Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tooltip): make tooltip border color overridable #1804

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading