|
| 1 | +import { css, cx } from "@emotion/css"; |
| 2 | + |
| 3 | +/** |
| 4 | + * DOM target for portaled PatternFly flyouts (Popover, Tooltip). |
| 5 | + * Uses `document.body` so flyouts inherit Red Hat Text from PatternFly base styles. |
| 6 | + * Appending to `document.documentElement` (where the theme class often lives) leaves |
| 7 | + * flyouts outside `body` and they fall back to the browser serif default. |
| 8 | + */ |
| 9 | +export const getFlyoutAppendTo = (): HTMLElement => document.body; |
| 10 | + |
| 11 | +/** Shared typography for portaled popover and tooltip content. */ |
| 12 | +export const flyoutTypographyClassName = css` |
| 13 | + .pf-v6-c-popover__content, |
| 14 | + .pf-v6-c-popover__title-text, |
| 15 | + .pf-v6-c-tooltip__content { |
| 16 | + font-family: var(--pf-t--global--font--family--body); |
| 17 | + line-height: var(--pf-t--global--font--line-height--body); |
| 18 | + } |
| 19 | +
|
| 20 | + .pf-v6-c-tooltip__content { |
| 21 | + font-size: var(--pf-t--global--font--size--body--sm); |
| 22 | + } |
| 23 | +`; |
| 24 | + |
| 25 | +/** Popover color tokens that respect the active PatternFly theme. */ |
| 26 | +export const themeAwarePopoverClassName = css` |
| 27 | + --pf-v6-c-popover__content--BackgroundColor: var( |
| 28 | + --pf-t--global--background--color--floating--default |
| 29 | + ); |
| 30 | + --pf-v6-c-popover__content--Color: var(--pf-t--global--text--color--regular); |
| 31 | + --pf-v6-c-popover__arrow--BackgroundColor: var( |
| 32 | + --pf-t--global--background--color--floating--default |
| 33 | + ); |
| 34 | + --pf-v6-c-popover__arrow--BorderColor: var( |
| 35 | + --pf-t--global--border--color--default |
| 36 | + ); |
| 37 | +`; |
| 38 | + |
| 39 | +/** Tooltip color tokens that respect the active PatternFly theme. */ |
| 40 | +export const themeAwareTooltipClassName = css` |
| 41 | + --pf-v6-c-tooltip__content--BackgroundColor: var( |
| 42 | + --pf-t--global--background--color--floating--default |
| 43 | + ); |
| 44 | + --pf-v6-c-tooltip__content--Color: var(--pf-t--global--text--color--regular); |
| 45 | + --pf-v6-c-tooltip__arrow--BackgroundColor: var( |
| 46 | + --pf-t--global--background--color--floating--default |
| 47 | + ); |
| 48 | + --pf-v6-c-tooltip__arrow--BorderColor: var( |
| 49 | + --pf-t--global--border--color--default |
| 50 | + ); |
| 51 | +`; |
| 52 | + |
| 53 | +/** Typography + theme tokens for popovers. */ |
| 54 | +export const themePopoverFlyoutClassName = cx( |
| 55 | + flyoutTypographyClassName, |
| 56 | + themeAwarePopoverClassName, |
| 57 | +); |
| 58 | + |
| 59 | +/** Typography + theme tokens for tooltips. */ |
| 60 | +export const themeTooltipFlyoutClassName = cx( |
| 61 | + flyoutTypographyClassName, |
| 62 | + themeAwareTooltipClassName, |
| 63 | +); |
| 64 | + |
| 65 | +/** Victory chart tooltips (Voronoi) that respect the active PatternFly theme. */ |
| 66 | +export const themedChartTooltipStyle = { |
| 67 | + fontSize: 9, |
| 68 | + fill: "var(--pf-t--global--text--color--regular)", |
| 69 | +} as const; |
| 70 | + |
| 71 | +export const themedChartTooltipFlyoutStyle = { |
| 72 | + stroke: "var(--pf-t--global--border--color--default)", |
| 73 | + strokeWidth: 1, |
| 74 | + fill: "var(--pf-t--global--background--color--floating--default)", |
| 75 | +} as const; |
| 76 | + |
| 77 | +export const themedChartTooltipFlyoutPadding = { |
| 78 | + top: 6, |
| 79 | + bottom: 6, |
| 80 | + left: 10, |
| 81 | + right: 10, |
| 82 | +} as const; |
| 83 | + |
| 84 | +/** Shared props for theme-aware PatternFly Popovers. */ |
| 85 | +export const themePopoverFlyoutProps = { |
| 86 | + appendTo: getFlyoutAppendTo, |
| 87 | + className: themePopoverFlyoutClassName, |
| 88 | +} as const; |
| 89 | + |
| 90 | +/** Shared props for theme-aware PatternFly Tooltips. */ |
| 91 | +export const themeTooltipFlyoutProps = { |
| 92 | + appendTo: getFlyoutAppendTo, |
| 93 | + className: themeTooltipFlyoutClassName, |
| 94 | +} as const; |
0 commit comments