Skip to content

Commit 3a0904b

Browse files
joyenjoyeradamlobler
authored andcommitted
refactor(ui-avatar): rename Avatar tokens in index.tsx and styles.ts
1 parent bf27edc commit 3a0904b

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

packages/ui-avatar/src/Avatar/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
import { useStyle } from '@instructure/emotion'
25+
import { useStyle, useTheme } from '@instructure/emotion'
2626
import { useState, useEffect, forwardRef, SyntheticEvent } from 'react'
2727

2828
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
@@ -53,6 +53,8 @@ const Avatar = forwardRef<HTMLDivElement, AvatarProps>(
5353
margin
5454
} = props
5555
const [loaded, setLoaded] = useState(false)
56+
const theme = useTheme()
57+
const iconTokens = (theme as any).newTheme.components.Icon
5658

5759
const styles = useStyle({
5860
generateStyle,
@@ -66,7 +68,8 @@ const Avatar = forwardRef<HTMLDivElement, AvatarProps>(
6668
showBorder,
6769
themeOverride,
6870
display,
69-
margin
71+
margin,
72+
iconTokens
7073
},
7174
componentId: 'Avatar',
7275
displayName: 'Avatar'

packages/ui-avatar/src/Avatar/styles.ts

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type StyleParams = {
3737
themeOverride: AvatarProps['themeOverride']
3838
display: AvatarProps['display']
3939
margin: AvatarProps['margin']
40+
iconTokens: NewComponentTypes['Icon']
4041
}
4142
/**
4243
* ---
@@ -61,7 +62,8 @@ const generateStyle = (
6162
shape,
6263
showBorder,
6364
display,
64-
margin
65+
margin,
66+
iconTokens
6567
} = params
6668

6769
const sizeStyles = {
@@ -111,40 +113,34 @@ const generateStyle = (
111113

112114
const colorVariants = {
113115
accent1: {
114-
text: componentTheme.accent1TextColor,
115-
background: componentTheme.accent1BackgroundColor
116-
//TODO-rework add icon handling
117-
// icon: componentTheme.accent1IconColor
116+
text: componentTheme.blueTextColor,
117+
background: componentTheme.blueBackgroundColor,
118+
icon: iconTokens.accentBlueColor
118119
},
119120
accent2: {
120-
text: componentTheme.accent2TextColor,
121-
background: componentTheme.accent2BackgroundColor
122-
//TODO-rework add icon handling
123-
// icon: componentTheme.accent2IconColor
121+
text: componentTheme.greenTextColor,
122+
background: componentTheme.greenBackgroundColor,
123+
icon: iconTokens.accentGreenColor
124124
},
125125
accent3: {
126-
text: componentTheme.accent3TextColor,
127-
background: componentTheme.accent3BackgroundColor
128-
//TODO-rework add icon handling
129-
// icon: componentTheme.accent3IconColor
126+
text: componentTheme.redTextColor,
127+
background: componentTheme.redBackgroundColor,
128+
icon: iconTokens.accentRedColor
130129
},
131130
accent4: {
132-
text: componentTheme.accent4TextColor,
133-
background: componentTheme.accent4BackgroundColor
134-
//TODO-rework add icon handling
135-
// icon: componentTheme.accent4IconColor
131+
text: componentTheme.orangeTextColor,
132+
background: componentTheme.orangeBackgroundColor,
133+
icon: iconTokens.accentOrangeColor
136134
},
137135
accent5: {
138-
text: componentTheme.accent5TextColor,
139-
background: componentTheme.accent5BackgroundColor
140-
//TODO-rework add icon handling
141-
// icon: componentTheme.accent5IconColor
136+
text: componentTheme.greyTextColor,
137+
background: componentTheme.greyBackgroundColor,
138+
icon: iconTokens.accentGreyColor
142139
},
143140
accent6: {
144-
text: componentTheme.accent6TextColor,
145-
background: componentTheme.accent6BackgroundColor
146-
//TODO-rework add icon handling
147-
// icon: componentTheme.accent6IconColor
141+
text: componentTheme.ashTextColor,
142+
background: componentTheme.ashBackgroundColor,
143+
icon: iconTokens.accentAshColor
148144
},
149145
ai: {
150146
text: componentTheme.textOnColor,

0 commit comments

Comments
 (0)