Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add headline sizes as css class to overwrite headlines on purpose #3500

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/foundations/docs/FontsSizes.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ All options (except the last one) set `font-size`, `line-height` and some **CSS

**Note: We use `XX` here. You should replace it with a size from above.**

| CSS class | CSS data-attribute | SCSS | Tailwind |
| :-----------------------: | --------------------- | ------------------------------------ | ------------------------- |
| `class="db-font-size-XX"` | `data-font-size="XX"` | `@extend %db-overwrite-font-size-XX` | `class="db-font-size-XX"` |
| CSS class | CSS data-attribute | SCSS | Tailwind |
| :---------------------------: | ------------------------- | ---------------------------------------- | ----------------------------- |
| `class="db-font-size-XX"` | `data-font-size="XX"` | `@extend %db-overwrite-font-size-XX` | `class="db-font-size-XX"` |
| `class="db-headline-size-XX"` | `data-headline-size="XX"` | `@extend %db-overwrite-headline-size-XX` | `class="db-headline-size-XX"` |

#### Advanced use: CSS Custom Properties

Expand Down
16 changes: 16 additions & 0 deletions packages/foundations/scss/fonts/_font-sizes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
font-size: var(--db-type-body-font-size-#{$size});
}

@mixin set-headline-variables($size) {
/* Those variables are only for components to calculate heights and change icons */
--db-icon-font-weight: var(--db-base-headline-icon-weight-#{$size});
--db-icon-font-size: var(--db-base-headline-icon-font-size-#{$size});
}

@mixin set-headline-size($size) {
line-height: var(--db-type-headline-line-height-#{$size});
font-size: var(--db-type-headline-font-size-#{$size});
}

$font-sizes: "3xl", "2xl", "xl", "lg", "md", "sm", "xs", "2xs", "3xs";

/**
Expand All @@ -33,6 +44,11 @@ $font-sizes: "3xl", "2xl", "xl", "lg", "md", "sm", "xs", "2xs", "3xs";
@include set-component-variables($font-size);
@include set-font-size($font-size);
}

%db-overwrite-headline-size-#{$font-size} {
@include set-headline-variables($font-size);
@include set-headline-size($font-size);
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions packages/foundations/scss/fonts/classes/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@
[data-font-size="#{$font-size}"] {
@extend %db-overwrite-font-size-#{$font-size};
}

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "2xl";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "2xs";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "3xl";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "3xs";

Expand Down
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/body/all.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

@each $font-size in index.$font-sizes {
.db-font-size-#{$font-size},
[data-font-size="#{$font-size}"] {
@extend %db-overwrite-font-size-#{$font-size};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "lg";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "md";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "sm";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "xl";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use "../index";
@use "../../index";

$font-size: "xs";

Expand Down
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/2xl.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "2xl";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/2xs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "2xs";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/3xl.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "3xl";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/3xs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "3xs";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/all.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

@each $font-size in index.$font-sizes {
.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/lg.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "lg";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/md.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "md";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/sm.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "sm";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/xl.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "xl";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
8 changes: 8 additions & 0 deletions packages/foundations/scss/fonts/classes/headline/xs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../../index";

$font-size: "xs";

.db-headline-size-#{$font-size},
[data-headline-size="#{$font-size}"] {
@extend %db-overwrite-headline-size-#{$font-size};
}
Loading