Skip to content

Commit 1e9fac7

Browse files
authored
ColorPicker - Moving sub-component out (#1692)
* ColorPicker - Moving sub-component (ColorPalette and ColorSwatch) to 'components' directory * fix imports
1 parent d50d424 commit 1e9fac7

File tree

14 files changed

+94
-8
lines changed

14 files changed

+94
-8
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import { StyleProp, ViewStyle } from 'react-native';
3+
interface Props {
4+
/**
5+
* Array of colors to render in the palette
6+
*/
7+
colors: string[];
8+
/**
9+
* Style to pass the palette container
10+
*/
11+
containerStyle?: StyleProp<ViewStyle>;
12+
/**
13+
* The container margins
14+
*/
15+
containerWidth?: number;
16+
/**
17+
* Whether to use pagination when number of colors exceeds the number of rows
18+
*/
19+
usePagination?: boolean;
20+
/**
21+
* Whether the colors pagination scrolls in a loop
22+
*/
23+
loop?: boolean;
24+
/**
25+
* The number of color rows from 2 to 5
26+
*/
27+
numberOfRows?: number;
28+
/**
29+
* Style to pass all the ColorSwatches in the palette
30+
*/
31+
swatchStyle?: StyleProp<ViewStyle>;
32+
/**
33+
* The value of the selected swatch
34+
*/
35+
value?: string;
36+
/**
37+
* The index of the item to animate at first render (default is last)
38+
*/
39+
animatedIndex?: number;
40+
/**
41+
* Invoked once when value changes by selecting one of the swatches in the palette
42+
*/
43+
onValueChange?: (value: string, options: object) => void;
44+
style?: StyleProp<ViewStyle>;
45+
testID?: string;
46+
}
47+
export declare type ColorPaletteProps = Props;
48+
declare const _default: React.ComponentClass<Props & {
49+
useCustomTheme?: boolean | undefined;
50+
}, any>;
51+
export default _default;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import { StyleProp, ViewStyle } from 'react-native';
3+
interface Props {
4+
/**
5+
* The identifier value of the ColorSwatch in a ColorSwatch palette.
6+
* Must be different than other ColorSwatches in the same group
7+
*/
8+
value?: string;
9+
/**
10+
* The color of the ColorSwatch
11+
*/
12+
color?: string;
13+
/**
14+
* Is the initial state is selected
15+
*/
16+
selected?: boolean;
17+
/**
18+
* Is first render should be animated
19+
*/
20+
animated?: boolean;
21+
/**
22+
* onPress callback
23+
*/
24+
onPress?: (value: string, options: object) => void;
25+
index?: number;
26+
style?: StyleProp<ViewStyle>;
27+
testID?: string;
28+
}
29+
export declare type ColorSwatchProps = Props;
30+
export declare const SWATCH_MARGIN = 12;
31+
export declare const SWATCH_SIZE: number;
32+
declare const _default: React.ComponentClass<Props & {
33+
useCustomTheme?: boolean | undefined;
34+
}, any>;
35+
export default _default;

src/components/colorPicker/ColorPalette.tsx renamed to src/components/colorPalette/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {Colors} from '../../style';
77
import {asBaseComponent} from '../../commons/new';
88
import View from '../view';
99
import Carousel from '../carousel';
10-
import PageControl from '../pageControl';
11-
import ColorSwatch, {SWATCH_SIZE} from './ColorSwatch';
1210
import ScrollBar from '../scrollBar';
11+
import PageControl from '../pageControl';
12+
import ColorSwatch, {SWATCH_SIZE} from '../colorSwatch';
1313

1414

1515
interface Props {
-1.24 KB
Binary file not shown.

src/components/colorPicker/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, {PureComponent} from 'react';
22
import {StyleSheet, StyleProp, ViewStyle} from 'react-native';
3-
import ColorPalette from './ColorPalette';
4-
import {SWATCH_MARGIN, SWATCH_SIZE} from './ColorSwatch';
53
import {asBaseComponent} from '../../commons/new';
64
import Assets from '../../assets';
75
import {Colors} from '../../style';
86
import View from '../view';
97
import Button from '../button';
8+
import ColorPalette from '../colorPalette';
9+
import {SWATCH_MARGIN, SWATCH_SIZE} from '../colorSwatch';
1010
import ColorPickerDialog, {ColorPickerDialogProps} from './ColorPickerDialog';
1111

1212

src/components/colorPicker/ColorSwatch.tsx renamed to src/components/colorSwatch/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, {PureComponent} from 'react';
22
import {StyleSheet, Animated, Easing, LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
33
import Assets from '../../assets';
4+
import {Constants} from '../../helpers';
5+
import {Colors} from '../../style';
46
import {asBaseComponent} from '../../commons/new';
57
import View from '../view';
68
import TouchableOpacity from '../touchableOpacity';
79
import Image from '../image';
8-
import {Colors} from '../../style';
9-
import {Constants} from '../../helpers';
1010

1111

1212
interface Props {

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ export default {
3434
return require('./components/checkbox').default;
3535
},
3636
get ColorPalette() {
37-
return require('./components/colorPicker/ColorPalette').default;
37+
return require('./components/colorPalette').default;
3838
},
3939
get ColorPicker() {
4040
return require('./components/colorPicker').default;
4141
},
4242
get ColorSwatch() {
43-
return require('./components/colorPicker/ColorSwatch').default;
43+
return require('./components/colorSwatch').default;
4444
},
4545
get ConnectionStatusBar() {
4646
return require('./components/connectionStatusBar').default;

0 commit comments

Comments
 (0)