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 1 commit
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
1 change: 0 additions & 1 deletion src/components/colorPicker/colorPicker.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"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"}
],
"snippet": [
Expand Down
17 changes: 13 additions & 4 deletions 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 @@ -65,15 +66,23 @@ const ACCESSIBILITY_LABELS = {
class ColorPicker extends PureComponent<Props> {
static displayName = 'ColorPicker';

static defaultProps = {
accessibilityLabels: ACCESSIBILITY_LABELS,
backgroundColor: Colors.$backgroundDefault
};
constructor(props: Props) {
super(props);

if (props.style) {
LogService.warn('UILib ColorPicker style prop is deprecated.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LogService.warn('UILib ColorPicker style prop is deprecated.');
LogService.warn('UILib ColorPicker style prop is deprecated. Please stop using it.');

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also tell the user what to do, otherwise, they will ask if there is another prop that replaces it etc.

}
}

state = {
show: false
};

static defaultProps = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep the statics up after the static displayName

accessibilityLabels: ACCESSIBILITY_LABELS,
backgroundColor: Colors.$backgroundDefault
};

get animatedIndex() {
const {animatedIndex, colors} = this.props;
if (animatedIndex === undefined) {
Expand Down