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 55 * found at http://www.apache.org/licenses/LICENSE-2.0.
66 */
77
8+ import { useTheme } from 'styled-components' ;
89import React , { useCallback , useState } from 'react' ;
910import { StoryFn } from '@storybook/react' ;
1011import { Grid } from '@zendeskgarden/react-grid' ;
1112import { Menu , Item } from '@zendeskgarden/react-dropdowns' ;
1213import { Avatar , IAvatarProps } from '@zendeskgarden/react-avatars' ;
14+ import { getColor } from '@zendeskgarden/react-theming' ;
1315
1416const items : {
1517 value : string ;
@@ -49,6 +51,8 @@ export const MenuStory: StoryFn = ({ isCompact }) => {
4951 focusedValue !== undefined && setHighlightedValue ( focusedValue ) ;
5052 } , [ ] ) ;
5153
54+ const theme = useTheme ( ) ;
55+
5256 return (
5357 < Grid >
5458 < Grid . Row style = { { height : 'calc(100vh - 80px)' } } >
@@ -64,7 +68,14 @@ export const MenuStory: StoryFn = ({ isCompact }) => {
6468 status = { item . avatarProps . status }
6569 badge = { item . avatarProps . badge }
6670 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'
6879 }
6980 >
7081 < 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', () => {
5252
5353 it ( 'renders surface color variable key as expected' , ( ) => {
5454 const { container, rerender } = render (
55- < StyledAvatar $status = "away" $surfaceColor = "background.primary " />
55+ < StyledAvatar $status = "away" $surfaceColor = "background.primaryEmphasis " />
5656 ) ;
5757
58- expect ( container . firstChild ) . toHaveStyleRule ( 'color' , PALETTE . blue [ 100 ] , {
58+ expect ( container . firstChild ) . toHaveStyleRule ( 'color' , PALETTE . blue [ 700 ] , {
5959 modifier : '&&'
6060 } ) ;
6161
62- rerender ( < StyledAvatar $surfaceColor = "background.primary " /> ) ;
62+ rerender ( < StyledAvatar $surfaceColor = "background.primaryEmphasis " /> ) ;
6363
6464 expect ( container . firstChild ) . toHaveStyleRule ( 'color' , 'transparent' , {
6565 modifier : '&&'
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ export interface IAvatarProps extends HTMLAttributes<HTMLElement> {
2929 /**
3030 * Provides surface color for an avatar placed on a non-default background.
3131 * 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.
3333 */
3434 surfaceColor ?: string ;
3535 /** 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 {
2222const StyledDiv = styled . div < Omit < IArgs , 'isAnimated' > > `
2323 border: ${ p =>
2424 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 ' } ) } ` } ;
2626 box-shadow: ${ p =>
2727 p . hasBoxShadow &&
2828 p . theme . shadows . lg (
2929 `${ p . theme . space . base * ( p . theme . colors . base === 'dark' ? 4 : 5 ) } px` ,
3030 `${ p . theme . space . base * ( p . theme . colors . base === 'dark' ? 5 : 6 ) } px` ,
3131 getColor ( { variable : 'shadow.medium' , theme : p . theme } )
3232 ) } ;
33- background-color: ${ p => getColor ( { theme : p . theme , variable : 'background.primary ' } ) } ;
33+ background-color: ${ p => getColor ( { theme : p . theme , variable : 'background.subtle ' } ) } ;
3434 padding: ${ p => p . theme . space . xxl } ;
3535
3636 ${ p =>
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ exports[`DEFAULT_THEME matches snapshot 1`] = `
3939 " default" : " neutralHue.1100" ,
4040 " disabled" : " rgba(neutralHue.500, 100)" ,
4141 " emphasis" : " neutralHue.600" ,
42- " primary" : " primaryHue.900" ,
4342 " primaryEmphasis" : " primaryHue.600" ,
4443 " raised" : " neutralHue.1000" ,
4544 " recessed" : " neutralHue.1200" ,
@@ -88,7 +87,6 @@ exports[`DEFAULT_THEME matches snapshot 1`] = `
8887 " default" : " palette.white" ,
8988 " disabled" : " rgba(neutralHue.700, 100)" ,
9089 " emphasis" : " neutralHue.700" ,
91- " primary" : " primaryHue.100" ,
9290 " primaryEmphasis" : " primaryHue.700" ,
9391 " raised" : " palette.white" ,
9492 " recessed" : " neutralHue.100" ,
Original file line number Diff line number Diff line change @@ -52,7 +52,6 @@ const colors = {
5252 recessed : 'neutralHue.1200' ,
5353 subtle : 'neutralHue.1000' ,
5454 emphasis : 'neutralHue.600' ,
55- primary : 'primaryHue.900' ,
5655 success : 'successHue.1000' ,
5756 warning : 'warningHue.1000' ,
5857 danger : 'dangerHue.1000' ,
@@ -101,7 +100,6 @@ const colors = {
101100 recessed : 'neutralHue.100' ,
102101 subtle : 'neutralHue.100' ,
103102 emphasis : 'neutralHue.700' ,
104- primary : 'primaryHue.100' ,
105103 success : 'successHue.100' ,
106104 warning : 'warningHue.100' ,
107105 danger : 'dangerHue.100' ,
You can’t perform that action at this time.
0 commit comments