Skip to content

Commit 5bf3564

Browse files
authored
Infra/design tokens color swatch (#2029)
* Design Tokens - ColorSwatch - not final * Add border to transparent * Fix ColorPalette fader color
1 parent 4b4049c commit 5bf3564

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

demo/src/screens/componentScreens/ColorSwatchScreen.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {ScrollView} from 'react-native';
44
import {Constants, Colors, View, Text, ColorSwatch, ColorPalette} from 'react-native-ui-lib'; //eslint-disable-line
55

66
export default class ColorSwatchScreen extends Component {
7-
colors = ['transparent', Colors.green30, Colors.yellow30, Colors.red30];
7+
colors = [
8+
'transparent',
9+
Colors.$backgroundSuccessHeavy,
10+
Colors.$backgroundWarningHeavy,
11+
Colors.$backgroundDangerHeavy
12+
];
813
mainColors = [
914
'#66737C',
1015
'#459FED',
@@ -50,15 +55,15 @@ export default class ColorSwatchScreen extends Component {
5055
const {color, color1, color2, selected} = this.state;
5156

5257
return (
53-
<ScrollView style={{backgroundColor: Colors.grey80}}>
58+
<ScrollView style={{backgroundColor: Colors.$backgroundNeutralLight}}>
5459
<View flex center useSafeArea>
5560
<Text margin-5 text60 grey10>
5661
Single ColorSwatch
5762
</Text>
5863
<View row>
5964
<ColorSwatch selected={selected} onPress={this.onPress}/>
6065
<View>
61-
<ColorSwatch selected color={Colors.orange60}/>
66+
<ColorSwatch selected color={Colors.$backgroundMajor}/>
6267
<Text>Disabled</Text>
6368
</View>
6469
</View>

src/components/colorPalette/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ class ColorPalette extends PureComponent<Props, State> {
347347
height={SCROLLABLE_HEIGHT}
348348
containerProps={{width: !scrollable ? contentWidth : undefined}}
349349
gradientHeight={SCROLLABLE_HEIGHT - 12}
350+
gradientColor={Colors.$backgroundDefault}
350351
>
351352
{this.renderPalette(others, styles.scrollContent, this.colors, 0)}
352353
</ScrollBar>

src/components/colorSwatch/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +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 {Colors} from '../../style';
4+
import {BorderRadiuses, Colors} from '../../style';
55
import {Constants, asBaseComponent} from '../../commons/new';
66
import View from '../view';
77
import TouchableOpacity from '../touchableOpacity';
88
import Image from '../image';
99

10-
1110
interface Props {
1211
/**
1312
* The identifier value of the ColorSwatch in a ColorSwatch palette.
@@ -110,9 +109,9 @@ class ColorSwatch extends PureComponent<Props> {
110109
getTintColor(color?: string) {
111110
if (color) {
112111
if (Colors.isTransparent(color)) {
113-
return Colors.black;
112+
return Colors.$iconDefault;
114113
}
115-
return Colors.isDark(color) ? Colors.white : Colors.black;
114+
return Colors.isDark(color) ? Colors.$iconDefaultLight : Colors.$iconDefault;
116115
}
117116
}
118117

@@ -192,7 +191,6 @@ class ColorSwatch extends PureComponent<Props> {
192191

193192
export default asBaseComponent<Props>(ColorSwatch);
194193

195-
196194
function createStyles({color = Colors.grey30}) {
197195
return StyleSheet.create({
198196
container: {
@@ -202,12 +200,15 @@ function createStyles({color = Colors.grey30}) {
202200
borderRadius: DEFAULT_SIZE / 2,
203201
margin: SWATCH_MARGIN,
204202
borderWidth: color === 'transparent' ? undefined : 1,
205-
borderColor: Colors.rgba(Colors.grey30, 0.2)
203+
borderColor: Colors.rgba(Colors.$outlineDisabledHeavy, 0.2)
206204
},
207205
transparentImage: {
208206
...StyleSheet.absoluteFillObject,
209207
width: DEFAULT_SIZE,
210-
height: DEFAULT_SIZE
208+
height: DEFAULT_SIZE,
209+
borderWidth: 1,
210+
borderRadius: BorderRadiuses.br100,
211+
borderColor: Colors.rgba(Colors.$outlineDisabledHeavy, 0.2)
211212
}
212213
});
213214
}

0 commit comments

Comments
 (0)