@red-hat-developer-hub/backstage-plugin-theme 1.0.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/config.schema.json +552 -0
- package/dist/assets/bui/component-overrides.css.esm.js +5 -0
- package/dist/assets/bui/component-overrides.css.esm.js.map +1 -0
- package/dist/assets/bui/tokens.css.esm.js +5 -0
- package/dist/assets/bui/tokens.css.esm.js.map +1 -0
- package/dist/components/ThemeProvider.esm.js +67 -12
- package/dist/components/ThemeProvider.esm.js.map +1 -1
- package/dist/index.esm.js +6 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/legacy.d.ts +25 -1
- package/dist/legacy.esm.js +3 -1
- package/dist/legacy.esm.js.map +1 -1
- package/dist/lightTheme.esm.js +9 -1
- package/dist/lightTheme.esm.js.map +1 -1
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js +1 -1
- package/dist/node_modules_dist/style-inject/dist/style-inject.es.esm.js.map +1 -1
- package/dist/themes.esm.js +37 -25
- package/dist/themes.esm.js.map +1 -1
- package/dist/utils/buiTokensToCSS.esm.js +27 -0
- package/dist/utils/buiTokensToCSS.esm.js.map +1 -0
- package/dist/utils/createComponents.esm.js +37 -0
- package/dist/utils/createComponents.esm.js.map +1 -1
- package/package.json +15 -15
- package/config.d.ts +0 -181
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import styleInject from '../../node_modules_dist/style-inject/dist/style-inject.es.esm.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = "body[data-theme-name='light'][data-theme-mode='light'],\nbody[data-theme-name='dark'][data-theme-mode='dark'],\nbody[data-theme-name='light-customized'][data-theme-mode='light'],\nbody[data-theme-name='dark-customized'][data-theme-mode='dark'] {\n /*\n * Override BUI tokens with PatternFly tokens. In this storybook and in ui-docs the fallback is always used.\n * These tokens are used here for documentation purposes to show how the BUI tokens map to PatternFly tokens.\n */\n\n /* Font families */\n --bui-font-regular: var(\n --pf-t--global--font--family--body,\n 'Red Hat Text',\n 'RedHatText',\n 'Noto Sans Arabic',\n 'Noto Sans Hebrew',\n 'Noto Sans JP',\n 'Noto Sans KR',\n 'Noto Sans Malayalam',\n 'Noto Sans SC',\n 'Noto Sans TC',\n 'Noto Sans Thai',\n Helvetica,\n Arial,\n sans-serif\n );\n /* This `--bui-redhat-` prefixed variable does NOT exist in BUI but is used only in this theme by some components below */\n --bui-redhat-theme-font-heading: var(\n --pf-t--global--font--family--heading,\n 'Red Hat Display',\n 'RedHatDisplay',\n 'Noto Sans Arabic',\n 'Noto Sans Hebrew',\n 'Noto Sans JP',\n 'Noto Sans KR',\n 'Noto Sans Malayalam',\n 'Noto Sans SC',\n 'Noto Sans TC',\n 'Noto Sans Thai',\n Helvetica,\n Arial,\n sans-serif\n );\n --bui-font-monospace: var(\n --pf-t--global--font--family--mono,\n 'Red Hat Mono',\n 'RedHatMono',\n 'Courier New',\n Courier,\n monospace\n );\n\n /* Font weights */\n --bui-font-weight-regular: var(\n --pf-t--global--font--weight--body--default,\n 400\n );\n --bui-font-weight-bold: var(--pf-t--global--font--weight--body--bold, 600);\n /* This `--bui-redhat-` prefixed variable does NOT exist in BUI but is used only in this theme by some components below */\n --bui-redhat-theme-font-weight-heading-regular: var(\n --pf-t--global--font--weight--heading--default,\n 400\n );\n /* This `--bui-redhat-` prefixed variable does NOT exist in BUI but is used only in this theme by some components below */\n --bui-redhat-theme-font-weight-heading-bold: var(\n --pf-t--global--font--weight--heading--bold,\n 600\n );\n\n /*\n * Font sizes are mostly similar between BUI and this theme. We used a slightly bigger font size.\n *\n * BUI \"Body Medium\" = --bui-font-size-3 is 0.875rem but we aligned with --pf-t--global--font--size--md which is 1rem.\n *\n * TODO: Check line height.\n */\n --bui-font-size-1: var(\n --pf-t--global--font--size--xs,\n 0.75rem\n ); /* BUI default 0.625rem = 10px */\n --bui-font-size-2: var(\n --pf-t--global--font--size--sm,\n 0.875rem\n ); /* BUI default 0.75rem = 12px */\n --bui-font-size-3: var(\n --pf-t--global--font--size--md,\n 14px /*1rem*/\n ); /* BUI default 0.875rem = 14px */\n --bui-font-size-4: var(\n --pf-t--global--font--size--lg,\n 1.125rem\n ); /* BUI default 1rem = 16px */\n --bui-font-size-5: var(\n --pf-t--global--font--size--xl,\n 1.25rem\n ); /* BUI default 1.25rem = 20px */\n --bui-font-size-6: var(\n --pf-t--global--font--size--2xl,\n 1.5rem\n ); /* BUI default 1.5rem = 24px */\n --bui-font-size-7: var(\n --pf-t--global--font--size--3xl,\n 1.75rem\n ); /* BUI default 2rem = 32px */\n --bui-font-size-8: var(\n --pf-t--global--font--size--4xl,\n 2.25rem\n ); /* BUI default 3rem = 48px */\n --bui-font-size-9: var(\n --pf-t--global--font--size--5xl,\n 3rem\n ); /* BUI default 4rem = 64px */\n --bui-font-size-10: var(\n --pf-t--global--font--size--6xl,\n 4rem\n ); /* BUI default 5.75rem = 92px */\n\n /*\n * Spacing\n *\n * Use default BUI spacing tokens because they are matching mostly the PatternFly tokens.\n *\n * For example `--bui-space: 0.25rem` is same as `pf-t--global--spacer--xs: 0.25rem`\n */\n\n /*\n * Radius\n *\n * While BUI has 6 radius tokens and a `full` token, PatternFly has just 4 radius tokens and a `sharp` (0px) and a `pill` token.\n * We mapped the BUI tokens to the closest PatternFly tokens and used custom values in the middle between `small` and `medium`\n * so that BUI component users can still expect different radius options.\n *\n * The `full` token is mapped to the `pill` token in PatternFly but we kept 9999px instead of 999px from PF.\n */\n --bui-radius-1: var(\n --pf-t--global--border--radius--tiny,\n 4px\n ); /* default: 0.125rem */\n --bui-radius-2: var(\n --pf-t--global--border--radius--small,\n 6px\n ); /* default: 0.25rem */\n --bui-radius-3: 8px; /* default: 0.5rem */\n --bui-radius-4: 12px; /* default: 0.75rem */\n --bui-radius-5: var(\n --pf-t--global--border--radius--medium,\n 16px\n ); /* default: 1rem */\n --bui-radius-6: var(\n --pf-t--global--border--radius--large,\n 24px\n ); /* default: 1.25rem */\n --bui-radius-full: var(\n --pf-t--global--border--radius--pill,\n 9999px\n ); /* default: 9999px */\n}\n\nbody[data-theme-name='light'][data-theme-mode='light'],\nbody[data-theme-name='light-customized'][data-theme-mode='light'] {\n /* Base Colors */\n --bui-black: #151515;\n --bui-white: #ffffff;\n\n /* Solid background colors */\n --bui-bg-solid: var(--pf-t--global--icon--color--brand--default, #0066cc);\n --bui-bg-solid-hover: var(--pf-t--global--icon--color--brand--hover, #004d99);\n --bui-bg-solid-pressed: var(\n --pf-t--global--icon--color--brand--clicked,\n #004d99\n );\n --bui-bg-solid-disabled: var(\n --pf-t--global--background--color--disabled--default,\n #c7c7c7\n );\n\n /* Neutral background colors */\n /* --bui-bg-app: #f8f8f8; */\n\n --bui-bg-neutral-1: #fff;\n --bui-bg-neutral-1-hover: oklch(0% 0 0 / 6%);\n --bui-bg-neutral-1-pressed: oklch(0% 0 0 / 12%);\n --bui-bg-neutral-1-disabled: oklch(0% 0 0 / 6%);\n\n --bui-bg-neutral-2: oklch(0% 0 0 / 6%);\n --bui-bg-neutral-2-hover: oklch(0% 0 0 / 12%);\n --bui-bg-neutral-2-pressed: oklch(0% 0 0 / 16%);\n --bui-bg-neutral-2-disabled: oklch(0% 0 0 / 6%);\n\n --bui-bg-neutral-3: oklch(0% 0 0 / 6%);\n --bui-bg-neutral-3-hover: oklch(0% 0 0 / 12%);\n --bui-bg-neutral-3-pressed: oklch(0% 0 0 / 16%);\n --bui-bg-neutral-3-disabled: oklch(0% 0 0 / 6%);\n\n --bui-bg-neutral-4: oklch(0% 0 0 / 6%);\n --bui-bg-neutral-4-hover: oklch(0% 0 0 / 12%);\n --bui-bg-neutral-4-pressed: oklch(0% 0 0 / 16%);\n --bui-bg-neutral-4-disabled: oklch(0% 0 0 / 6%);\n\n /* Status background colors */\n --bui-bg-danger: #ffe2e2;\n --bui-bg-warning: #ffedd5;\n --bui-bg-success: #dcfce7;\n --bui-bg-info: #dbeafe;\n\n /* Foreground colors */\n --bui-fg-primary: var(--bui-black);\n --bui-fg-secondary: var(\n --pf-t--global--text--color--subtle,\n #4d4d4d\n ); /* PF gray-60 */\n --bui-fg-disabled: var(\n --pf-t--global--text--color--disabled,\n #a3a3a3\n ); /* PF gray-40 */\n --bui-fg-solid: var(--bui-white);\n --bui-fg-solid-disabled: var(\n --pf-t--global--text--color--on-disabled,\n #707070\n ); /* PF gray-50 */\n\n /* Foreground Statuses — used as icon/border accent on status backgrounds */\n --bui-fg-danger-on-bg: var(\n --pf-t--global--color--status--danger--default,\n #b1380b\n ); /* PF red-orange-60 */\n --bui-fg-warning-on-bg: var(\n --pf-t--global--color--status--warning--default,\n #dca614\n ); /* PF yellow-40 */\n --bui-fg-success-on-bg: var(\n --pf-t--global--color--status--success--default,\n #3d7317\n ); /* PF green-60 */\n --bui-fg-info-on-bg: var(\n --pf-t--global--color--status--info--default,\n #5e40be\n ); /* PF purple-50 */\n --bui-fg-danger: var(\n --pf-t--global--color--status--danger--default,\n #b1380b\n ); /* PF red-orange-60 */\n --bui-fg-warning: var(\n --pf-t--global--color--status--warning--default,\n #dca614\n ); /* PF yellow-40 */\n --bui-fg-success: var(\n --pf-t--global--color--status--success--default,\n #3d7317\n ); /* PF green-60 */\n --bui-fg-info: var(\n --pf-t--global--color--status--info--default,\n #5e40be\n ); /* PF purple-50 */\n\n /* Border colors */\n --bui-border-1: var(\n --pf-t--global--border--color--default,\n #c7c7c7\n ); /* PF gray-30 */\n --bui-border-2: var(\n --pf-t--global--border--color--control--default,\n #a3a3a3\n ); /* PF gray-40 */\n --bui-border-info: var(\n --pf-t--global--border--color--status--info--default,\n #5e40be\n ); /* PF purple-50 */\n --bui-border-danger: var(\n --pf-t--global--border--color--status--danger--default,\n #b1380b\n ); /* PF red-orange-60 */\n --bui-border-warning: var(\n --pf-t--global--border--color--status--warning--default,\n #dca614\n ); /* PF yellow-40 */\n --bui-border-success: var(\n --pf-t--global--border--color--status--success--default,\n #3d7317\n ); /* PF green-60 */\n\n /* Accent colors (used by Switch and other interactive components) */\n --bui-accent-bg: var(--bui-bg-solid);\n --bui-accent-bg-hover: var(--bui-bg-solid-hover);\n --bui-accent-bg-disabled: var(--bui-bg-solid-disabled);\n --bui-accent-fg: var(--bui-fg-solid);\n --bui-accent-fg-disabled: var(--bui-fg-solid-disabled);\n\n /*\n * Brand accent for tab/nav indicators — separate from the button brand.\n * Defaults to the brand color; felt variants override to red.\n */\n --bui-redhat-theme-brand-accent: var(--bui-bg-solid);\n\n /* Readonly form control colors — PF gray-10 bg, gray-30 border */\n --bui-redhat-theme-readonly-bg: #f2f2f2;\n --bui-redhat-theme-readonly-border: #c7c7c7;\n\n /* Primary background — PF background-color-primary-default */\n --bui-redhat-theme-bg-primary: #ffffff; /* PF white */\n\n /* Floating background — PF background-color-floating-default (menus, popovers) */\n --bui-redhat-theme-bg-floating: #ffffff; /* PF white */\n\n /* Page inset — the shell background behind the rounded content well */\n --bui-redhat-theme-page-inset: 1.5rem;\n --bui-redhat-theme-page-inset-bg: #f2f2f2;\n\n /* Brand subtle — used by ToggleButton selected/hover states */\n --bui-redhat-theme-brand-subtle: #e0f0ff; /* PF blue-10 */\n --bui-redhat-theme-brand-subtle-hover: #b9dafc; /* PF blue-20 */\n --bui-redhat-theme-brand-subtle-border: #4394e5; /* PF blue-40 */\n\n /* Special colors */\n --bui-ring: var(--bui-bg-solid);\n --bui-scrollbar: #a0a0a03b;\n --bui-scrollbar-thumb: #a0a0a0;\n\n /* Shadows */\n --bui-shadow: rgba(41, 41, 41, 0.15) 0px 10px 20px 0px;\n\n --bui-animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n\nbody[data-theme-name='dark'][data-theme-mode='dark'],\nbody[data-theme-name='dark-customized'][data-theme-mode='dark'] {\n /* Base Colors */\n --bui-black: #151515;\n --bui-white: #ffffff;\n\n /* Solid background colors — dark brand uses lighter blue for contrast on dark bg */\n --bui-bg-solid: var(\n --pf-t--global--icon--color--brand--default,\n #92c5f9\n ); /* PF dark brand = blue-30 */\n --bui-bg-solid-hover: var(\n --pf-t--global--icon--color--brand--hover,\n #b9dafc\n ); /* PF dark = blue-20 */\n --bui-bg-solid-pressed: var(\n --pf-t--global--icon--color--brand--clicked,\n #b9dafc\n );\n --bui-bg-solid-disabled: var(\n --pf-t--global--background--color--disabled--default,\n #a3a3a3\n ); /* PF dark gray-40 */\n\n /* Neutral background colors */\n --bui-bg-neutral-1: oklch(100% 0 0 / 10%);\n --bui-bg-neutral-1-hover: oklch(100% 0 0 / 14%);\n --bui-bg-neutral-1-pressed: oklch(100% 0 0 / 20%);\n --bui-bg-neutral-1-disabled: oklch(100% 0 0 / 10%);\n\n --bui-bg-neutral-2: oklch(100% 0 0 / 6%);\n --bui-bg-neutral-2-hover: oklch(100% 0 0 / 10%);\n --bui-bg-neutral-2-pressed: oklch(100% 0 0 / 16%);\n --bui-bg-neutral-2-disabled: oklch(100% 0 0 / 6%);\n\n --bui-bg-neutral-3: oklch(100% 0 0 / 8%);\n --bui-bg-neutral-3-hover: oklch(100% 0 0 / 12%);\n --bui-bg-neutral-3-pressed: oklch(100% 0 0 / 20%);\n --bui-bg-neutral-3-disabled: oklch(100% 0 0 / 8%);\n\n --bui-bg-neutral-4: oklch(100% 0 0 / 8%);\n --bui-bg-neutral-4-hover: oklch(100% 0 0 / 12%);\n --bui-bg-neutral-4-pressed: oklch(100% 0 0 / 20%);\n --bui-bg-neutral-4-disabled: oklch(100% 0 0 / 8%);\n\n /* Status background colors — BUI uses tinted backgrounds for alerts */\n --bui-bg-danger: #ffe2e2;\n --bui-bg-warning: #ffedd5;\n --bui-bg-success: #dcfce7;\n --bui-bg-info: #dbeafe;\n\n /* Foreground colors */\n --bui-fg-primary: var(--bui-white);\n --bui-fg-secondary: var(\n --pf-t--global--text--color--subtle,\n #c7c7c7\n ); /* PF dark = gray-30 */\n --bui-fg-disabled: var(\n --pf-t--global--text--color--disabled,\n #707070\n ); /* PF dark = gray-50 */\n --bui-fg-solid: #151515;\n --bui-fg-solid-disabled: var(\n --pf-t--global--text--color--on-disabled,\n #383838\n ); /* PF dark = gray-70 */\n\n /* Foreground Statuses — dark mode uses lighter status colors for contrast */\n --bui-fg-danger-on-bg: var(\n --pf-t--global--color--status--danger--default,\n #f0561d\n ); /* PF dark = red-orange-50 */\n --bui-fg-warning-on-bg: var(\n --pf-t--global--color--status--warning--default,\n #ffcc17\n ); /* PF dark = yellow-30 */\n --bui-fg-success-on-bg: var(\n --pf-t--global--color--status--success--default,\n #87bb62\n ); /* PF dark = green-40 */\n --bui-fg-info-on-bg: var(\n --pf-t--global--color--status--info--default,\n #b6a6e9\n ); /* PF dark = purple-30 */\n --bui-fg-danger: var(\n --pf-t--global--color--status--danger--default,\n #f0561d\n ); /* PF dark = red-orange-50 */\n --bui-fg-warning: var(\n --pf-t--global--color--status--warning--default,\n #ffcc17\n ); /* PF dark = yellow-30 */\n --bui-fg-success: var(\n --pf-t--global--color--status--success--default,\n #87bb62\n ); /* PF dark = green-40 */\n --bui-fg-info: var(\n --pf-t--global--color--status--info--default,\n #b6a6e9\n ); /* PF dark = purple-30 */\n\n /* Border colors */\n --bui-border-1: var(\n --pf-t--global--border--color--default,\n #4d4d4d\n ); /* PF dark = gray-60 */\n --bui-border-2: var(\n --pf-t--global--border--color--control--default,\n #a3a3a3\n ); /* PF dark = gray-40 */\n --bui-border-info: var(\n --pf-t--global--border--color--status--info--default,\n #b6a6e9\n ); /* PF dark = purple-30 */\n --bui-border-danger: var(\n --pf-t--global--border--color--status--danger--default,\n #f0561d\n ); /* PF dark = red-orange-50 */\n --bui-border-warning: var(\n --pf-t--global--border--color--status--warning--default,\n #ffcc17\n ); /* PF dark = yellow-30 */\n --bui-border-success: var(\n --pf-t--global--border--color--status--success--default,\n #87bb62\n ); /* PF dark = green-40 */\n\n /* Accent colors (used by Switch and other interactive components) */\n --bui-accent-bg: var(--bui-bg-solid);\n --bui-accent-bg-hover: var(--bui-bg-solid-hover);\n --bui-accent-bg-disabled: var(--bui-bg-solid-disabled);\n --bui-accent-fg: var(--bui-fg-solid);\n --bui-accent-fg-disabled: var(--bui-fg-solid-disabled);\n\n --bui-redhat-theme-brand-accent: var(--bui-bg-solid);\n\n /* Readonly form control colors — PF dark: gray-80 bg, gray-60 border */\n --bui-redhat-theme-readonly-bg: #292929;\n --bui-redhat-theme-readonly-border: #4d4d4d;\n\n /* Primary background — PF dark: gray-80 */\n --bui-redhat-theme-bg-primary: #292929;\n\n /* Floating background — PF dark: gray-70 */\n --bui-redhat-theme-bg-floating: #383838;\n\n /* Page inset — dark shell background */\n --bui-redhat-theme-page-inset: 1.5rem;\n --bui-redhat-theme-page-inset-bg: #151515;\n\n /* Brand subtle — PF dark: blue-70, blue-60, blue-30 */\n --bui-redhat-theme-brand-subtle: #003366; /* PF blue-70 */\n --bui-redhat-theme-brand-subtle-hover: #004d99; /* PF blue-60 */\n --bui-redhat-theme-brand-subtle-border: #92c5f9; /* PF blue-30 */\n\n /* Special colors */\n --bui-ring: var(--bui-bg-solid);\n --bui-scrollbar: #a0a0a03b;\n --bui-scrollbar-thumb: #a0a0a0;\n\n /* Shadows */\n --bui-shadow: rgba(0, 0, 0, 0.5) 0px 10px 20px 0px;\n\n --bui-animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n}\n\n/*\n * Felt theme overrides for the customized variants.\n */\nbody[data-theme-name='light-customized'][data-theme-mode='light'] {\n /* Brand accent → red (buttons stay blue via --bui-bg-solid) */\n --bui-redhat-theme-brand-accent: #ee0000;\n}\n\nbody[data-theme-name='dark-customized'][data-theme-mode='dark'] {\n /* Brand accent → red */\n --bui-redhat-theme-brand-accent: #ee0000;\n}\n";
|
|
4
|
+
styleInject(css_248z);
|
|
5
|
+
//# sourceMappingURL=tokens.css.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.css.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,25 +1,80 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useApi, appThemeApiRef } from '@backstage/core-plugin-api';
|
|
2
4
|
import { UnifiedThemeProvider } from '@backstage/theme';
|
|
3
5
|
import { StyledEngineProvider, ThemeProvider as ThemeProvider$1 } from '@mui/material/styles';
|
|
6
|
+
import GlobalStyles from '@mui/material/GlobalStyles';
|
|
4
7
|
import { useTheme } from '../hooks/useTheme.esm.js';
|
|
5
8
|
import { useThemeConfig } from '../hooks/useThemeConfig.esm.js';
|
|
9
|
+
import { useBranding } from '../hooks/useBranding.esm.js';
|
|
10
|
+
import { buiTokensToCSS } from '../utils/buiTokensToCSS.esm.js';
|
|
6
11
|
|
|
7
12
|
const ThemeProvider = ({
|
|
13
|
+
themeName,
|
|
8
14
|
theme,
|
|
9
15
|
children
|
|
10
|
-
}) =>
|
|
11
|
-
const
|
|
12
|
-
|
|
16
|
+
}) => {
|
|
17
|
+
const branding = useBranding();
|
|
18
|
+
const mui5Theme = theme.getTheme("v5");
|
|
19
|
+
const secondary = mui5Theme.palette.text.secondary;
|
|
20
|
+
const buiTokenStyles = useMemo(() => {
|
|
21
|
+
const themes = branding?.theme;
|
|
22
|
+
if (!themes) return null;
|
|
23
|
+
const styles = {};
|
|
24
|
+
for (const [themeName2, themeConfig] of Object.entries(themes)) {
|
|
25
|
+
const tokens = themeConfig?.bui?.tokens;
|
|
26
|
+
if (!tokens) continue;
|
|
27
|
+
const cssMap = buiTokensToCSS(tokens);
|
|
28
|
+
if (Object.keys(cssMap).length === 0) continue;
|
|
29
|
+
const mode = themeConfig.mode ?? (themeName2.includes("dark") ? "dark" : "light");
|
|
30
|
+
styles[`[data-theme-mode='${mode}']`] = {
|
|
31
|
+
...styles[`[data-theme-mode='${mode}']`],
|
|
32
|
+
...cssMap
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return Object.keys(styles).length > 0 ? styles : null;
|
|
36
|
+
}, [branding?.theme]);
|
|
37
|
+
const customCSS = branding?.customCSS ?? "";
|
|
38
|
+
return /* @__PURE__ */ jsx(UnifiedThemeProvider, { themeName, theme, children: /* @__PURE__ */ jsx(StyledEngineProvider, { injectFirst: true, children: /* @__PURE__ */ jsxs(ThemeProvider$1, { theme: mui5Theme, children: [
|
|
39
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
40
|
+
:root, [data-theme-mode='light'], [data-theme-mode='dark'] {
|
|
41
|
+
--bui-fg-secondary: ${secondary} !important;
|
|
42
|
+
}
|
|
43
|
+
` }),
|
|
44
|
+
buiTokenStyles && /* @__PURE__ */ jsx(GlobalStyles, { styles: buiTokenStyles }),
|
|
45
|
+
customCSS && /* @__PURE__ */ jsx("style", { children: customCSS }),
|
|
46
|
+
children
|
|
47
|
+
] }) }) });
|
|
13
48
|
};
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
49
|
+
const resolveActiveKey = (activeId, keys) => {
|
|
50
|
+
if (activeId && keys.includes(activeId)) {
|
|
51
|
+
return activeId;
|
|
52
|
+
}
|
|
53
|
+
const prefersDark = activeId ? activeId.includes("dark") : window.matchMedia?.("(prefers-color-scheme: dark)")?.matches;
|
|
54
|
+
return prefersDark ? keys.find((n) => n.includes("dark")) ?? keys[0] : keys.find((n) => !n.includes("dark")) ?? keys[0];
|
|
17
55
|
};
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
56
|
+
const useActiveThemeId = () => {
|
|
57
|
+
let appThemeApi;
|
|
58
|
+
try {
|
|
59
|
+
appThemeApi = useApi(appThemeApiRef);
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
return appThemeApi?.getActiveThemeId();
|
|
63
|
+
};
|
|
64
|
+
const createSharedThemeProvider = (entries) => {
|
|
65
|
+
const keys = Object.keys(entries);
|
|
66
|
+
function RHDHSharedThemeProvider({ children }) {
|
|
67
|
+
const activeId = useActiveThemeId();
|
|
68
|
+
const key = resolveActiveKey(activeId, keys);
|
|
69
|
+
const entry = entries[key];
|
|
70
|
+
const configFromName = useThemeConfig(entry.name ?? key);
|
|
71
|
+
const resolvedConfig = entry.config ?? configFromName;
|
|
72
|
+
const themeFromHook = useTheme(resolvedConfig);
|
|
73
|
+
const theme = entry.theme ?? themeFromHook;
|
|
74
|
+
return /* @__PURE__ */ jsx(ThemeProvider, { theme, themeName: entry.name ?? key, children });
|
|
75
|
+
}
|
|
76
|
+
return RHDHSharedThemeProvider;
|
|
22
77
|
};
|
|
23
78
|
|
|
24
|
-
export {
|
|
79
|
+
export { createSharedThemeProvider };
|
|
25
80
|
//# sourceMappingURL=ThemeProvider.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.esm.js","sources":["../../src/components/ThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type
|
|
1
|
+
{"version":3,"file":"ThemeProvider.esm.js","sources":["../../src/components/ThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type ReactNode, useMemo } from 'react';\nimport {\n type AppTheme,\n appThemeApiRef,\n type AppThemeApi,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { UnifiedTheme, UnifiedThemeProvider } from '@backstage/theme';\n\nimport {\n StyledEngineProvider,\n ThemeProvider as Mui5Provider,\n Theme as Mui5Theme,\n} from '@mui/material/styles';\nimport GlobalStyles from '@mui/material/GlobalStyles';\n\nimport { useTheme } from '../hooks/useTheme';\nimport { useThemeConfig } from '../hooks/useThemeConfig';\nimport { useBranding } from '../hooks/useBranding';\nimport { buiTokensToCSS } from '../utils/buiTokensToCSS';\nimport { ThemeConfig } from '../types';\n\n/**\n * Uses the UnifiedThemeProvider to style MUI v4 and v5 components.\n *\n * This component duplicated the StyledEngineProvider and MUI v5 ThemeProvider\n * to solve an issue that the defaultProps from the component configurations\n * (see `utils/createComponents.ts`) wasn't picked up.\n *\n * https://github.com/backstage/backstage/blob/master/packages/theme/src/unified/UnifiedThemeProvider.tsx#L94-L100\n */\nconst ThemeProvider = ({\n themeName,\n theme,\n children,\n}: {\n themeName: string;\n theme: UnifiedTheme;\n children: ReactNode;\n}) => {\n const branding = useBranding();\n const mui5Theme = theme.getTheme('v5') as Mui5Theme;\n const secondary = mui5Theme.palette.text.secondary;\n\n const buiTokenStyles = useMemo(() => {\n const themes = branding?.theme;\n if (!themes) return null;\n const styles: Record<string, Record<string, string>> = {};\n for (const [themeName, themeConfig] of Object.entries(themes)) {\n const tokens = themeConfig?.bui?.tokens;\n if (!tokens) continue;\n const cssMap = buiTokensToCSS(tokens);\n if (Object.keys(cssMap).length === 0) continue;\n const mode =\n themeConfig.mode ?? (themeName.includes('dark') ? 'dark' : 'light');\n styles[`[data-theme-mode='${mode}']`] = {\n ...styles[`[data-theme-mode='${mode}']`],\n ...cssMap,\n };\n }\n return Object.keys(styles).length > 0 ? styles : null;\n }, [branding?.theme]);\n\n const customCSS = branding?.customCSS ?? '';\n\n return (\n <UnifiedThemeProvider themeName={themeName} theme={theme}>\n <StyledEngineProvider injectFirst>\n <Mui5Provider theme={mui5Theme}>\n {/*\n Native style tag (not Emotion) so the declaration is unlayered and\n reliably overrides @backstage/ui @layer tokens for --bui-fg-secondary.\n */}\n <style>{`\n :root, [data-theme-mode='light'], [data-theme-mode='dark'] {\n --bui-fg-secondary: ${secondary} !important;\n }\n `}</style>\n {buiTokenStyles && <GlobalStyles styles={buiTokenStyles} />}\n {customCSS && <style>{customCSS}</style>}\n {children}\n </Mui5Provider>\n </StyledEngineProvider>\n </UnifiedThemeProvider>\n );\n};\n\nexport const createThemeProvider = (\n themeName: string,\n theme: UnifiedTheme,\n): AppTheme['Provider'] =>\n function RHDHThemeProvider({ children }) {\n return (\n <ThemeProvider themeName={themeName} theme={theme}>\n {children}\n </ThemeProvider>\n );\n };\n\nexport const createThemeProviderForThemeConfig = (\n themeName: string,\n themeConfig: ThemeConfig,\n): AppTheme['Provider'] =>\n function RHDHThemeProviderForThemeConfig({ children }) {\n const theme = useTheme(themeConfig);\n return (\n <ThemeProvider themeName={themeName} theme={theme}>\n {children}\n </ThemeProvider>\n );\n };\n\nexport const createThemeProviderForThemeName = (\n themeName: string,\n themeNameForConfig = themeName,\n): AppTheme['Provider'] =>\n function RHDHThemeProviderForThemeName({ children }) {\n const themeConfig = useThemeConfig(themeNameForConfig);\n const theme = useTheme(themeConfig);\n return (\n <ThemeProvider themeName={themeName} theme={theme}>\n {children}\n </ThemeProvider>\n );\n };\n\nconst resolveActiveKey = (\n activeId: string | undefined,\n keys: string[],\n): string => {\n if (activeId && keys.includes(activeId)) {\n return activeId;\n }\n const prefersDark = activeId\n ? activeId.includes('dark')\n : window.matchMedia?.('(prefers-color-scheme: dark)')?.matches;\n return prefersDark\n ? (keys.find(n => n.includes('dark')) ?? keys[0])\n : (keys.find(n => !n.includes('dark')) ?? keys[0]);\n};\n\nconst useActiveThemeId = (): string | undefined => {\n let appThemeApi: AppThemeApi | undefined;\n try {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n appThemeApi = useApi<AppThemeApi>(appThemeApiRef); // NOSONAR\n } catch {\n // appThemeApi may not be available during createApp initialization\n }\n return appThemeApi?.getActiveThemeId();\n};\n\nexport type SharedThemeEntry = {\n name?: string;\n config?: ThemeConfig;\n theme?: UnifiedTheme;\n};\n\nexport const createSharedThemeProvider = (\n entries: Record<string, SharedThemeEntry>,\n): AppTheme['Provider'] => {\n const keys = Object.keys(entries);\n\n function RHDHSharedThemeProvider({ children }: { children: ReactNode }) {\n const activeId = useActiveThemeId();\n const key = resolveActiveKey(activeId, keys);\n const entry = entries[key];\n\n // Always call hooks unconditionally (Rules of Hooks).\n // For entries that don't need them the results are simply unused.\n const configFromName = useThemeConfig(entry.name ?? key);\n const resolvedConfig = entry.config ?? configFromName;\n const themeFromHook = useTheme(resolvedConfig);\n\n const theme = entry.theme ?? themeFromHook;\n return (\n <ThemeProvider theme={theme} themeName={entry.name ?? key}>\n {children}\n </ThemeProvider>\n );\n }\n return RHDHSharedThemeProvider;\n};\n"],"names":["themeName","Mui5Provider"],"mappings":";;;;;;;;;;;AA+CA,MAAM,gBAAgB,CAAC;AAAA,EACrB,SAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,KAIM;AACJ,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,SAAA,GAAY,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA;AACrC,EAAA,MAAM,SAAA,GAAY,SAAA,CAAU,OAAA,CAAQ,IAAA,CAAK,SAAA;AAEzC,EAAA,MAAM,cAAA,GAAiB,QAAQ,MAAM;AACnC,IAAA,MAAM,SAAS,QAAA,EAAU,KAAA;AACzB,IAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AACpB,IAAA,MAAM,SAAiD,EAAC;AACxD,IAAA,KAAA,MAAW,CAACA,UAAAA,EAAW,WAAW,KAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AAC7D,MAAA,MAAM,MAAA,GAAS,aAAa,GAAA,EAAK,MAAA;AACjC,MAAA,IAAI,CAAC,MAAA,EAAQ;AACb,MA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SAAS,cAAc,CAAA;AAE7C,IAAA,MAAM,KAAA,GAAQ,MAAM,KAAA,IAAS,aAAA;AAC7B,IAAA,2BACG,aAAA,EAAA,EAAc,KAAA,EAAc,WAAW,KAAA,CAAM,IAAA,IAAQ,KACnD,QAAA,EACH,CAAA;AAAA,EAEJ;AACA,EAAA,OAAO,uBAAA;AACT;;;;"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { createFrontendModule } from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { ThemeBlueprint } from '@backstage/plugin-app-react';
|
|
3
|
-
import './assets/fonts/font.min.css.esm.js';
|
|
4
3
|
import { getAllThemes } from './themes.esm.js';
|
|
4
|
+
import './assets/fonts/font.min.css.esm.js';
|
|
5
|
+
import './assets/bui/tokens.css.esm.js';
|
|
6
|
+
import './assets/bui/component-overrides.css.esm.js';
|
|
5
7
|
export { LogoFull } from './components/LogoFull.esm.js';
|
|
6
8
|
export { LogoIcon } from './components/LogoIcon.esm.js';
|
|
7
9
|
import 'react/jsx-runtime';
|
|
8
|
-
import '@backstage/theme';
|
|
9
|
-
import '@mui/material/styles';
|
|
10
10
|
import 'react';
|
|
11
11
|
import '@backstage/core-plugin-api';
|
|
12
|
+
import '@backstage/theme';
|
|
13
|
+
import '@mui/material/styles';
|
|
14
|
+
import '@mui/material/GlobalStyles';
|
|
12
15
|
|
|
13
16
|
const rhdhThemeModule = createFrontendModule({
|
|
14
17
|
pluginId: "app",
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * RHDH Theme plugin for Backstage.\n * @packageDocumentation\n */\n\nimport { createFrontendModule } from '@backstage/frontend-plugin-api';\nimport { ThemeBlueprint } from '@backstage/plugin-app-react';\n\nimport './assets/fonts/font.min.css';\nimport
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * RHDH Theme plugin for Backstage.\n * @packageDocumentation\n */\n\nimport { createFrontendModule } from '@backstage/frontend-plugin-api';\nimport { ThemeBlueprint } from '@backstage/plugin-app-react';\n\nimport { getAllThemes } from './themes';\n\nimport './assets/fonts/font.min.css';\nimport './assets/bui/tokens.css';\nimport './assets/bui/component-overrides.css';\n\nexport { LogoFull, LogoIcon } from './components';\n\n/**\n * RHDH themes as NFS extensions (ThemeBlueprint).\n * Only the app can register ThemeBlueprint; we use the same theme definitions\n * from the theme plugin (getAllThemes()) so behavior matches the legacy app.\n *\n * @public\n */\nconst rhdhThemeModule = createFrontendModule({\n pluginId: 'app',\n extensions: getAllThemes().map(appTheme =>\n ThemeBlueprint.make({\n name: appTheme.id,\n params: {\n theme: {\n id: appTheme.id,\n title: appTheme.title,\n variant: appTheme.variant,\n icon: appTheme.icon,\n Provider: appTheme.Provider,\n },\n },\n }),\n ),\n});\n\nexport default rhdhThemeModule;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAM,kBAAkB,oBAAA,CAAqB;AAAA,EAC3C,QAAA,EAAU,KAAA;AAAA,EACV,UAAA,EAAY,cAAa,CAAE,GAAA;AAAA,IAAI,CAAA,QAAA,KAC7B,eAAe,IAAA,CAAK;AAAA,MAClB,MAAM,QAAA,CAAS,EAAA;AAAA,MACf,MAAA,EAAQ;AAAA,QACN,KAAA,EAAO;AAAA,UACL,IAAI,QAAA,CAAS,EAAA;AAAA,UACb,OAAO,QAAA,CAAS,KAAA;AAAA,UAChB,SAAS,QAAA,CAAS,OAAA;AAAA,UAClB,MAAM,QAAA,CAAS,IAAA;AAAA,UACf,UAAU,QAAA,CAAS;AAAA;AACrB;AACF,KACD;AAAA;AAEL,CAAC;;;;"}
|
package/dist/legacy.d.ts
CHANGED
|
@@ -93,11 +93,35 @@ interface ThemeConfig {
|
|
|
93
93
|
defaultPageTheme?: string;
|
|
94
94
|
pageTheme?: Record<string, ThemeConfigPageTheme>;
|
|
95
95
|
options?: ThemeConfigOptions;
|
|
96
|
+
bui?: {
|
|
97
|
+
tokens?: BUITokens;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Structured BUI token overrides configurable via app-config.
|
|
102
|
+
* Maps to BUI's CSS custom properties (--bui-*).
|
|
103
|
+
*/
|
|
104
|
+
interface BUITokens {
|
|
105
|
+
primary?: string;
|
|
106
|
+
warning?: string;
|
|
107
|
+
error?: string;
|
|
108
|
+
success?: string;
|
|
109
|
+
info?: string;
|
|
110
|
+
fontFamily?: string;
|
|
111
|
+
fontFamilyMonospace?: string;
|
|
112
|
+
borderColor?: string;
|
|
113
|
+
backgroundColor?: string;
|
|
114
|
+
foregroundPrimary?: string;
|
|
115
|
+
foregroundSecondary?: string;
|
|
116
|
+
foregroundDisabled?: string;
|
|
117
|
+
focusRing?: string;
|
|
118
|
+
shadow?: string;
|
|
96
119
|
}
|
|
97
120
|
interface Branding {
|
|
98
121
|
theme?: {
|
|
99
122
|
[key: string]: ThemeConfig;
|
|
100
123
|
};
|
|
124
|
+
customCSS?: string;
|
|
101
125
|
}
|
|
102
126
|
interface Config {
|
|
103
127
|
app: {
|
|
@@ -124,4 +148,4 @@ declare const getThemes: () => AppTheme[];
|
|
|
124
148
|
declare const useThemes: () => AppTheme[];
|
|
125
149
|
declare const useLoaderTheme: () => _mui_material.Theme;
|
|
126
150
|
|
|
127
|
-
export { type BackstageThemePalette, type Branding, type Config, type RHDHThemePalette, type ThemeConfig, type ThemeConfigOptions, type ThemeConfigPageTheme, type ThemeConfigPalette, darkThemeProvider, getAllThemes, getThemes, lightThemeProvider, useAllThemes, useBranding, useLoaderTheme, useThemeConfig, useThemeOptions, useThemes };
|
|
151
|
+
export { type BUITokens, type BackstageThemePalette, type Branding, type Config, type RHDHThemePalette, type ThemeConfig, type ThemeConfigOptions, type ThemeConfigPageTheme, type ThemeConfigPalette, darkThemeProvider, getAllThemes, getThemes, lightThemeProvider, useAllThemes, useBranding, useLoaderTheme, useThemeConfig, useThemeOptions, useThemes };
|
package/dist/legacy.esm.js
CHANGED
|
@@ -8,7 +8,9 @@ export { darkThemeProvider, getAllThemes, getThemes, lightThemeProvider, useAllT
|
|
|
8
8
|
export { LogoFull } from './components/LogoFull.esm.js';
|
|
9
9
|
export { LogoIcon } from './components/LogoIcon.esm.js';
|
|
10
10
|
import 'react/jsx-runtime';
|
|
11
|
+
import 'react';
|
|
12
|
+
import '@backstage/core-plugin-api';
|
|
11
13
|
import '@backstage/theme';
|
|
12
14
|
import '@mui/material/styles';
|
|
13
|
-
import '
|
|
15
|
+
import '@mui/material/GlobalStyles';
|
|
14
16
|
//# sourceMappingURL=legacy.esm.js.map
|
package/dist/legacy.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"legacy.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
package/dist/lightTheme.esm.js
CHANGED
|
@@ -21,7 +21,15 @@ const lightThemeOverrides = {
|
|
|
21
21
|
},
|
|
22
22
|
text: {
|
|
23
23
|
primary: "#151515",
|
|
24
|
-
|
|
24
|
+
// PatternFly --pf-v5-global--Color--200; AA on white and #f2f2f2 nav chrome
|
|
25
|
+
secondary: "#6A6E73"
|
|
26
|
+
},
|
|
27
|
+
// MUI defaults (#0288d1 / #ed6c02) fail WCAG AA on white (~3.1–3.9:1)
|
|
28
|
+
info: {
|
|
29
|
+
main: "#0066CC"
|
|
30
|
+
},
|
|
31
|
+
warning: {
|
|
32
|
+
main: "#C05600"
|
|
25
33
|
},
|
|
26
34
|
background: {
|
|
27
35
|
default: "#FFFFFF",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightTheme.esm.js","sources":["../src/lightTheme.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { palettes } from '@backstage/theme';\nimport { type PaletteOptions } from '@mui/material/styles';\n\nimport { type ThemeConfigPalette } from './types';\n\nexport const lightThemeOverrides: Partial<ThemeConfigPalette> = {\n primary: {\n main: '#0066CC',\n },\n secondary: {\n main: '#0066CC',\n },\n navigation: {\n background: '#f2f2f2',\n indicator: 'transparent',\n color: '#151515',\n selectedColor: '#151515',\n navItem: {\n hoverBackground: '#ffffff',\n },\n submenu: {\n background: '#FFF',\n },\n },\n text: {\n primary: '#151515',\n secondary: '#
|
|
1
|
+
{"version":3,"file":"lightTheme.esm.js","sources":["../src/lightTheme.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { palettes } from '@backstage/theme';\nimport { type PaletteOptions } from '@mui/material/styles';\n\nimport { type ThemeConfigPalette } from './types';\n\nexport const lightThemeOverrides: Partial<ThemeConfigPalette> = {\n primary: {\n main: '#0066CC',\n },\n secondary: {\n main: '#0066CC',\n },\n navigation: {\n background: '#f2f2f2',\n indicator: 'transparent',\n color: '#151515',\n selectedColor: '#151515',\n navItem: {\n hoverBackground: '#ffffff',\n },\n submenu: {\n background: '#FFF',\n },\n },\n text: {\n primary: '#151515',\n // PatternFly --pf-v5-global--Color--200; AA on white and #f2f2f2 nav chrome\n secondary: '#6A6E73',\n },\n // MUI defaults (#0288d1 / #ed6c02) fail WCAG AA on white (~3.1–3.9:1)\n info: {\n main: '#0066CC',\n },\n warning: {\n main: '#C05600',\n },\n background: {\n default: '#FFFFFF',\n paper: '#FFFFFF',\n },\n rhdh: {\n general: {\n pageInset: '1.5rem',\n pageInsetBackgroundColor: '#f2f2f2',\n\n disabled: '#6A6E73',\n disabledBackground: '#D2D2D2',\n\n paperBackgroundImage: 'none',\n paperBorderColor: '#C7C7C7',\n\n // Box shadow from PatternFly 5 (--pf-v5-global--BoxShadow--sm)\n popoverBoxShadow:\n '0 0.25rem 0.5rem 0rem rgba(3, 3, 3, 0.12), 0 0 0.25rem 0 rgba(3, 3, 3, 0.06)',\n\n cardBackgroundColor: '#FFF',\n cardBorderColor: '#C7C7C7',\n\n mainSectionBackgroundColor: '#FFF',\n formControlBackgroundColor: '#FFF',\n\n sidebarBackgroundColor: '#f2f2f2',\n sidebarDividerColor: '#c7c7c7',\n sidebarItemSelectedBackgroundColor: '#FFF',\n\n tableTitleColor: '#181818',\n tableSubtitleColor: '#616161',\n tableColumnTitleColor: '#151515',\n tableRowHover: '#F5F5F5',\n tableBorderColor: '#E0E0E0',\n tableBackgroundColor: '#FFF',\n tabsLinkHoverBackgroundColor: 'rgba(199, 199, 199, 0.2500)',\n\n contrastText: '#FFF',\n\n appBarBackgroundScheme: 'light',\n\n appBarBackgroundColor: '#f2f2f2',\n appBarForegroundColor: '#1f1f1f',\n appBarBackgroundImage: 'none',\n\n starredItemsColor: '#F3BA37',\n },\n primary: {\n main: '#0066CC',\n focusVisibleBorder: '#0066CC',\n },\n secondary: {\n main: '#0066CC',\n focusVisibleBorder: '#0066CC',\n },\n cards: {\n headerTextColor: '#151515',\n headerBackgroundColor: '#FFF',\n headerBackgroundImage: 'none',\n },\n },\n};\n\nexport const customLightTheme = (): ThemeConfigPalette => {\n const palette: (typeof palettes)['light'] & PaletteOptions = palettes.light;\n return {\n ...palette,\n ...lightThemeOverrides,\n };\n};\n"],"names":[],"mappings":";;AAqBO,MAAM,mBAAA,GAAmD;AAAA,EAC9D,OAAA,EAAS;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA,SAAA,EAAW;AAAA,IACT,IAAA,EAAM;AAAA,GACR;AAAA,EACA,UAAA,EAAY;AAAA,IACV,UAAA,EAAY,SAAA;AAAA,IACZ,SAAA,EAAW,aAAA;AAAA,IACX,KAAA,EAAO,SAAA;AAAA,IACP,aAAA,EAAe,SAAA;AAAA,IACf,OAAA,EAAS;AAAA,MACP,eAAA,EAAiB;AAAA,KACnB;AAAA,IACA,OAAA,EAAS;AAAA,MACP,UAAA,EAAY;AAAA;AACd,GACF;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,OAAA,EAAS,SAAA;AAAA;AAAA,IAET,SAAA,EAAW;AAAA,GACb;AAAA;AAAA,EAEA,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM;AAAA,GACR;AAAA,EACA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM;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,MACL,eAAA,EAAiB,SAAA;AAAA,MACjB,qBAAA,EAAuB,MAAA;AAAA,MACvB,qBAAA,EAAuB;AAAA;AACzB;AAEJ;AAEO,MAAM,mBAAmB,MAA0B;AACxD,EAAA,MAAM,UAAuD,QAAA,CAAS,KAAA;AACtE,EAAA,OAAO;AAAA,IACL,GAAG,OAAA;AAAA,IACH,GAAG;AAAA,GACL;AACF;;;;"}
|
|
@@ -2,7 +2,7 @@ function styleInject(css, ref) {
|
|
|
2
2
|
if ( ref === void 0 ) ref = {};
|
|
3
3
|
var insertAt = ref.insertAt;
|
|
4
4
|
|
|
5
|
-
if (typeof document === 'undefined') { return; }
|
|
5
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
6
6
|
|
|
7
7
|
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8
8
|
var style = document.createElement('style');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-inject.es.esm.js","sources":["../../../../../../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,
|
|
1
|
+
{"version":3,"file":"style-inject.es.esm.js","sources":["../../../../../../node_modules/style-inject/dist/style-inject.es.js"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n"],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAI,CAAC,GAAG,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,CAAC;;AAEzD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;AAC/C,IAAI,CAAC,MAAM;AACX,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC7B,IAAI;AACJ,EAAE,CAAC,MAAM;AACT,IAAI,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;AAC3B,EAAE;;AAEF,EAAE,IAAI,KAAK,CAAC,UAAU,EAAE;AACxB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG;AAClC,EAAE,CAAC,MAAM;AACT,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;AACnD,EAAE;AACF;;;;","x_google_ignoreList":[0]}
|
package/dist/themes.esm.js
CHANGED
|
@@ -4,12 +4,38 @@ import { themes } from '@backstage/theme';
|
|
|
4
4
|
import LightIcon from '@mui/icons-material/WbSunnyRounded';
|
|
5
5
|
import DarkIcon from '@mui/icons-material/Brightness2Rounded';
|
|
6
6
|
import { createTheme } from '@mui/material/styles';
|
|
7
|
-
import {
|
|
7
|
+
import { createSharedThemeProvider } from './components/ThemeProvider.esm.js';
|
|
8
8
|
import { getDefaultThemeConfig } from './backstage.esm.js';
|
|
9
9
|
import { getDefaultThemeConfig as getDefaultThemeConfig$1 } from './rhdh.esm.js';
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const sharedProvider = createSharedThemeProvider({
|
|
12
|
+
light: { name: "light" },
|
|
13
|
+
dark: { name: "dark" },
|
|
14
|
+
"light-customized": {
|
|
15
|
+
config: {
|
|
16
|
+
mode: "light",
|
|
17
|
+
variant: "rhdh",
|
|
18
|
+
palette: {
|
|
19
|
+
primary: { main: "#ff0000" },
|
|
20
|
+
secondary: { main: "#00ff00" }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"dark-customized": {
|
|
25
|
+
config: {
|
|
26
|
+
mode: "dark",
|
|
27
|
+
variant: "rhdh",
|
|
28
|
+
palette: {
|
|
29
|
+
primary: { main: "#ff0000" },
|
|
30
|
+
secondary: { main: "#00ff00" }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"backstage-light": { theme: themes.light },
|
|
35
|
+
"backstage-dark": { theme: themes.dark }
|
|
36
|
+
});
|
|
37
|
+
const lightThemeProvider = sharedProvider;
|
|
38
|
+
const darkThemeProvider = sharedProvider;
|
|
13
39
|
const getAllThemes = () => {
|
|
14
40
|
return [
|
|
15
41
|
{
|
|
@@ -17,56 +43,42 @@ const getAllThemes = () => {
|
|
|
17
43
|
title: "RHDH Light (latest)",
|
|
18
44
|
variant: "light",
|
|
19
45
|
icon: /* @__PURE__ */ jsx(LightIcon, {}),
|
|
20
|
-
Provider:
|
|
46
|
+
Provider: sharedProvider
|
|
21
47
|
},
|
|
22
48
|
{
|
|
23
49
|
id: "dark",
|
|
24
50
|
title: "RHDH Dark (latest)",
|
|
25
51
|
variant: "dark",
|
|
26
52
|
icon: /* @__PURE__ */ jsx(DarkIcon, {}),
|
|
27
|
-
Provider:
|
|
53
|
+
Provider: sharedProvider
|
|
28
54
|
},
|
|
29
55
|
{
|
|
30
56
|
id: "light-customized",
|
|
31
57
|
title: "RHDH Light (customized)",
|
|
32
58
|
variant: "light",
|
|
33
59
|
icon: /* @__PURE__ */ jsx(LightIcon, {}),
|
|
34
|
-
Provider:
|
|
35
|
-
mode: "light",
|
|
36
|
-
variant: "rhdh",
|
|
37
|
-
palette: {
|
|
38
|
-
primary: { main: "#ff0000" },
|
|
39
|
-
secondary: { main: "#00ff00" }
|
|
40
|
-
}
|
|
41
|
-
})
|
|
60
|
+
Provider: sharedProvider
|
|
42
61
|
},
|
|
43
62
|
{
|
|
44
63
|
id: "dark-customized",
|
|
45
64
|
title: "RHDH Dark (customized)",
|
|
46
65
|
variant: "dark",
|
|
47
66
|
icon: /* @__PURE__ */ jsx(DarkIcon, {}),
|
|
48
|
-
Provider:
|
|
49
|
-
mode: "dark",
|
|
50
|
-
variant: "rhdh",
|
|
51
|
-
palette: {
|
|
52
|
-
primary: { main: "#ff0000" },
|
|
53
|
-
secondary: { main: "#00ff00" }
|
|
54
|
-
}
|
|
55
|
-
})
|
|
67
|
+
Provider: sharedProvider
|
|
56
68
|
},
|
|
57
69
|
{
|
|
58
70
|
id: "backstage-light",
|
|
59
71
|
title: "Backstage Light",
|
|
60
72
|
variant: "light",
|
|
61
73
|
icon: /* @__PURE__ */ jsx(LightIcon, {}),
|
|
62
|
-
Provider:
|
|
74
|
+
Provider: sharedProvider
|
|
63
75
|
},
|
|
64
76
|
{
|
|
65
77
|
id: "backstage-dark",
|
|
66
78
|
title: "Backstage Dark",
|
|
67
79
|
variant: "dark",
|
|
68
80
|
icon: /* @__PURE__ */ jsx(DarkIcon, {}),
|
|
69
|
-
Provider:
|
|
81
|
+
Provider: sharedProvider
|
|
70
82
|
}
|
|
71
83
|
];
|
|
72
84
|
};
|
|
@@ -80,14 +92,14 @@ const getThemes = () => {
|
|
|
80
92
|
title: "Light",
|
|
81
93
|
variant: "light",
|
|
82
94
|
icon: /* @__PURE__ */ jsx(LightIcon, {}),
|
|
83
|
-
Provider:
|
|
95
|
+
Provider: sharedProvider
|
|
84
96
|
},
|
|
85
97
|
{
|
|
86
98
|
id: "dark",
|
|
87
99
|
title: "Dark",
|
|
88
100
|
variant: "dark",
|
|
89
101
|
icon: /* @__PURE__ */ jsx(DarkIcon, {}),
|
|
90
|
-
Provider:
|
|
102
|
+
Provider: sharedProvider
|
|
91
103
|
}
|
|
92
104
|
];
|
|
93
105
|
};
|
package/dist/themes.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.esm.js","sources":["../src/themes.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo } from 'react';\nimport { AppTheme } from '@backstage/core-plugin-api';\nimport { themes } from '@backstage/theme';\n\nimport LightIcon from '@mui/icons-material/WbSunnyRounded';\nimport DarkIcon from '@mui/icons-material/Brightness2Rounded';\nimport { createTheme } from '@mui/material/styles';\n\nimport {
|
|
1
|
+
{"version":3,"file":"themes.esm.js","sources":["../src/themes.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo } from 'react';\nimport { AppTheme } from '@backstage/core-plugin-api';\nimport { themes } from '@backstage/theme';\n\nimport LightIcon from '@mui/icons-material/WbSunnyRounded';\nimport DarkIcon from '@mui/icons-material/Brightness2Rounded';\nimport { createTheme } from '@mui/material/styles';\n\nimport { createSharedThemeProvider } from './components/ThemeProvider';\nimport * as backstage from './backstage';\nimport * as rhdh from './rhdh';\n\nconst sharedProvider = createSharedThemeProvider({\n light: { name: 'light' },\n dark: { name: 'dark' },\n 'light-customized': {\n config: {\n mode: 'light',\n variant: 'rhdh',\n palette: {\n primary: { main: '#ff0000' },\n secondary: { main: '#00ff00' },\n },\n },\n },\n 'dark-customized': {\n config: {\n mode: 'dark',\n variant: 'rhdh',\n palette: {\n primary: { main: '#ff0000' },\n secondary: { main: '#00ff00' },\n },\n },\n },\n 'backstage-light': { theme: themes.light },\n 'backstage-dark': { theme: themes.dark },\n});\n\nexport const lightThemeProvider = sharedProvider;\n\nexport const darkThemeProvider = sharedProvider;\n\nexport const getAllThemes = (): AppTheme[] => {\n return [\n {\n id: 'light',\n title: 'RHDH Light (latest)',\n variant: 'light',\n icon: <LightIcon />,\n Provider: sharedProvider,\n },\n {\n id: 'dark',\n title: 'RHDH Dark (latest)',\n variant: 'dark',\n icon: <DarkIcon />,\n Provider: sharedProvider,\n },\n {\n id: 'light-customized',\n title: 'RHDH Light (customized)',\n variant: 'light',\n icon: <LightIcon />,\n Provider: sharedProvider,\n },\n {\n id: 'dark-customized',\n title: 'RHDH Dark (customized)',\n variant: 'dark',\n icon: <DarkIcon />,\n Provider: sharedProvider,\n },\n {\n id: 'backstage-light',\n title: 'Backstage Light',\n variant: 'light',\n icon: <LightIcon />,\n Provider: sharedProvider,\n },\n {\n id: 'backstage-dark',\n title: 'Backstage Dark',\n variant: 'dark',\n icon: <DarkIcon />,\n Provider: sharedProvider,\n },\n ];\n};\n\nexport const useAllThemes = (): AppTheme[] => {\n return useMemo(() => getAllThemes(), []);\n};\n\nexport const getThemes = (): AppTheme[] => {\n return [\n {\n id: 'light',\n title: 'Light',\n variant: 'light',\n icon: <LightIcon />,\n Provider: sharedProvider,\n },\n {\n id: 'dark',\n title: 'Dark',\n variant: 'dark',\n icon: <DarkIcon />,\n Provider: sharedProvider,\n },\n ];\n};\n\nexport const useThemes = (): AppTheme[] => {\n return useMemo(() => getThemes(), []);\n};\n\nexport const useLoaderTheme = () => {\n return useMemo(() => {\n const latestTheme = localStorage.getItem('theme');\n const mode = latestTheme?.includes('dark') ? 'dark' : 'light';\n const variant = latestTheme?.includes('backstage') ? 'backstage' : 'rhdh';\n const themeOptions =\n variant === 'backstage'\n ? backstage.getDefaultThemeConfig(mode)\n : rhdh.getDefaultThemeConfig(mode);\n return createTheme(themeOptions);\n }, []);\n};\n"],"names":["backstage.getDefaultThemeConfig","rhdh.getDefaultThemeConfig"],"mappings":";;;;;;;;;;AA4BA,MAAM,iBAAiB,yBAAA,CAA0B;AAAA,EAC/C,KAAA,EAAO,EAAE,IAAA,EAAM,OAAA,EAAQ;AAAA,EACvB,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAO;AAAA,EACrB,kBAAA,EAAoB;AAAA,IAClB,MAAA,EAAQ;AAAA,MACN,IAAA,EAAM,OAAA;AAAA,MACN,OAAA,EAAS,MAAA;AAAA,MACT,OAAA,EAA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Aa,OAAA,CAAQ,OAAO,CAAA;AAChD,IAAA,MAAM,IAAA,GAAO,WAAA,EAAa,QAAA,CAAS,MAAM,IAAI,MAAA,GAAS,OAAA;AACtD,IAAA,MAAM,OAAA,GAAU,WAAA,EAAa,QAAA,CAAS,WAAW,IAAI,WAAA,GAAc,MAAA;AACnE,IAAA,MAAM,YAAA,GACJ,YAAY,WAAA,GACRA,sBAAgC,IAAI,CAAA,GACpCC,uBAAK,CAAsB,IAAI,CAAA;AACrC,IAAA,OAAO,YAAY,YAAY,CAAA;AAAA,EACjC,CAAA,EAAG,EAAE,CAAA;AACP;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const buiTokensToCSS = (tokens) => {
|
|
2
|
+
const set = (value) => value;
|
|
3
|
+
const css = {};
|
|
4
|
+
if (tokens.primary) css["--bui-bg-solid"] = set(tokens.primary);
|
|
5
|
+
if (tokens.warning) css["--bui-fg-warning"] = set(tokens.warning);
|
|
6
|
+
if (tokens.error) css["--bui-fg-danger"] = set(tokens.error);
|
|
7
|
+
if (tokens.success) css["--bui-fg-success"] = set(tokens.success);
|
|
8
|
+
if (tokens.info) css["--bui-fg-info"] = set(tokens.info);
|
|
9
|
+
if (tokens.fontFamily) css["--bui-font-regular"] = set(tokens.fontFamily);
|
|
10
|
+
if (tokens.fontFamilyMonospace)
|
|
11
|
+
css["--bui-font-monospace"] = set(tokens.fontFamilyMonospace);
|
|
12
|
+
if (tokens.borderColor) css["--bui-border-1"] = set(tokens.borderColor);
|
|
13
|
+
if (tokens.backgroundColor)
|
|
14
|
+
css["--bui-bg-neutral-1"] = set(tokens.backgroundColor);
|
|
15
|
+
if (tokens.foregroundPrimary)
|
|
16
|
+
css["--bui-fg-primary"] = set(tokens.foregroundPrimary);
|
|
17
|
+
if (tokens.foregroundSecondary)
|
|
18
|
+
css["--bui-fg-secondary"] = set(tokens.foregroundSecondary);
|
|
19
|
+
if (tokens.foregroundDisabled)
|
|
20
|
+
css["--bui-fg-disabled"] = set(tokens.foregroundDisabled);
|
|
21
|
+
if (tokens.focusRing) css["--bui-ring"] = set(tokens.focusRing);
|
|
22
|
+
if (tokens.shadow) css["--bui-shadow"] = set(tokens.shadow);
|
|
23
|
+
return css;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { buiTokensToCSS };
|
|
27
|
+
//# sourceMappingURL=buiTokensToCSS.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buiTokensToCSS.esm.js","sources":["../../src/utils/buiTokensToCSS.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BUITokens } from '../types';\n\n/**\n * Maps structured BUI token config values to CSS custom properties.\n * Uses !important to override BUI's @layer tokens.\n */\nexport const buiTokensToCSS = (tokens: BUITokens): Record<string, string> => {\n const set = (value: string) => value;\n const css: Record<string, string> = {};\n if (tokens.primary) css['--bui-bg-solid'] = set(tokens.primary);\n if (tokens.warning) css['--bui-fg-warning'] = set(tokens.warning);\n if (tokens.error) css['--bui-fg-danger'] = set(tokens.error);\n if (tokens.success) css['--bui-fg-success'] = set(tokens.success);\n if (tokens.info) css['--bui-fg-info'] = set(tokens.info);\n if (tokens.fontFamily) css['--bui-font-regular'] = set(tokens.fontFamily);\n if (tokens.fontFamilyMonospace)\n css['--bui-font-monospace'] = set(tokens.fontFamilyMonospace);\n if (tokens.borderColor) css['--bui-border-1'] = set(tokens.borderColor);\n if (tokens.backgroundColor)\n css['--bui-bg-neutral-1'] = set(tokens.backgroundColor);\n if (tokens.foregroundPrimary)\n css['--bui-fg-primary'] = set(tokens.foregroundPrimary);\n if (tokens.foregroundSecondary)\n css['--bui-fg-secondary'] = set(tokens.foregroundSecondary);\n if (tokens.foregroundDisabled)\n css['--bui-fg-disabled'] = set(tokens.foregroundDisabled);\n if (tokens.focusRing) css['--bui-ring'] = set(tokens.focusRing);\n if (tokens.shadow) css['--bui-shadow'] = set(tokens.shadow);\n return css;\n};\n"],"names":[],"mappings":"AAsBO,MAAM,cAAA,GAAiB,CAAC,MAAA,KAA8C;AAC3E,EAAA,MAAM,GAAA,GAAM,CAAC,KAAA,KAAkB,KAAA;AAC/B,EAAA,MAAM,MAA8B,EAAC;AACrC,EAAA,IAAI,OAAO,OAAA,EAAS,GAAA,CAAI,gBAAgB,CAAA,GAAI,GAAA,CAAI,OAAO,OAAO,CAAA;AAC9D,EAAA,IAAI,OAAO,OAAA,EAAS,GAAA,CAAI,kBAAkB,CAAA,GAAI,GAAA,CAAI,OAAO,OAAO,CAAA;AAChE,EAAA,IAAI,OAAO,KAAA,EAAO,GAAA,CAAI,iBAAiB,CAAA,GAAI,GAAA,CAAI,OAAO,KAAK,CAAA;AAC3D,EAAA,IAAI,OAAO,OAAA,EAAS,GAAA,CAAI,kBAAkB,CAAA,GAAI,GAAA,CAAI,OAAO,OAAO,CAAA;AAChE,EAAA,IAAI,OAAO,IAAA,EAAM,GAAA,CAAI,eAAe,CAAA,GAAI,GAAA,CAAI,OAAO,IAAI,CAAA;AACvD,EAAA,IAAI,OAAO,UAAA,EAAY,GAAA,CAAI,oBAAoB,CAAA,GAAI,GAAA,CAAI,OAAO,UAAU,CAAA;AACxE,EAAA,IAAI,MAAA,CAAO,mBAAA;AACT,IAAA,GAAA,CAAI,sBAAsB,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,mBAAmB,CAAA;AAC9D,EAAA,IAAI,OAAO,WAAA,EAAa,GAAA,CAAI,gBAAgB,CAAA,GAAI,GAAA,CAAI,OAAO,WAAW,CAAA;AACtE,EAAA,IAAI,MAAA,CAAO,eAAA;AACT,IAAA,GAAA,CAAI,oBAAoB,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,eAAe,CAAA;AACxD,EAAA,IAAI,MAAA,CAAO,iBAAA;AACT,IAAA,GAAA,CAAI,kBAAkB,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,iBAAiB,CAAA;AACxD,EAAA,IAAI,MAAA,CAAO,mBAAA;AACT,IAAA,GAAA,CAAI,oBAAoB,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,mBAAmB,CAAA;AAC5D,EAAA,IAAI,MAAA,CAAO,kBAAA;AACT,IAAA,GAAA,CAAI,mBAAmB,CAAA,GAAI,GAAA,CAAI,MAAA,CAAO,kBAAkB,CAAA;AAC1D,EAAA,IAAI,OAAO,SAAA,EAAW,GAAA,CAAI,YAAY,CAAA,GAAI,GAAA,CAAI,OAAO,SAAS,CAAA;AAC9D,EAAA,IAAI,OAAO,MAAA,EAAQ,GAAA,CAAI,cAAc,CAAA,GAAI,GAAA,CAAI,OAAO,MAAM,CAAA;AAC1D,EAAA,OAAO,GAAA;AACT;;;;"}
|
|
@@ -17,9 +17,19 @@ const createComponents = (themeConfig) => {
|
|
|
17
17
|
styleOverrides: (theme) => {
|
|
18
18
|
const backstageOverrides = defaultComponentThemes.MuiCssBaseline.styleOverrides;
|
|
19
19
|
const backstageStyles = typeof backstageOverrides === "function" ? backstageOverrides(theme) : backstageOverrides;
|
|
20
|
+
const dialogMastheadOffset = "var(--rhdh-global-header-height, 64px)";
|
|
20
21
|
return {
|
|
21
22
|
...backstageStyles,
|
|
22
23
|
"@font-face": redHatFontFaces,
|
|
24
|
+
':root:has(#global-header) [class*="bui-DialogOverlay"]': {
|
|
25
|
+
top: `${dialogMastheadOffset} !important`,
|
|
26
|
+
height: `calc(100% - ${dialogMastheadOffset}) !important`,
|
|
27
|
+
zIndex: 1300
|
|
28
|
+
},
|
|
29
|
+
':root:has(#global-header) [class*="bui-DialogOverlay"] > [class*="bui-Dialog"]': {
|
|
30
|
+
height: `calc(100vh - ${dialogMastheadOffset} - 3rem) !important`,
|
|
31
|
+
maxHeight: `calc(100vh - ${dialogMastheadOffset} - 3rem) !important`
|
|
32
|
+
},
|
|
23
33
|
body: {
|
|
24
34
|
...backstageStyles.body,
|
|
25
35
|
fontFamily: redHatFonts.text
|
|
@@ -48,6 +58,9 @@ const createComponents = (themeConfig) => {
|
|
|
48
58
|
"&.MuiTypography-h1": {
|
|
49
59
|
fontWeight: "normal"
|
|
50
60
|
}
|
|
61
|
+
},
|
|
62
|
+
button: {
|
|
63
|
+
textTransform: "none"
|
|
51
64
|
}
|
|
52
65
|
}
|
|
53
66
|
};
|
|
@@ -654,6 +667,13 @@ const createComponents = (themeConfig) => {
|
|
|
654
667
|
}
|
|
655
668
|
}
|
|
656
669
|
};
|
|
670
|
+
components.BackstageIconLinkVertical = {
|
|
671
|
+
styleOverrides: {
|
|
672
|
+
label: {
|
|
673
|
+
textTransform: "none"
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
};
|
|
657
677
|
components.BackstageSidebarPage = {
|
|
658
678
|
styleOverrides: {
|
|
659
679
|
root: {
|
|
@@ -691,12 +711,29 @@ const createComponents = (themeConfig) => {
|
|
|
691
711
|
// Prevent overflow in the main container due to the margin
|
|
692
712
|
maxHeight: `calc(100vh - 2 * ${general.pageInset})`
|
|
693
713
|
},
|
|
714
|
+
// NFS BUI entity pages wrap PluginHeader + tabs + Container in a
|
|
715
|
+
// classless <main>. BUI Container is flex: 1 1 0% but that only
|
|
716
|
+
// grows when main is a flex column — otherwise Topology / Scorecard
|
|
717
|
+
// stay content-height inside a tall well (RHDHBUGS-3543). Do not
|
|
718
|
+
// override Backstage Page, which uses display:grid on <main>.
|
|
719
|
+
"& > main:not([data-backstage-core-page])": {
|
|
720
|
+
display: "flex",
|
|
721
|
+
flexDirection: "column",
|
|
722
|
+
flex: 1,
|
|
723
|
+
minHeight: 0,
|
|
724
|
+
maxHeight: `calc(100% - 2 * ${general.pageInset})`
|
|
725
|
+
},
|
|
694
726
|
// NFS / BUI pages use Container instead of <main>. Match the content
|
|
695
727
|
// well color (same token as BackstageContent) and rely on flex: 1
|
|
696
728
|
// from BUI rather than 100vh so PluginHeader siblings are not overflowed.
|
|
697
729
|
"& > [class*='bui-Container']:not([class*='bui-Header'])": {
|
|
698
730
|
backgroundColor: general.mainSectionBackgroundColor
|
|
699
731
|
},
|
|
732
|
+
// When a BackstagePage-root is present, the MUI page already has
|
|
733
|
+
// its own header; hide the sibling BUI PluginHeader to avoid duplication.
|
|
734
|
+
"&:has([class*='BackstagePage-root']) > .bui-PluginHeader": {
|
|
735
|
+
display: "none"
|
|
736
|
+
},
|
|
700
737
|
// Settings and other pages render BackstageContent as <article>.
|
|
701
738
|
// Grow it to fill the flex column so pageInset doesn't show as a band.
|
|
702
739
|
'& > article, & > [class*="BackstageContent-root"]': {
|