Skip to content

Commit

Permalink
Updated tests and types
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinaKozlova committed Nov 14, 2024
1 parent b459c3b commit 98a7604
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe('AlphaSlider', () => {
});

it('renders a default state', () => {
const result = render(<AlphaSlider overlayColor="red" />);
const hsvColor = { h: 0, s: 1, v: 1 };
const result = render(<AlphaSlider color={hsvColor} />);
expect(result.container).toMatchInlineSnapshot(`
<div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type AlphaSliderSlots = ColorSliderSlots;
*/
export type AlphaSliderProps = Omit<
ComponentProps<Partial<AlphaSliderSlots>, 'input'>,
'defaultValue' | 'onChange' | 'value'
'defaultValue' | 'onChange' | 'value' | ' color'
> &
ColorSliderProps & {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useColorArea_unstable = (props: ColorAreaProps, ref: React.Ref<HTML
const colorFromContext = useColorPickerContextValue_unstable(ctx => ctx.color);

const {
onChange = onChangeFromContext,
onChange = onChangeFromContext as unknown as ColorAreaProps['onChange'],
// Slots
inputX,
inputY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('ColorSlider', () => {
<input
class="fui-ColorSlider__input"
id="slider-9"
max="360"
min="0"
type="range"
value="0"
/>
Expand All @@ -42,7 +44,7 @@ describe('ColorSlider', () => {
});

it('applies the color prop', () => {
render(<ColorSlider color="#f09" />);
render(<ColorSlider color={{ h: 324, s: 1, v: 1 }} />);
expect(screen.getByRole('slider').getAttribute('value')).toEqual('324');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type ColorSliderSlots = {
*/
export type ColorSliderProps = Omit<
ComponentProps<Partial<ColorSliderSlots>, 'input'>,
'defaultValue' | 'onChange' | 'value'
'defaultValue' | 'onChange' | 'value' | 'color'
> & {
channel?: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { ColorPickerProps, ColorPickerState, HsvColor } from '../components
/**
* The context through which individual color controls communicate with the picker.
*/
export type ColorPickerContextValue = Pick<ColorPickerProps, 'color'> & {
export type ColorPickerContextValue = {
color: HsvColor;
/**
* @internal
* Callback used by Sliders to request a change on it's selected value
Expand All @@ -31,7 +32,7 @@ export const colorPickerContextDefaultValue: ColorPickerContextValue = {
requestChange: () => {
/*noop*/
},
color: undefined,
color: { h: 0, s: 0, v: 0 },
};

export type ColorPickerContextValues = {
Expand Down

0 comments on commit 98a7604

Please sign in to comment.