Skip to content

Commit 45f27d9

Browse files
authored
Avatar and Text - design tokens (#1917)
* Avatar and Text - design tokens * Revert Text * Change to * Fix screen background and text
1 parent b5fb1f3 commit 45f27d9

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

demo/src/screens/componentScreens/AvatarsScreen.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import _ from 'lodash';
22
import React, {Component} from 'react';
3-
import {ScrollView, View, Text, StyleSheet, Alert} from 'react-native';
4-
import {Avatar, AvatarHelper, Colors, Typography} from 'react-native-ui-lib'; //eslint-disable-line
3+
import {ScrollView, StyleSheet, Alert} from 'react-native';
4+
import {Avatar, AvatarHelper, View, Text, Colors, Typography} from 'react-native-ui-lib'; //eslint-disable-line
55

66

77
const star = require('../../assets/icons/star.png');
8-
const onlineColor = Colors.green30;
8+
const onlineColor = Colors.$backgroundSuccessHeavy;
99
const examples = [
1010
{title: 'Custom Background', backgroundColor: Colors.violet60},
1111
{title: 'Empty Avatar with ribbon', ribbonLabel: 'New'},
1212
{
1313
title: 'Initials with Color',
1414
label: 'AD',
15-
backgroundColor: Colors.yellow60,
16-
labelColor: Colors.orange20,
15+
backgroundColor: Colors.$backgroundWarning,
16+
labelColor: Colors.$textMajor,
1717
ribbonLabel: 'New',
1818
ribbonStyle: {backgroundColor: Colors.purple30}
1919
},
@@ -24,7 +24,7 @@ const examples = [
2424
uri:
2525
'https://lh3.googleusercontent.com/-cw77lUnOvmI/AAAAAAAAAAI/AAAAAAAAAAA/WMNck32dKbc/s181-c/104220521160525129167.jpg'
2626
},
27-
badgeProps: {size: 10, backgroundColor: Colors.yellow30},
27+
badgeProps: {size: 10, backgroundColor: Colors.$backgroundWarningHeavy},
2828
badgePosition: 'BOTTOM_RIGHT'
2929
},
3030

@@ -35,7 +35,7 @@ const examples = [
3535
uri:
3636
'https://lh3.googleusercontent.com/-CMM0GmT5tiI/AAAAAAAAAAI/AAAAAAAAAAA/-o9gKbC6FVo/s181-c/111308920004613908895.jpg'
3737
},
38-
badgeProps: {size: 10, backgroundColor: Colors.grey50},
38+
badgeProps: {size: 10, backgroundColor: Colors.$backgroundDisabled},
3939
badgePosition: 'BOTTOM_LEFT'
4040
},
4141
{
@@ -65,8 +65,8 @@ const examples = [
6565
icon: star,
6666
size: 14,
6767
borderWidth: 1.5,
68-
borderColor: Colors.white,
69-
iconStyle: {backgroundColor: Colors.yellow20}
68+
borderColor: Colors.$outlineLight,
69+
iconStyle: {backgroundColor: Colors.$backgroundWarningHeavy}
7070
}
7171
},
7272
{
@@ -79,7 +79,7 @@ const examples = [
7979
{
8080
title: 'Invalid Gravatar (see logs)',
8181
label: '🤦',
82-
backgroundColor: Colors.grey60,
82+
backgroundColor: Colors.$backgroundNeutralMedium,
8383
source: {uri: 'https://www.gravatar.com/avatar/00000000000000000000000000000000?d=404'},
8484
onImageLoadStart: () => console.log('AvatarScreen: Invalid avatar load STARTED...'), // eslint-disable-line
8585
onImageLoadEnd: () => console.log('AvatarScreen: Invalid avatar load ENDED'), // eslint-disable-line
@@ -88,26 +88,26 @@ const examples = [
8888
{
8989
title: 'Monitored Avatar (see logs)',
9090
label: '?!',
91-
backgroundColor: Colors.blue20,
91+
backgroundColor: Colors.$backgroundGeneralHeavy,
9292
source: {uri: 'https://static.altomusic.com/media/catalog/product/M/A/MAJ100SBK_0.jpg'},
9393
onImageLoadStart: () => console.log('AvatarScreen: Monitored avatar load STARTED...'), // eslint-disable-line
9494
onImageLoadEnd: () => console.log('AvatarScreen: Monitored avatar load ENDED') // eslint-disable-line
9595
},
9696
{
9797
title: 'Empty Gravatar',
98-
backgroundColor: Colors.red60,
98+
backgroundColor: Colors.$backgroundDanger,
9999
source: {uri: 'https://www.gravatar.com/avatar/2497473d558a37020c558bf26e380a7c?d=blank'}
100100
},
101101
{
102102
title: 'With custom badge label',
103103
label: 'LD',
104-
backgroundColor: Colors.red60,
104+
backgroundColor: Colors.$backgroundDanger,
105105
badgePosition: 'BOTTOM_RIGHT',
106106
badgeProps: {
107107
label: '+2',
108108
size: 24,
109109
borderWidth: 1.5,
110-
borderColor: Colors.white
110+
borderColor: Colors.$outlineLight
111111
}
112112
}
113113
];
@@ -130,7 +130,7 @@ export default class AvatarsScreen extends Component {
130130
<ScrollView contentContainerStyle={styles.container}>
131131
{_.map(examples, (example, i) => (
132132
<View key={i} style={styles.section}>
133-
<Text style={{...Typography.text80}}>{example.title}</Text>
133+
<Text $textDefault style={{...Typography.text80}}>{example.title}</Text>
134134
<Avatar containerStyle={{marginVertical: 5}} {...example} onPress={() => this.onAvatarPress(example)}/>
135135
</View>
136136
))}
@@ -141,7 +141,8 @@ export default class AvatarsScreen extends Component {
141141

142142
const styles = StyleSheet.create({
143143
container: {
144-
padding: 25
144+
padding: 25,
145+
backgroundColor: Colors.$backgroundDefault
145146
},
146147
section: {
147148
flexDirection: 'row',

src/components/avatar/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class Avatar extends PureComponent<AvatarProps> {
179179
static defaultProps = {
180180
animate: false,
181181
size: 50,
182-
labelColor: Colors.grey10,
182+
labelColor: Colors.$textDefault,
183183
badgePosition: BadgePosition.TOP_RIGHT
184184
};
185185

@@ -266,7 +266,7 @@ class Avatar extends PureComponent<AvatarProps> {
266266
<View style={this.getRibbonStyle()}>{customRibbon}</View>
267267
) : (
268268
<View style={[this.getRibbonStyle(), this.styles.ribbon, ribbonStyle]}>
269-
<Text numberOfLines={1} text100 white style={[ribbonLabelStyle]}>
269+
<Text numberOfLines={1} text100 $textDefaultLight style={[ribbonLabelStyle]}>
270270
{ribbonLabel}
271271
</Text>
272272
</View>
@@ -332,7 +332,7 @@ class Avatar extends PureComponent<AvatarProps> {
332332
const {
333333
avatarColors = AvatarHelper.getAvatarColors(),
334334
hashFunction = AvatarHelper.hashStringToNumber,
335-
defaultColor = Colors.grey80
335+
defaultColor = Colors.$backgroundNeutralLight
336336
} = autoColorsConfig || {};
337337
if (useAutoColors) {
338338
return this.getBackgroundColor(name, avatarColors, hashFunction, defaultColor);
@@ -407,7 +407,7 @@ function createStyles(props: AvatarProps) {
407407
lineHeight: undefined
408408
},
409409
ribbon: {
410-
backgroundColor: Colors.primary,
410+
backgroundColor: Colors.$backgroundPrimaryHeavy,
411411
paddingHorizontal: 6,
412412
paddingVertical: 3
413413
}

0 commit comments

Comments
 (0)