Skip to content

Commit b77e5aa

Browse files
authored
Checkbox - to design tokens (#1920)
1 parent 940b4fc commit b77e5aa

File tree

2 files changed

+67
-61
lines changed

2 files changed

+67
-61
lines changed
Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, {Component} from 'react';
2-
import {Checkbox, Assets, Text, View, Colors, Spacings} from 'react-native-ui-lib'; //eslint-disable-line
2+
import {StyleSheet} from 'react-native';
3+
import {Checkbox, Assets, Text, View, Colors} from 'react-native-ui-lib'; //eslint-disable-line
34

4-
class CheckboxScreen extends Component {
5+
export default class CheckboxScreen extends Component {
56
state = {
67
value1: false,
78
value2: false,
@@ -14,63 +15,67 @@ class CheckboxScreen extends Component {
1415
render() {
1516
return (
1617
<View useSafeArea flex>
17-
<View flex padding-20>
18-
<View flex center>
19-
<Checkbox
20-
value={this.state.value1}
21-
onValueChange={value1 => this.setState({value1})}
22-
style={{marginBottom: 20}}
23-
/>
24-
<Checkbox
25-
value={this.state.value6}
26-
label={'With label'}
27-
color={Colors.green20}
28-
onValueChange={value6 => this.setState({value6})}
29-
containerStyle={{marginBottom: 20, marginLeft: 75}}
30-
/>
31-
<Checkbox
32-
value={this.state.value2}
33-
onValueChange={value2 => this.setState({value2})}
34-
borderRadius={2}
35-
size={30}
36-
color={Colors.purple30}
37-
selectedIcon={Assets.icons.x}
38-
style={{marginBottom: 20}}
39-
/>
40-
<Checkbox
41-
value={this.state.value3}
42-
onValueChange={value3 => this.setState({value3})}
43-
borderRadius={5}
44-
size={18}
45-
color={Colors.grey10}
46-
iconColor={Colors.green10}
47-
style={{marginBottom: 20}}
48-
/>
49-
<View row marginB-20>
50-
<Text text70 centerV>
51-
Disabled:{' '}
52-
</Text>
53-
<Checkbox
54-
disabled
55-
value={this.state.value5}
56-
onValueChange={value5 => this.setState({value5})}
57-
style={{marginRight: 10}}
58-
/>
59-
<Checkbox
60-
disabled
61-
value={!this.state.value5}
62-
onValueChange={value5 => this.setState({value5})}
63-
iconColor={Colors.green10}
64-
/>
65-
</View>
66-
</View>
67-
<Text text40 grey10>
68-
Checkbox
18+
<Text text40 $textDefault margin-20>
19+
Checkbox
20+
</Text>
21+
22+
<Checkbox
23+
value={this.state.value1}
24+
onValueChange={value1 => this.setState({value1})}
25+
style={styles.checkbox}
26+
/>
27+
<Checkbox
28+
value={this.state.value6}
29+
label={'With label'}
30+
color={Colors.green20}
31+
onValueChange={value6 => this.setState({value6})}
32+
containerStyle={styles.checkbox}
33+
/>
34+
<Checkbox
35+
value={this.state.value2}
36+
onValueChange={value2 => this.setState({value2})}
37+
borderRadius={2}
38+
size={30}
39+
color={Colors.purple30}
40+
selectedIcon={Assets.icons.x}
41+
style={styles.checkbox}
42+
/>
43+
<Checkbox
44+
value={this.state.value3}
45+
onValueChange={value3 => this.setState({value3})}
46+
borderRadius={5}
47+
size={18}
48+
color={Colors.grey10}
49+
iconColor={Colors.green10}
50+
style={styles.checkbox}
51+
/>
52+
<View row margin-20 style={styles.row}>
53+
<Text $textDefault marginR-10>
54+
Disabled:
6955
</Text>
56+
<Checkbox
57+
disabled
58+
value={this.state.value5}
59+
onValueChange={value5 => this.setState({value5})}
60+
style={{marginRight: 10}}
61+
/>
62+
<Checkbox
63+
disabled
64+
value={!this.state.value5}
65+
onValueChange={value5 => this.setState({value5})}
66+
iconColor={Colors.green10}
67+
/>
7068
</View>
7169
</View>
7270
);
7371
}
7472
}
7573

76-
export default CheckboxScreen;
74+
const styles = StyleSheet.create({
75+
checkbox: {
76+
margin: 20
77+
},
78+
row: {
79+
alignItems: 'center'
80+
}
81+
});

src/components/checkbox/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import Text, {TextProps} from '../text';
1818
import View from '../view';
1919

2020
const DEFAULT_SIZE = 24;
21-
const DEFAULT_COLOR = Colors.primary;
22-
const DEFAULT_ICON_COLOR = Colors.white;
23-
const DEFAULT_DISABLED_COLOR = Colors.grey50;
21+
const DEFAULT_COLOR = Colors.$backgroundPrimaryHeavy;
22+
const DEFAULT_ICON_COLOR = Colors.$iconDefaultLight;
23+
const DEFAULT_DISABLED_COLOR = Colors.$backgroundDisabled;
2424

2525
const DEFAULT_BORDER_WIDTH = 2;
2626
const DEFAULT_BORDER_RADIUS = 8;
@@ -188,9 +188,9 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
188188
return iconColor || DEFAULT_COLOR;
189189
}
190190
} else if (disabled) {
191-
return Colors.white;
191+
return DEFAULT_ICON_COLOR;
192192
} else {
193-
return iconColor || Colors.white;
193+
return iconColor || DEFAULT_ICON_COLOR;
194194
}
195195
};
196196

@@ -276,7 +276,8 @@ function createStyles(props: CheckboxProps) {
276276
},
277277
checkboxLabel: {
278278
marginLeft: Spacings.s3,
279-
alignSelf: 'center'
279+
alignSelf: 'center',
280+
color: Colors.$textDefault
280281
}
281282
});
282283
}

0 commit comments

Comments
 (0)