Skip to content

Commit 98a7604

Browse files
Updated tests and types
1 parent b459c3b commit 98a7604

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

packages/react-components/react-color-picker-preview/library/src/components/AlphaSlider/AlphaSlider.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ describe('AlphaSlider', () => {
2525
});
2626

2727
it('renders a default state', () => {
28-
const result = render(<AlphaSlider overlayColor="red" />);
28+
const hsvColor = { h: 0, s: 1, v: 1 };
29+
const result = render(<AlphaSlider color={hsvColor} />);
2930
expect(result.container).toMatchInlineSnapshot(`
3031
<div>
3132
<div

packages/react-components/react-color-picker-preview/library/src/components/AlphaSlider/AlphaSlider.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type AlphaSliderSlots = ColorSliderSlots;
99
*/
1010
export type AlphaSliderProps = Omit<
1111
ComponentProps<Partial<AlphaSliderSlots>, 'input'>,
12-
'defaultValue' | 'onChange' | 'value'
12+
'defaultValue' | 'onChange' | 'value' | ' color'
1313
> &
1414
ColorSliderProps & {
1515
/**

packages/react-components/react-color-picker-preview/library/src/components/ColorArea/useColorArea.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const useColorArea_unstable = (props: ColorAreaProps, ref: React.Ref<HTML
2929
const colorFromContext = useColorPickerContextValue_unstable(ctx => ctx.color);
3030

3131
const {
32-
onChange = onChangeFromContext,
32+
onChange = onChangeFromContext as unknown as ColorAreaProps['onChange'],
3333
// Slots
3434
inputX,
3535
inputY,

packages/react-components/react-color-picker-preview/library/src/components/ColorSlider/ColorSlider.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ describe('ColorSlider', () => {
2121
<input
2222
class="fui-ColorSlider__input"
2323
id="slider-9"
24+
max="360"
25+
min="0"
2426
type="range"
2527
value="0"
2628
/>
@@ -42,7 +44,7 @@ describe('ColorSlider', () => {
4244
});
4345

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

packages/react-components/react-color-picker-preview/library/src/components/ColorSlider/ColorSlider.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type ColorSliderSlots = {
1818
*/
1919
export type ColorSliderProps = Omit<
2020
ComponentProps<Partial<ColorSliderSlots>, 'input'>,
21-
'defaultValue' | 'onChange' | 'value'
21+
'defaultValue' | 'onChange' | 'value' | 'color'
2222
> & {
2323
channel?: string;
2424

packages/react-components/react-color-picker-preview/library/src/contexts/colorPicker.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import type { ColorPickerProps, ColorPickerState, HsvColor } from '../components
66
/**
77
* The context through which individual color controls communicate with the picker.
88
*/
9-
export type ColorPickerContextValue = Pick<ColorPickerProps, 'color'> & {
9+
export type ColorPickerContextValue = {
10+
color: HsvColor;
1011
/**
1112
* @internal
1213
* Callback used by Sliders to request a change on it's selected value
@@ -31,7 +32,7 @@ export const colorPickerContextDefaultValue: ColorPickerContextValue = {
3132
requestChange: () => {
3233
/*noop*/
3334
},
34-
color: undefined,
35+
color: { h: 0, s: 0, v: 0 },
3536
};
3637

3738
export type ColorPickerContextValues = {

0 commit comments

Comments
 (0)