Skip to content

ColorPicker style prop deprecation #2444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/colorPalette/ColorPalette.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
{"name": "containerWidth", "type": "number", "description": "The container margins"},
{"name": "containerStyle", "type": "ViewStyle", "description": "Component's container style"},
{"name": "style", "type": "ViewStyle", "description": "Component's style"},
{"name": "testID", "type": "string", "description": "The test id for e2e tests"}
{"name": "testID", "type": "string", "description": "The test id for e2e tests"},
{"name": "backgroundColor", "type": "string", "description": "The ColorPalette's background color"}
],
"snippet": [
"<ColorPalette",
Expand Down
2 changes: 1 addition & 1 deletion src/components/colorPalette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface Props {
style?: StyleProp<ViewStyle>;
testID?: string;
/**
* Give the ColorPalette a background color
* The ColorPalette's background color
*/
backgroundColor?: string;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/colorPicker/colorPicker.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"description": "Accessibility labels as an object of strings",
"default": "{\n addButton: 'add custom color using hex code',\n dismissButton: 'dismiss',\n doneButton: 'done',\n input: 'custom hex color code'\n}"
},
{"name": "style", "type": "ViewStyle", "description": "Component's style"},
{"name": "testID", "type": "string", "description": "The test id for e2e tests"}
{"name": "testID", "type": "string", "description": "The test id for e2e tests"},
{"name": "backgroundColor", "type": "string", "description": "The ColorPicker's background color"}
],
"snippet": [
"<ColorPicker",
Expand Down
11 changes: 10 additions & 1 deletion src/components/colorPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Button from '../button';
import ColorPalette from '../colorPalette';
import {SWATCH_MARGIN, SWATCH_SIZE} from '../colorSwatch';
import ColorPickerDialog, {ColorPickerDialogProps} from './ColorPickerDialog';
import {LogService} from '../../services';

interface Props extends ColorPickerDialogProps {
/**
Expand Down Expand Up @@ -43,7 +44,7 @@ interface Props extends ColorPickerDialogProps {
style?: StyleProp<ViewStyle>;
testID?: string;
/**
* Give the ColorPicker a background color
* The ColorPicker's background color
*/
backgroundColor?: string;
}
Expand All @@ -70,6 +71,14 @@ class ColorPicker extends PureComponent<Props> {
backgroundColor: Colors.$backgroundDefault
};

constructor(props: Props) {
super(props);

if (props.style) {
LogService.warn(`UILib ColorPicker's 'style' prop is deprecated. You can use the 'backgroundColor' prop instead`);
}
}

state = {
show: false
};
Expand Down