diff --git a/.eslintignore b/.eslintignore index ae40305609f..386bd9ad3dc 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,3 +10,4 @@ /showcases/nuxt-showcase/** build-outputs/ build-showcases/ +/output/vue/scripts/fix-any-types.ts diff --git a/.xo-config.cjs b/.xo-config.cjs index 1b37447b6c1..c328175b1f0 100644 --- a/.xo-config.cjs +++ b/.xo-config.cjs @@ -1,8 +1,6 @@ module.exports = { prettier: true, - ignores: [ - './showcases/nuxt-showcase/**' - ], + ignores: ['./showcases/nuxt-showcase/**'], overrides: [ { files: ['./showcases/angular-showcase/**'], diff --git a/package-lock.json b/package-lock.json index 4b91c1916d8..cafa411c0a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36732,7 +36732,7 @@ }, "showcases/next-showcase": { "dependencies": { - "next": "*", + "next": "latest", "react": "18.3.1", "react-dom": "18.3.1" }, diff --git a/packages/foundations/docs/FontsSizes.md b/packages/foundations/docs/FontsSizes.md index fc2e12e3634..cf2d58254b7 100644 --- a/packages/foundations/docs/FontsSizes.md +++ b/packages/foundations/docs/FontsSizes.md @@ -1,10 +1,35 @@ -# Font-Sizes +# DB Font Sizes -- You should use our provided **Font-Sizes** to change the size of text elements like `
` etc. +The font sizes of foundations consist of [two different sets](./overview) (9 sizes each) for general texts (**Body Font Sizes**) and headlines (**Headline Font Sizes**). +All sizes of both sets are automatically adjusted by the selected [density](./../densities/readme). -> **_NOTE:_** Some sizes may stay the same because of screen-width or density. +## Body Font Sizes -## How to include colors +- By default, the Body Font Size `md` is set to the body tag. +- These 9 Body Font Sizes can also be explicitly set as classes on elements in order to change their font size. + +## Headline Font Sizes + +- 9 Headline Sizes are available and are usable by custom properties +- 6 Headline Sizes are mapped to native headline tags (`h1` to `h6`) by default. Headlines can therefore be used directly. + +## Available variants / sizes + +`3xl` | `2xl` | `xl` | `lg` | `md` | `sm` | `xs` | `2xs` | `3xs` + +## When to use + +- Use our provided **Body Font Sizes** to explicitly change the size of text elements like `
`, `` etc.
+- Use a **Body Font Size** for a container and all text elements in it (does not affect components font-sizes) .
+- **Headline Font Sizes** can be used to override the default mapping of the `h1` - `h6` tags.
+- _Advanced: use standardised *custom properties* to define `font-size` and `line-height` in your own components._
+
+### Notes
+
+> - Some sizes may stay the same because of screen width or density.
+> - Elements such as ` ` and all headings (`h1` - `h6`) as well as **DB UI components** have font sizes assigned by default so that they can be used without further customisation.
+
+### How to include
For **CSS** and **Tailwind** you need to use the import `@import "@db-ui/foundations/build/css/fonts/classes/all.css";` in your root `.css` file.
@@ -23,12 +48,37 @@ Then you can use e.g. `sm` font-size by extending our SCSS placeholders like thi
### How to use
-We're providing an [overview for all possible font-sizes](./overview).
+The following options are recommended for applying **Body Font Sizes**:
+
+- CSS classes
+- CSS `data-`attributes
+- SCSS placeholders
+- Tailwind classes
-There are several variants: `3xl`, `2xl`, `xl`, `lg`, `md`, `sm`, `xs`, `2xs`, `3xs`.
+All options (except the last one) set `font-size`, `line-height` and some **CSS Custom Properties** for an element. These custom properties are internally required by some components to be displayed correctly.
-**We use `XX` here you should replace it with a variant from above.**
+> All available variants / sizes, [see also the detailed overview](./overview):
+>
+> `3xl` | `2xl` | `xl` | `lg` | `md` | `sm` | `xs` | `2xs` | `3xs`
-| Variant | CSS | SCSS | Tailwind |
-| :-----: | ------------------------- | ------------------------------------ | ------------------------- |
-| `XX` | `class="db-font-size-XX"` | `@extend %db-overwrite-font-size-XX` | `class="db-font-size-XX"` |
+**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"` |
+
+#### Advanced use: CSS Custom Properties
+
+> **_Note:_** The direct use of custom properties to set font sizes should be avoided if possible. If this is unavoidable, existing restrictions should be taken into account.
+
+All of the above options are available for applying the **Body Font Sizes** to HTML elements within custom components.
+In some cases it may make sense to set the `font-size` and `line-height` manually in the css.
+
+**Please replace `XX` in the custom-properties with one of the sizes:**
+
+```css
+.text-element {
+ font-size: var(--db-type-body-font-size-XX);
+ line-height: var(--db-type-body-line-height-XX);
+}
+```
diff --git a/showcases/patternhub/pages/foundations/font-sizes/overview.tsx b/showcases/patternhub/pages/foundations/font-sizes/overview.tsx
index 92674b91b72..9b57b5ef3cc 100644
--- a/showcases/patternhub/pages/foundations/font-sizes/overview.tsx
+++ b/showcases/patternhub/pages/foundations/font-sizes/overview.tsx
@@ -1,24 +1,266 @@
+import { useState } from 'react';
import DefaultPage from '../../../components/default-page';
-import { DBInfotext } from '../../../../../output/react/src';
+import {
+ DBInfotext,
+ DBSwitch,
+ DBIcon,
+ DBSection
+} from '../../../../../output/react/src';
+
+const overwriteHeadlineMarkdown = `/* Select a headline tag to be overwritten */
+h1 {
+ font-size: var(--db-type-headline-font-size-XX);
+ line-height: var(--db-type-headline-line-height-XX);
+
+ /* spacings may vary depending on the project */
+ margin-block: var(--db-spacing-fixed-XX);
+}
+`;
+
+const getCodeExampleBodyFontSize = (size: string) => `.db-font-size-${size} {
+ font-size: var(--db-type-body-font-size-${size});
+ line-height: var(--db-type-body-line-height-${size});
+
+ /* custom properties only for components */
+ --db-icon-font-weight: var(--db-base-body-icon-weight-${size});
+ --db-icon-font-size: var(--db-base-body-icon-font-size-${size});
+ --db-base-line-height: var(--db-type-body-line-height-${size});
+ --db-base-font-size: var(--db-type-body-font-size-${size});
+}
+`;
+const getCodeExampleHeadlineTag = (tag: string, size: string) => `${tag} {
+ line-height: var(--db-type-headline-line-height-${size});
+ font-size: var(--db-type-headline-font-size-${size});
+ margin-block: var(--db-spacing-fixed-${size});
+}
+`;
+
+const getCodeExampleHeadlineSizes = (
+ size: string
+) => `.custom-headline-selector {
+ line-height: var(--db-type-headline-line-height-${size});
+ font-size: var(--db-type-headline-font-size-${size});
+ margin-block: var(--db-spacing-fixed-${size});
+}
+`;
const ColorOverview = () => {
+ const [showCodeBody, setShowCodeBody] = useState(false);
+ const [showCodeHeadlines, setShowCodeHeadlines] = useState(false);
+ const [showCodeHeadlineSizes, setShowCodeHeadlineSizes] = useState(false);
+
return (
+ All 9 body font sizes provided by foundations
+ can be set via css class,{' '}
+ data-attribute,{' '}
+ scss placeholder or{' '}
+ Tailwind class (
+ How to use). This ensures that all custom
+ properties are defined by the class to match the font size, so
+ that certain child components fit correctly. For example, this
+ allows DBIcon component to display its icon in the correct
+ height and weight according to the chosen font-size.
+
+ Therefore, if possible, these db-font-size classes should
+ be used to change the font size of certain text elements such as{' '}
+
- I am size: {size}
-
+ I am size: {size}{' '}
+ {size !== '3xl' && size !== '3xs' && (
+
+ Certain Headline Font Sizes are mapped to the{' '}
+ headline tags (H1 - H6) by default.
+ Accordingly, it is sufficient to use the native headline tags,
+ as in this example.
+
+ This overview shows all 9 headline sizes that
+ are available in foundations. These can be used, for example, to
+ (globally) overwrite the default mapping. Instructions on how
+ overwriting works are below.
+
+ To overwrite the default mapping of the foundations, a suitable
+ selector (H1 - H6 or css class) is used to set{' '}
+
+ These custom properties must be used for overwrites:
+
+ They are available in the following sizes:
+
+ FontsSizes Overview
- Body
- Font Sizes Overview
+
+
+ xl
{' '}
+ sizes are the same.
Body Font Sizes
+ p
or containers with other texts.
+ 3xl
and 3xs
. That is why they are
+ hidden there.
+
+
+
+ >
)
)}
+
+ {getCodeExampleBodyFontSize(size)}
+
+ Default Headlines H1 - H6
+
+
+
+
+ >
+ ))}
+
+ {getCodeExampleHeadlineTag(Tag, size)}
+
+ Available Headline Font Sizes
+
+
+
+
+ Headline with size: {size}
+
+
+
+ >
+ )
+ )}
+
+ {getCodeExampleHeadlineSizes(size)}
+
+ How to overwrite headlines default mapping
+ font-size
and line-height
(and{' '}
+ margin-block
if necessary) to the desired size
+ using the supplied custom properties.
+ font-size
and line-height
must{' '}
+ be selected with the same size (e.g. md
).
+
+ --db-type-headline-font-size-XX
+
+ --db-type-headline-line-height-XX
+
+ --db-spacing-fixed-XX
(optional e.g. for margin)
+ 3xl
| 2xl
| xl
|{' '}
+ lg
| md
| sm
|{' '}
+ xs
| 2xs
| 3xs
+
+
+
+ {overwriteHeadlineMarkdown}
+
+