Skip to content

Revert "No static locale infra (#2684)" #2702

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 1 commit into from
Aug 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
8 changes: 4 additions & 4 deletions src/components/colorPicker/colorPicker.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"description": "Callback for the picker's color palette change"
},
{
"name": "getAccessibilityLabels",
"type": "() => {\n addButton: string,\n dismissButton: string,\n doneButton: string,\n input: string}",
"description": "A function that returns the 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": "accessibilityLabels",
"type": "{\n addButton: string,\n dismissButton: string,\n doneButton: string,\n input: string}",
"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": "testID", "type": "string", "description": "The test id for e2e tests"},
{"name": "backgroundColor", "type": "string", "description": "The ColorPicker's background color"}
Expand Down
39 changes: 8 additions & 31 deletions src/components/colorPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ import ColorPalette, {ColorPaletteProps} from '../colorPalette';
import {SWATCH_MARGIN, SWATCH_SIZE} from '../colorSwatch';
import ColorPickerDialog, {ColorPickerDialogProps} from './ColorPickerDialog';

interface AccessibilityLabels {
addButton?: string;
dismissButton?: string;
doneButton?: string;
input?: string;
}

interface Props extends ColorPickerDialogProps, Pick<ColorPaletteProps, 'onValueChange'> {
/**
* Array of colors for the picker's color palette (hex values)
Expand All @@ -36,19 +29,13 @@ interface Props extends ColorPickerDialogProps, Pick<ColorPaletteProps, 'onValue
* doneButton: 'done',
* input: 'custom hex color code'
* }
* @deprecated
*/
accessibilityLabels?: AccessibilityLabels;
/**
* A function that returns the accessibility labels as an object of strings, ex.
* {
* addButton: 'add custom color using hex code',
* dismissButton: 'dismiss',
* doneButton: 'done',
* input: 'custom hex color code'
* }
*/
getAccessibilityLabels?: () => AccessibilityLabels;
accessibilityLabels?: {
addButton?: string;
dismissButton?: string;
doneButton?: string;
input?: string;
};
testID?: string;
/**
* The ColorPicker's background color
Expand All @@ -74,7 +61,7 @@ class ColorPicker extends PureComponent<Props> {
static displayName = 'ColorPicker';

static defaultProps = {
getAccessibilityLabels: () => ACCESSIBILITY_LABELS,
accessibilityLabels: ACCESSIBILITY_LABELS,
backgroundColor: Colors.$backgroundDefault
};

Expand All @@ -99,17 +86,7 @@ class ColorPicker extends PureComponent<Props> {
};

render() {
const {
initialColor,
colors,
value,
testID,
accessibilityLabels: deprecatedAccessibilityLabels,
getAccessibilityLabels,
backgroundColor,
onValueChange
} = this.props;
const accessibilityLabels = deprecatedAccessibilityLabels ?? getAccessibilityLabels?.();
const {initialColor, colors, value, testID, accessibilityLabels, backgroundColor, onValueChange} = this.props;
const {show} = this.state;
return (
<View row testID={testID} style={{backgroundColor}}>
Expand Down
25 changes: 4 additions & 21 deletions src/components/slider/ColorSliderGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import Text from '../text';

type SliderOnValueChange = (value: string) => void;

type Labels = {[key in GradientSliderTypes]: string};

export type ColorSliderGroupProps = {
/**
* The gradient color
Expand All @@ -31,17 +29,11 @@ export type ColorSliderGroupProps = {
* Show the sliders labels (defaults are: Hue, Lightness, Saturation)
*/
showLabels?: boolean;
/**
* In case you would like to change the default labels (translations etc.), you can provide
* this prop with a map to the relevant labels ({hue: ..., lightness: ..., saturation: ...}).
* @deprecated
*/
labels?: Labels;
/**
* In case you would like to change the default labels (translations etc.), you can provide
* this prop with a map to the relevant labels ({hue: ..., lightness: ..., saturation: ...}).
*/
getLabels?: () => Labels;
labels?: {[key in GradientSliderTypes]: string};
/**
* The labels style
*/
Expand All @@ -50,7 +42,7 @@ export type ColorSliderGroupProps = {
* If true the component will have accessibility features enabled
*/
accessible?: boolean;
/**
/**
* Whether to use the new Slider implementation using Reanimated
*/
migrate?: boolean;
Expand All @@ -69,7 +61,7 @@ class ColorSliderGroup extends PureComponent<ColorSliderGroupProps, ColorSliderG
static displayName = 'ColorSliderGroup';

static defaultProps = {
getLabels: () => ({hue: 'Hue', lightness: 'Lightness', saturation: 'Saturation'})
labels: {hue: 'Hue', lightness: 'Lightness', saturation: 'Saturation'}
};

state = {
Expand All @@ -91,16 +83,7 @@ class ColorSliderGroup extends PureComponent<ColorSliderGroupProps, ColorSliderG
};

renderSlider = (type: GradientSliderTypes) => {
const {
sliderContainerStyle,
showLabels,
labelsStyle,
accessible,
labels: deprecatedLabels,
getLabels,
migrate
} = this.props;
const labels = deprecatedLabels ?? getLabels?.();
const {sliderContainerStyle, showLabels, labelsStyle, accessible, labels, migrate} = this.props;

return (
<>
Expand Down