diff --git a/.storybook/preview.js b/.storybook/preview.js index fc432f30..fd350e4b 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -19,7 +19,14 @@ export const decorators = [ ]; export const parameters = { - actions: { argTypesRegex: "^on[A-Z].*" }, + options: { + storySort: { + order: ["Configuration", "Components", "Forms", "Extensions", "CMEM", "*"], + }, + }, + actions: { + argTypesRegex: "^on[A-Z].*", + }, controls: { matchers: { color: /(background|color)$/i, diff --git a/CHANGELOG.md b/CHANGELOG.md index f61ca14a..628cb853 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - `` - component for hiding elements in specific media - `` - - force children to get displayed as inline content + - force children to get displayed as inline content - `` - - `useOnly` property: specify if only parts of the content should be used for the shortened preview, this property replaces `firstNonEmptyLineOnly` + - `useOnly` property: specify if only parts of the content should be used for the shortened preview, this property replaces `firstNonEmptyLineOnly` +- CSS custom properties + - beside the color palette we now mirror the most important layout configuration variables as CSS custom properties ### Fixed @@ -21,11 +23,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - create more whitespace inside `small` tag - reduce visual impact of border - `` - - take Markdown rendering into account before testing the maximum preview length + - take Markdown rendering into account before testing the maximum preview length - `` - header-menu items are vertically centered now - `Typography` - - adjust displaying fallback symbols in different browsers + - adjust displaying fallback symbols in different browsers ### Changed @@ -43,7 +45,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Deprecated - `` - - `firstNonEmptyLineOnly` will be removed, is replaced by `useOnly="firstNonEmptyLine"` + - `firstNonEmptyLineOnly` will be removed, is replaced by `useOnly="firstNonEmptyLine"` ## [25.0.0] - 2025-12-01 diff --git a/src/components/Application/_colors.scss b/src/components/Application/_colors.scss index 6cd103d1..6a16bd7d 100644 --- a/src/components/Application/_colors.scss +++ b/src/components/Application/_colors.scss @@ -2,6 +2,7 @@ @use "sass:list"; :root { + // creating css custom properties from palette colors @each $palette-group-name, $palette-group-tints in $eccgui-color-palette-light { @each $palette-tint-name, $palette-tint-colors in $palette-group-tints { @for $i from 1 through list.length($palette-tint-colors) { @@ -12,4 +13,18 @@ } } } + + // set aliases for base colors + --#{$eccgui}-color-primary: #{$eccgui-color-primary}; + --#{$eccgui}-color-primary-contrast: #{$eccgui-color-primary-contrast}; + --#{$eccgui}-color-accent: #{$eccgui-color-accent}; + --#{$eccgui}-color-accent-contrast: #{$eccgui-color-accent-contrast}; + --#{$eccgui}-color-success-foreground: #{$eccgui-color-success-text}; + --#{$eccgui}-color-success-background: #{$eccgui-color-success-background}; + --#{$eccgui}-color-info-foreground: #{$eccgui-color-info-text}; + --#{$eccgui}-color-info-background: #{$eccgui-color-info-background}; + --#{$eccgui}-color-warning-foreground: #{$eccgui-color-warning-text}; + --#{$eccgui}-color-warning-background: #{$eccgui-color-warning-background}; + --#{$eccgui}-color-danger-foreground: #{$eccgui-color-danger-text}; + --#{$eccgui}-color-danger-background: #{$eccgui-color-danger-background}; } diff --git a/src/configuration/_customproperties.scss b/src/configuration/_customproperties.scss new file mode 100644 index 00000000..e72ba008 --- /dev/null +++ b/src/configuration/_customproperties.scss @@ -0,0 +1,32 @@ +/** + * We mirror our SCSS variables here to improve availability in inline styles + * and module styles without included SCSS config stack. + * Colors are set in `src/components/Application/_colors.scss`. + */ + +:root { + --#{$eccgui}-size-typo-caption: #{$eccgui-size-typo-caption}; + --#{$eccgui}-size-typo-caption-lineheight: #{$eccgui-size-typo-caption-lineheight}; + --#{$eccgui}-size-typo-text: #{$eccgui-size-typo-text}; + --#{$eccgui}-size-typo-text-lineheight: #{$eccgui-size-typo-text-lineheight}; + --#{$eccgui}-size-typo-subtitle: #{$eccgui-size-typo-subtitle}; + --#{$eccgui}-size-typo-subtitle-lineheight: #{$eccgui-size-typo-subtitle-lineheight}; + --#{$eccgui}-size-typo-title: #{$eccgui-size-typo-title}; + --#{$eccgui}-size-typo-title-lineheight: #{$eccgui-size-typo-title-lineheight}; + --#{$eccgui}-size-typo-headline: #{$eccgui-size-typo-headline}; + --#{$eccgui}-size-typo-headline-lineheight: #{$eccgui-size-typo-headline-lineheight}; + --#{$eccgui}-font-weight-light: #{$eccgui-font-weight-light}; + --#{$eccgui}-font-weight-regular: #{$eccgui-font-weight-regular}; + --#{$eccgui}-font-weight-bold: #{$eccgui-font-weight-bold}; + --#{$eccgui}-font-spacing-condensed: #{$eccgui-font-spacing-condensed}; + --#{$eccgui}-font-spacing-regular: #{$eccgui-font-spacing-regular}; + --#{$eccgui}-font-spacing-wide: #{$eccgui-font-spacing-wide}; + --#{$eccgui}-size-block-whitespace: #{$eccgui-size-block-whitespace}; + --#{$eccgui}-size-inline-whitespace: #{$eccgui-size-inline-whitespace}; + --#{$eccgui}-opacity-regular: #{$eccgui-opacity-regular}; + --#{$eccgui}-opacity-narrow: #{$eccgui-opacity-narrow}; + --#{$eccgui}-opacity-muted: #{$eccgui-opacity-muted}; + --#{$eccgui}-opacity-disabled: #{$eccgui-opacity-disabled}; + --#{$eccgui}-opacity-ghostly: #{$eccgui-opacity-ghostly}; + --#{$eccgui}-opacity-invisible: #{$eccgui-opacity-invisible}; +} diff --git a/src/configuration/stories/customproperties.stories.tsx b/src/configuration/stories/customproperties.stories.tsx new file mode 100644 index 00000000..93722ed8 --- /dev/null +++ b/src/configuration/stories/customproperties.stories.tsx @@ -0,0 +1,118 @@ +import React from "react"; +import { Meta, StoryFn } from "@storybook/react"; + +import CssCustomProperties from "../../common/utils/CssCustomProperties"; +import { + Section, + SectionHeader, + Spacing, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableHeader, + TableRow, + TitleSubsection, +} from "../../components"; +import { CLASSPREFIX as eccgui } from "../../index"; + +const groups: { title: string; filterName: (name: string) => boolean }[] = [ + { + title: "Typography", + filterName: (name) => name.startsWith(`--${eccgui}-size-typo`), + }, + { + title: "Font weights and spacing", + filterName: (name) => name.startsWith(`--${eccgui}-font`), + }, + { + title: "Whitespace", + filterName: (name) => name.startsWith(`--${eccgui}-size-block`) || name.startsWith(`--${eccgui}-size-inline`), + }, + { + title: "Color aliases", + filterName: (name) => name.startsWith(`--${eccgui}-color`) && !name.startsWith(`--${eccgui}-color-palette`), + }, + { + title: "Opacity", + filterName: (name) => name.startsWith(`--${eccgui}-opacity`), + }, + { + title: "Palette colors", + filterName: (name) => name.startsWith(`--${eccgui}-color-palette`), + }, +]; + +const CssCustomPropertiesOverview = () => { + return ( + <> + {groups.map(({ title, filterName }) => { + const properties = new CssCustomProperties({ + selectorText: ":root", + filterName, + removeDashPrefix: false, + returnObject: false, + }).customProperties() as string[][]; + + return ( + +
+ + {title} + + + + + + + CSS custom property + Current value + + + + {properties.map(([name, value]) => ( + + + {name} + + + {name.startsWith(`--${eccgui}-color`) && ( + + )} + {value} + + + ))} + +
+
+
+ +
+ ); + })} + + ); +}; + +/** + * We mirror our SCSS configuration variables as CSS custom vars. + * This way they can be easily used for inline styles or in CSS modules without SCSS includes. + */ +export default { + title: "Configuration/CSS Custom Properties", + component: CssCustomPropertiesOverview, +} as Meta; + +export const Default: StoryFn = () => ; diff --git a/src/index.scss b/src/index.scss index f6707112..ad01bc16 100644 --- a/src/index.scss +++ b/src/index.scss @@ -9,6 +9,7 @@ // == load default configuration =============================================== @import "./configuration/variables"; +@import "./configuration/customproperties"; // mirror config as custom properties // == Necessary imports from libraries =========================================