From c48e06dc8b53f1feeb728b2c03ae9a65112fae37 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Wed, 11 Dec 2024 09:16:43 +0100 Subject: [PATCH] feat: provide scrollbar styles as CSS classes --- docs/GETTING_STARTED.md | 2 + src/elements/core/styles/scrollbar.scss | 44 +++++++++++++++++++ src/elements/core/styles/standard-theme.scss | 1 + src/elements/vite.config.ts | 4 +- src/storybook/styles/layout/readme.md | 8 ++-- src/storybook/styles/list/readme.md | 12 ++--- src/storybook/styles/scrollbar/readme.md | 17 ++++--- .../styles/scrollbar/scrollbar-internal.scss | 32 -------------- .../styles/scrollbar/scrollbar.stories.ts | 2 +- .../styles/scrollbar/scrollbar.visual.spec.ts | 2 +- src/storybook/styles/table/readme.md | 2 +- src/storybook/styles/typography/readme.md | 8 ++-- tools/vite/typography.ts | 2 + 13 files changed, 81 insertions(+), 55 deletions(-) create mode 100644 src/elements/core/styles/scrollbar.scss diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index ab7bbbfbac..1c8a0b3390 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -228,6 +228,8 @@ However, if you like to more specifically pick what you need, consider the follo | `animation.css` | Provides CSS classes to disable animation (e.g. for testing). | | `layout.css` | Provides layout related CSS classes (e.g. page spacing, grid). | | `lists.css` | Provides CSS classes to style lists. | +| `scrollbar.css` | Provides CSS classes to style a scrollbar. | +| `table.css` | Provides CSS classes to style a table. | | `typography.css` | Provides typography related CSS classes. | ### Full Font diff --git a/src/elements/core/styles/scrollbar.scss b/src/elements/core/styles/scrollbar.scss new file mode 100644 index 0000000000..b25fd11c0b --- /dev/null +++ b/src/elements/core/styles/scrollbar.scss @@ -0,0 +1,44 @@ +@use './mixins/scrollbar'; + +.sbb-scrollbar, +.sbb-scrollbar-negative, +.sbb-scrollbar-thick, +.sbb-scrollbar-thick-negative, +.sbb-scrollbar-track-visible, +.sbb-scrollbar-negative-track-visible, +.sbb-scrollbar-thick-track-visible, +.sbb-scrollbar-thick-negative-track-visible { + @include scrollbar.scrollbar-rules; +} + +.sbb-scrollbar { + @include scrollbar.scrollbar-variables($size: thin, $negative: false, $track-visible: false); +} + +.sbb-scrollbar-negative { + @include scrollbar.scrollbar-variables($size: thin, $negative: true, $track-visible: false); +} + +.sbb-scrollbar-thick { + @include scrollbar.scrollbar-variables($size: thick, $negative: false, $track-visible: false); +} + +.sbb-scrollbar-thick-negative { + @include scrollbar.scrollbar-variables($size: thick, $negative: true, $track-visible: false); +} + +.sbb-scrollbar-track-visible { + @include scrollbar.scrollbar-variables($size: thin, $negative: false, $track-visible: true); +} + +.sbb-scrollbar-negative-track-visible { + @include scrollbar.scrollbar-variables($size: thin, $negative: true, $track-visible: true); +} + +.sbb-scrollbar-thick-track-visible { + @include scrollbar.scrollbar-variables($size: thick, $negative: false, $track-visible: true); +} + +.sbb-scrollbar-thick-negative-track-visible { + @include scrollbar.scrollbar-variables($size: thick, $negative: true, $track-visible: true); +} diff --git a/src/elements/core/styles/standard-theme.scss b/src/elements/core/styles/standard-theme.scss index 984efe558b..569ce30a4d 100644 --- a/src/elements/core/styles/standard-theme.scss +++ b/src/elements/core/styles/standard-theme.scss @@ -7,4 +7,5 @@ @use './animation'; @use './layout'; @use './lists'; +@use './scrollbar'; @use './table'; diff --git a/src/elements/vite.config.ts b/src/elements/vite.config.ts index 448d153783..eea633f2f5 100644 --- a/src/elements/vite.config.ts +++ b/src/elements/vite.config.ts @@ -63,10 +63,12 @@ export default defineConfig((config) => 'animation.css', 'core.css', 'font-characters-extension.css', - 'standard-theme.css', 'layout.css', 'lists.css', 'normalize.css', + 'scrollbar.css', + 'standard-theme.css', + 'table.css', 'typography.css', ]), }, diff --git a/src/storybook/styles/layout/readme.md b/src/storybook/styles/layout/readme.md index 1d85c25dd9..4c82685cb3 100644 --- a/src/storybook/styles/layout/readme.md +++ b/src/storybook/styles/layout/readme.md @@ -3,7 +3,7 @@ The page spacing ensures inline margins and controls the max-width of the page. The `expanded`-variant has a smaller inline spacing and no max-width. -| css class | sass mixin | +| CSS class | SASS mixin | | --------------------------- | ----------------------- | | `sbb-page-spacing` | `page-spacing` | | `sbb-page-spacing-expanded` | `page-spacing-expanded` | @@ -22,12 +22,12 @@ Alternatively the [sbb-container](/docs/elements-sbb-container-sbb-container--do ## Grid -The grid is available as css class or sass mixin. +The grid is available as CSS class or SASS mixin. It provides the grid from the design specifications on which you can place your elements. The `expanded`-variant has a smaller inline spacing and no max-width. -[See css grid docs for full documentation of all the possibilities of placing elements on a grid.](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout) +[See CSS grid docs for full documentation of all the possibilities of placing elements on a grid.](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout) -| css class | sass mixin | +| CSS class | SASS mixin | | ------------------- | --------------- | | `sbb-grid` | `grid` | | `sbb-grid-expanded` | `grid-expanded` | diff --git a/src/storybook/styles/list/readme.md b/src/storybook/styles/list/readme.md index 9db25d7668..be7084f9fc 100644 --- a/src/storybook/styles/list/readme.md +++ b/src/storybook/styles/list/readme.md @@ -1,6 +1,6 @@ ## sbb-list -| css class | sass mixin | +| CSS class | SASS mixin | | ---------- | ---------- | | `sbb-list` | `list` | @@ -10,7 +10,7 @@ The list styling doesn't define any color itself but inherits it. ### Sass usage -The sass mixin can be included at top level or in a rule. +The SASS mixin can be included at top level or in a rule. If used at top level it will apply rules to the native `