File tree Expand file tree Collapse file tree 6 files changed +18
-11
lines changed Expand file tree Collapse file tree 6 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 5
5
* found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
*/
7
7
8
+ import { useTheme } from 'styled-components' ;
8
9
import React , { useCallback , useState } from 'react' ;
9
10
import { StoryFn } from '@storybook/react' ;
10
11
import { Grid } from '@zendeskgarden/react-grid' ;
11
12
import { Menu , Item } from '@zendeskgarden/react-dropdowns' ;
12
13
import { Avatar , IAvatarProps } from '@zendeskgarden/react-avatars' ;
14
+ import { getColor } from '@zendeskgarden/react-theming' ;
13
15
14
16
const items : {
15
17
value : string ;
@@ -49,6 +51,8 @@ export const MenuStory: StoryFn = ({ isCompact }) => {
49
51
focusedValue !== undefined && setHighlightedValue ( focusedValue ) ;
50
52
} , [ ] ) ;
51
53
54
+ const theme = useTheme ( ) ;
55
+
52
56
return (
53
57
< Grid >
54
58
< Grid . Row style = { { height : 'calc(100vh - 80px)' } } >
@@ -64,7 +68,14 @@ export const MenuStory: StoryFn = ({ isCompact }) => {
64
68
status = { item . avatarProps . status }
65
69
badge = { item . avatarProps . badge }
66
70
surfaceColor = {
67
- highlightedValue === item . value ? 'background.primary' : 'background.raised'
71
+ highlightedValue === item . value
72
+ ? getColor ( {
73
+ theme,
74
+ hue : 'primaryHue' ,
75
+ light : { shade : 100 } ,
76
+ dark : { shade : 900 }
77
+ } )
78
+ : 'background.raised'
68
79
}
69
80
>
70
81
< img alt = { item . label } src = { `images/avatars/${ item . value } .png` } />
Original file line number Diff line number Diff line change @@ -52,14 +52,14 @@ describe('StyledAvatar', () => {
52
52
53
53
it ( 'renders surface color variable key as expected' , ( ) => {
54
54
const { container, rerender } = render (
55
- < StyledAvatar $status = "away" $surfaceColor = "background.primary " />
55
+ < StyledAvatar $status = "away" $surfaceColor = "background.primaryEmphasis " />
56
56
) ;
57
57
58
- expect ( container . firstChild ) . toHaveStyleRule ( 'color' , PALETTE . blue [ 100 ] , {
58
+ expect ( container . firstChild ) . toHaveStyleRule ( 'color' , PALETTE . blue [ 700 ] , {
59
59
modifier : '&&'
60
60
} ) ;
61
61
62
- rerender ( < StyledAvatar $surfaceColor = "background.primary " /> ) ;
62
+ rerender ( < StyledAvatar $surfaceColor = "background.primaryEmphasis " /> ) ;
63
63
64
64
expect ( container . firstChild ) . toHaveStyleRule ( 'color' , 'transparent' , {
65
65
modifier : '&&'
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export interface IAvatarProps extends HTMLAttributes<HTMLElement> {
29
29
/**
30
30
* Provides surface color for an avatar placed on a non-default background.
31
31
* Accepts a [color variable](/components/theme-object#colors) key (i.e.
32
- * `background.primary `) to render based on light/dark mode, or any hex value.
32
+ * `background.subtle `) to render based on light/dark mode, or any hex value.
33
33
*/
34
34
surfaceColor ?: string ;
35
35
/** Applies system styling for representing objects, brands, or products */
Original file line number Diff line number Diff line change @@ -22,15 +22,15 @@ interface IArgs {
22
22
const StyledDiv = styled . div < Omit < IArgs , 'isAnimated' > > `
23
23
border: ${ p =>
24
24
p . hasBorder &&
25
- `${ p . theme . borders . sm } ${ getColor ( { theme : p . theme , variable : 'border.primaryEmphasis ' } ) } ` } ;
25
+ `${ p . theme . borders . sm } ${ getColor ( { theme : p . theme , variable : 'border.default ' } ) } ` } ;
26
26
box-shadow: ${ p =>
27
27
p . hasBoxShadow &&
28
28
p . theme . shadows . lg (
29
29
`${ p . theme . space . base * ( p . theme . colors . base === 'dark' ? 4 : 5 ) } px` ,
30
30
`${ p . theme . space . base * ( p . theme . colors . base === 'dark' ? 5 : 6 ) } px` ,
31
31
getColor ( { variable : 'shadow.medium' , theme : p . theme } )
32
32
) } ;
33
- background-color: ${ p => getColor ( { theme : p . theme , variable : 'background.primary ' } ) } ;
33
+ background-color: ${ p => getColor ( { theme : p . theme , variable : 'background.subtle ' } ) } ;
34
34
padding: ${ p => p . theme . space . xxl } ;
35
35
36
36
${ p =>
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ exports[`DEFAULT_THEME matches snapshot 1`] = `
39
39
" default" : " neutralHue.1100" ,
40
40
" disabled" : " rgba(neutralHue.500, 100)" ,
41
41
" emphasis" : " neutralHue.600" ,
42
- " primary" : " primaryHue.900" ,
43
42
" primaryEmphasis" : " primaryHue.600" ,
44
43
" raised" : " neutralHue.1000" ,
45
44
" recessed" : " neutralHue.1200" ,
@@ -88,7 +87,6 @@ exports[`DEFAULT_THEME matches snapshot 1`] = `
88
87
" default" : " palette.white" ,
89
88
" disabled" : " rgba(neutralHue.700, 100)" ,
90
89
" emphasis" : " neutralHue.700" ,
91
- " primary" : " primaryHue.100" ,
92
90
" primaryEmphasis" : " primaryHue.700" ,
93
91
" raised" : " palette.white" ,
94
92
" recessed" : " neutralHue.100" ,
Original file line number Diff line number Diff line change @@ -52,7 +52,6 @@ const colors = {
52
52
recessed : 'neutralHue.1200' ,
53
53
subtle : 'neutralHue.1000' ,
54
54
emphasis : 'neutralHue.600' ,
55
- primary : 'primaryHue.900' ,
56
55
success : 'successHue.1000' ,
57
56
warning : 'warningHue.1000' ,
58
57
danger : 'dangerHue.1000' ,
@@ -101,7 +100,6 @@ const colors = {
101
100
recessed : 'neutralHue.100' ,
102
101
subtle : 'neutralHue.100' ,
103
102
emphasis : 'neutralHue.700' ,
104
- primary : 'primaryHue.100' ,
105
103
success : 'successHue.100' ,
106
104
warning : 'warningHue.100' ,
107
105
danger : 'dangerHue.100' ,
You can’t perform that action at this time.
0 commit comments