Skip to content

Commit

Permalink
feat(tooltip): make tooltip border color overridable
Browse files Browse the repository at this point in the history
  • Loading branch information
igera93 committed Nov 28, 2024
1 parent 304a29a commit e4a155f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/shared-types/src/ComponentThemeVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ export type TooltipTheme = {
fontWeight: Typography['fontWeightNormal']
fontSize: Typography['fontSizeSmall']
padding: Spacing['small']
borderColor: Colors['contrasts']['grey3045']
}

export type TopNavBarActionItemsTheme = {
Expand Down
1 change: 1 addition & 0 deletions packages/ui-tooltip/src/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class Tooltip extends Component<TooltipProps, TooltipState> {
elementRef={this.handleRef}
shouldCloseOnDocumentClick={false}
shouldCloseOnEscape
themeOverride={{ borderColor: styles?.borderColor as string }}
>
<span id={this._id} css={styles?.tooltip} role="tooltip">
{/* TODO: figure out how to add a ref to this */}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-tooltip/src/Tooltip/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ type TooltipProps = PropsPassableToPopover &
OtherHTMLAttributes<TooltipOwnProps> &
WithDeterministicIdProps

type TooltipStyle = ComponentStyle<'tooltip'>
type TooltipStyle = ComponentStyle<'tooltip' | 'borderColor'>

type TooltipState = {
hasFocus: boolean
Expand Down
3 changes: 2 additions & 1 deletion packages/ui-tooltip/src/Tooltip/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const generateStyle = (componentTheme: TooltipTheme): TooltipStyle => {
display: 'block',
fontSize: componentTheme.fontSize,
padding: componentTheme.padding
}
},
borderColor: componentTheme.borderColor
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/ui-tooltip/src/Tooltip/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ import { TooltipTheme } from '@instructure/shared-types'
* @return {Object} The final theme object with the overrides and component variables
*/
const generateComponentTheme = (theme: Theme): TooltipTheme => {
const { typography, spacing } = theme
const { typography, spacing, colors } = theme

const componentVariables: TooltipTheme = {
fontFamily: typography?.fontFamily,
fontWeight: typography?.fontWeightNormal,
fontSize: typography?.fontSizeSmall,
padding: spacing?.small
padding: spacing?.small,
borderColor: colors?.contrasts?.grey3045
}

return {
Expand Down

0 comments on commit e4a155f

Please sign in to comment.