From: Mark Otto Date: Thu, 2 Oct 2025 19:24:54 +0000 (-0700) Subject: Update theme life while here X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cc4d43664e0b18936616a3338283e3cea23778c1;p=thirdparty%2Fbootstrap.git Update theme life while here --- diff --git a/scss/_theme.scss b/scss/_theme.scss index 22ceac745a..6ccb7a1dc5 100644 --- a/scss/_theme.scss +++ b/scss/_theme.scss @@ -138,7 +138,7 @@ $theme-fgs: ( $theme-borders: ( null: light-dark(var(--#{$prefix}gray-300), var(--#{$prefix}gray-700)), "muted": light-dark(var(--#{$prefix}gray-200), var(--#{$prefix}gray-800)), - "subtle": light-dark(var(--#{$prefix}gray-100), color-mix(in srgb, var(--#{$prefix}gray-800), var(--#{$prefix}gray-900))), + "subtle": light-dark(var(--#{$prefix}gray-100), var(--#{$prefix}gray-900)), "emphasized": light-dark(var(--#{$prefix}gray-400), var(--#{$prefix}gray-600)), ) !default; diff --git a/site/src/components/shortcodes/Swatch.astro b/site/src/components/shortcodes/Swatch.astro index bca1db31cd..5ce9f4ba4f 100644 --- a/site/src/components/shortcodes/Swatch.astro +++ b/site/src/components/shortcodes/Swatch.astro @@ -5,9 +5,11 @@ export interface Props { size?: 'inline' | 'medium' | 'large' contrast?: string contrastDark?: string + cssVar?: string + showVar?: boolean } -const { bg, fg, size = 'inline', contrast, contrastDark } = Astro.props +const { bg, fg, size = 'inline', contrast, contrastDark, cssVar, showVar = true } = Astro.props // Styles for different sizes const baseStyles = { @@ -52,6 +54,9 @@ const contrastStyles = { } const combinedStyles = { ...baseStyles, ...sizeStyles[size] } + +// Determine which CSS variable to display +const displayCssVar = cssVar || bg --- {size === 'inline' ? ( - - - {contrast && {contrast}} - {contrastDark && {contrastDark}} - + <> + + + {contrast && {contrast}} + {contrastDark && {contrastDark}} + + {showVar && displayCssVar && ( + + Loading... + Loading... + + )} + ) : size === 'large' ? ( @@ -93,3 +131,73 @@ const combinedStyles = { ...baseStyles, ...sizeStyles[size] } {contrastDark && {contrastDark}} )} + + diff --git a/site/src/content/docs/customize/theme.mdx b/site/src/content/docs/customize/theme.mdx index 9e64d07d17..4a7c63f1ff 100644 --- a/site/src/content/docs/customize/theme.mdx +++ b/site/src/content/docs/customize/theme.mdx @@ -93,38 +93,52 @@ Every token is available as a CSS variable, and most are then consumed by our ut })} -## Theme `fg` and `bg` +## `fg`, `bg`, and `border` -Theme foreground and background tokens are defined in their respective `$theme-fgs` and `$theme-bgs` Sass maps. These maps are used to generate color mode adaptive `color` and `background-color` values that are then consumed by our utilities and components. You'll find these values in the `_theme.scss` file. +While several text, background, and border colors are configured in the base `$new-theme-colors` Sass map, there are several additional options available for more nuanced theming with regards to foreground, background, and border colors. -Theme backgrounds include the following semantic colors: +Tokens for these three themes are defined in their respective `$theme-fgs`, `$theme-bgs`, and `$theme-borders` Sass maps. These maps are used to generate color mode adaptive `color`, `background-color`, and `border-color` values that are then consumed by our utilities and components. You'll find these values in the `_theme.scss` file. + +Theme backgrounds include several practical and semantic color options. | Background | Default value | Description | | --- | --- | --- | -| `null` | `var(--bs-white)` | Default background color | -| `1` | `var(--bs-gray-025)` | Lowest contrast background color | -| `2` | `var(--bs-gray-050)` | Lower contrast background color | -| `3` | `var(--bs-gray-100)` | Medium contrast background color, typically used for disabled states | -| `white` | `var(--bs-white)` | Pure white background color | -| `black` | `var(--bs-black)` | Pure black background color | -| `transparent` | `transparent` | Transparent background color | +| `null` | | Default background color | +| `1` | | Lowest contrast background color | +| `2` | | Lower contrast background color | +| `3` | | Medium contrast background color, typically used for disabled states | +| `white` | | Pure white background color | +| `black` | | Pure black background color | +| `transparent` | | Transparent background color | | `inherit` |`inherit` | Inherited background color | +Almost all those options are also available for foreground text colors. + | Foreground | Default value | Description | | --- | --- | --- | -| `null` | `var(--bs-gray-900)` | Default foreground color | -| `1` | `var(--bs-gray-800)` | Lowest contrast foreground color | -| `2` | `var(--bs-gray-700)` | Lower contrast foreground color | -| `3` | `var(--bs-gray-600)` | Medium contrast foreground color | -| `white` | `var(--bs-white)` | Pure white foreground color | -| `black` | `var(--bs-black)` | Pure black foreground color | -| `transparent` | `transparent` | Transparent foreground color | +| `null` | | Default foreground color | +| `1` | | Lowest contrast foreground color | +| `2` | | Lower contrast foreground color | +| `3` | | Medium contrast foreground color | +| `white` | | Pure white foreground color | +| `black` | | Pure black foreground color | | `inherit` | `inherit` | Inherited foreground color | +Border colors have similar levels, but different naming. + + +| Border | Default value | Description | +| --- | --- | --- | +| `null` | | Default border color | +| `muted` | | Muted border color | +| `subtle` | | Subtle border color | +| `emphasized` | | Emphasized border color | + + ### Suggested pairings Not all foreground colors are appropriate for all background colors. To maintain color contrast for accessibility, here are some recommended pairings.