Skip to content

Commit

Permalink
fix: apply primary button styles for icon button #2121
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Sep 13, 2023
1 parent 19021ae commit c5a93a2
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions ui/src/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ const
center: 'center',
between: 'space-between',
around: 'space-around',
},
iconButtonPrimaryStyles = {
root: { color: cssVar('$white'), background: cssVar('$themePrimary') },
rootHovered: { color: cssVar('$white'), background: cssVar('$themeDarkAlt') },
rootPressed: { color: cssVar('$white'), background: cssVar('$themePrimary') }
}

const
Expand Down Expand Up @@ -171,8 +176,22 @@ const
} : undefined,
split: !!commands,
}
if (isIconOnly) return <Fluent.IconButton {...btnProps} data-test={name} title={caption} />

if (isIconOnly) {
return <Fluent.IconButton
{...btnProps}
data-test={name}
title={caption}
// Fluent does not support primary icon buttons so we need to override the styles.
styles={primary
? {
...styles,
...iconButtonPrimaryStyles,
root: { ...(styles.root as any), ...iconButtonPrimaryStyles.root }
}
: undefined
}
/>
}
return caption?.length
? primary
? <Fluent.CompoundButton {...btnProps} data-test={name} primary secondaryText={caption} />
Expand Down

0 comments on commit c5a93a2

Please sign in to comment.