File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
packages/avatars/src/styled Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 66 */
77
88import React from 'react' ;
9- import { render , renderRtl } from 'garden-test-utils' ;
9+ import { getRenderFn , render , renderRtl } from 'garden-test-utils' ;
1010import { DEFAULT_THEME , PALETTE } from '@zendeskgarden/react-theming' ;
1111
1212import { StyledAvatar } from './StyledAvatar' ;
@@ -32,6 +32,16 @@ describe('StyledAvatar', () => {
3232 } ) ;
3333
3434 describe ( 'color' , ( ) => {
35+ it . each ( [ 'light' , 'dark' ] ) ( 'renders default %s mode surface color as expected' , mode => {
36+ const { container } = getRenderFn ( mode ) ( < StyledAvatar $status = "away" /> ) ;
37+
38+ expect ( container . firstChild ) . toHaveStyleRule (
39+ 'color' ,
40+ mode === 'light' ? PALETTE . white : PALETTE . grey [ 1100 ] ,
41+ { modifier : '&&' }
42+ ) ;
43+ } ) ;
44+
3545 it ( 'renders surface color as expected' , ( ) => {
3646 const { container } = render ( < StyledAvatar $status = "away" $surfaceColor = "red" /> ) ;
3747
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ const colorStyles = ({
6565 const statusColor = getStatusColor ( theme , $status ) ;
6666 let backgroundColor = 'transparent' ;
6767 let foregroundColor = theme . palette . white ;
68- let surfaceColor = 'transparent' ;
68+ let surfaceColor ;
6969
7070 if ( $backgroundColor ) {
7171 backgroundColor = $backgroundColor . includes ( '.' )
@@ -79,10 +79,12 @@ const colorStyles = ({
7979 : $foregroundColor ;
8080 }
8181
82- if ( $surfaceColor ) {
83- surfaceColor = $surfaceColor . includes ( '.' )
84- ? getColor ( { theme, variable : $surfaceColor } )
85- : $surfaceColor ;
82+ if ( $status ) {
83+ surfaceColor = $surfaceColor ?. includes ( '.' )
84+ ? getColor ( { variable : $surfaceColor , theme } )
85+ : $surfaceColor || getColor ( { variable : 'background.default' , theme } ) ;
86+ } else {
87+ surfaceColor = $surfaceColor || 'transparent' ;
8688 }
8789
8890 return css `
You can’t perform that action at this time.
0 commit comments