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: changed the consumption how to import required styles #2612

Merged
merged 24 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
99cbc58
feat: changed the consumption how to import required styles
nmerget May 6, 2024
3a975a2
fix: wrong import
nmerget May 8, 2024
028e40a
chore: add extra classes for foundation styling
nmerget May 8, 2024
983472c
fix: issue with wrong placeholder
nmerget May 8, 2024
fbc00f6
fix: issue with wrong import
nmerget May 8, 2024
731c230
chore: update snapshots
nmerget May 8, 2024
a4fe9e5
Merge branch 'main' of github.com:db-ui/mono into feat-style-consumption
nmerget May 10, 2024
c10a09e
chore: update snapshots
nmerget May 10, 2024
e530591
fix: missing dependency for helper class
nmerget May 10, 2024
4b8b9be
Update README.md
mfranzke May 13, 2024
b4fef4c
Update README.md
mfranzke May 13, 2024
39d4e7f
Update README.md
mfranzke May 13, 2024
59e1277
Update README.md
mfranzke May 13, 2024
c4660fd
Update README.md
mfranzke May 13, 2024
9da11cb
Update packages/components/src/components/tooltip/tooltip.scss
nmerget May 13, 2024
73e93db
fix: issues from PR
nmerget May 13, 2024
d27d5b3
Merge branch 'main' of github.com:db-ui/mono into feat-style-consumption
nmerget May 13, 2024
1c03b95
chore: update from main
nmerget May 21, 2024
6419c93
chore: update snapshots
nmerget May 21, 2024
8bcee38
Merge branch 'main' of github.com:db-ui/mono into feat-style-consumption
nmerget May 29, 2024
9e68c1e
fix: issue with densities
nmerget May 29, 2024
48a4bae
fix: issue from PR
nmerget May 29, 2024
2cf4ffb
chore: update snapshots
nmerget May 29, 2024
f9c59d4
Merge branch 'main' into feat-style-consumption
mfranzke May 30, 2024
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: 7 additions & 0 deletions docs/migration/alpha-beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ This is related to the following properties:
- `slotHeadline`
- `slotDrawerHeader`
- `slotSubNavigation`

## Styling

We add some more information about our styling and try to generate classes and data-attributes to use in the project, based on user-preferences.
Moreover, we add all optional styles to `db-ui-42` which may increase the size, but reduces the complexity for using the Design-System with all features.
mfranzke marked this conversation as resolved.
Show resolved Hide resolved

If you encounter performance issues try to reduce your loaded styles with this [documentation](https://github.com/db-ui/mono/blob/main/packages/components/README.md#optimize-dependencies) or by using a tool like [purgecss](https://purgecss.com/).
4 changes: 3 additions & 1 deletion output/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ npm i @db-ui/ngx-components

## Styling Dependencies

Import the styles in scss or css. Based on your technology the file names could be different.
Import the styles in `scss` or `css`. Based on your technology the file names could be different.

- Default (db-ui-42): points to `../assets`
- Webpack (db-ui-42-webpack): points to `~@db-ui/foundations/assets`
Expand All @@ -44,6 +44,8 @@ Import the styles in scss or css. Based on your technology the file names could

</details>

> **Note:** The `db-ui-42` file contains optional and all components styles. If you consider performance issues see [@db-ui/components](https://www.npmjs.com/package/@db-ui/components) for more information.

### Resolve assets

The current default development config in `angular.json` doesn't use output hashing. This may cause an issue loading the fonts. Look at [this](https://github.com/angular/angular-cli/issues/26347) for more information.
Expand Down
2 changes: 2 additions & 0 deletions output/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import "@db-ui/components/build/styles/db-ui-42-rollup.css";

</details>

> **Note:** The `db-ui-42` file contains optional and all components styles. If you consider performance issues see [@db-ui/components](https://www.npmjs.com/package/@db-ui/components) for more information.

## Usage

```tsx
Expand Down
2 changes: 2 additions & 0 deletions output/vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import "@db-ui/v-components/dist/style.css";

</details>

> **Note:** The `db-ui-42` file contains optional and all components styles. If you consider performance issues see [@db-ui/components](https://www.npmjs.com/package/@db-ui/components) for more information.

## Usage

```vue
Expand Down
26 changes: 26 additions & 0 deletions packages/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ Or within your JavaScript files, with the related bundler as a prefix (in this c
import "@db-ui/components/build/styles/db-ui-42-rollup.css";
```

### Optimize dependencies

If you only need some of the components or some features from [`@db-ui/foundations`](https://www.npmjs.com/package/@db-ui/foundations), you shouldn't include `db-ui-42`.
In the case you want to include only some components, and you could do it like this:

```css
/* The theme contains all prop required for components like spacings, colors, ... */
@import "@db-ui/foundations/build/css/default-theme.css";
/* The font include uses default font families based on your bundling paths (relative, absolute, webpack, rollup) */
@import "@db-ui/foundations/build/css/fonts/include-rollup.css";
/* The required styles will normalize css and add focus and default font to body */
@import "@db-ui/foundations/build/css/init/required.css";
/* The default root adds a default color space (neutral) and a density (regular) */
@import "@db-ui/foundations/build/css/init/default-root.css";

/* Optional: Add animations / transitions for components */
@import "@db-ui/components/build/styles/component-animations.css";

/* Optional: Add data-icon/data-icon-after to global attributes to enable icons for components */
@import "@db-ui/foundations/build/css/icons/include-rollup.css";

/* Optional: Add components */
@import "@db-ui/components/build/components/button/button.css";
@import "@db-ui/components/build/components/input/input.css";
```

## Deutsche Bahn brand

As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even when being used with the code that we're provide with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UI products free to use and release it under the Apache 2.0 license.
Expand Down
8 changes: 3 additions & 5 deletions packages/components/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,9 @@
</li>

<li>
<a href="./src/fonts.html">Fonts</a>
</li>

<li>
<a href="./src/icons.html">Icons</a>
<a href="./test/import-styles/simple-button/index.html">
Import styles: Simple Button
</a>
</li>
</ul>
</body>
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/components/badge/badge.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@
@extend %absolute-badge;
}
}

// Global styles

:has(> .db-badge[data-placement^="corner"]) {
position: relative;
}
bruno-sch marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@use "@db-ui/foundations/build/scss/variables";
@use "@db-ui/foundations/build/scss/colors";
@use "@db-ui/foundations/build/scss/focus";
@use "@db-ui/foundations/build/scss/icons";
@use "@db-ui/foundations/build/scss/helpers";
@use "../../styles/component";
Expand Down
24 changes: 24 additions & 0 deletions packages/components/src/components/tooltip/tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,27 @@ $tooltip-arrow-shadow-size: variables.$db-sizing-2xs;
}
}
}

// Global styles

@mixin show-popover($state) {
:has(
> :is(db-tooltip, dbtooltip) > .db-tooltip:not([data-open]),
> .db-tooltip:not([data-open])
) {
&:#{$state} {
.db-tooltip:first-of-type {
@extend %show-popover;
}
}
}
}

:has(> db-tooltip, > dbtooltip, > .db-tooltip) {
position: relative;
}
bruno-sch marked this conversation as resolved.
Show resolved Hide resolved

$popover-states: "hover", "focus";
@each $state in $popover-states {
@include show-popover($state);
}
17 changes: 17 additions & 0 deletions packages/components/src/styles/component-animations.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Use this file to add transitions for db-components.
Adds color and border transitions for a smooth experience.
*/

@use "@db-ui/foundations/build/scss/animation";

// transitions
[class^="db-"],
[class^="db-"] * {
@extend %default-transition;

::before,
::after {
@extend %default-transition;
}
}
nmerget marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions packages/components/src/styles/db-ui-42.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/* This is a predefined beginner friendly bundle with default asset-paths (../assets) */

@forward "./db-ui-components";
// Bundle default theme
@forward "@db-ui/foundations/build/css/default-theme";

// Bundle optionals
@forward "@db-ui/foundations/build/scss/icons/include";
@forward "@db-ui/foundations/build/scss/helpers/classes/all";
@forward "@db-ui/foundations/build/scss/density/classes/all";
@forward "@db-ui/foundations/build/scss/fonts/classes/all";
@forward "@db-ui/foundations/build/scss/colors/classes/all";
28 changes: 1 addition & 27 deletions packages/components/src/styles/db-ui-components.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@forward "@db-ui/foundations/build/scss/db-ui-foundations";
@forward "component-animations";
@forward "../components/button/button";
@forward "../components/icon/icon";
@forward "../components/tab-item/tab-item";
Expand All @@ -25,7 +26,6 @@
@forward "../components/navigation/navigation";
@forward "../components/popover/popover";
@forward "../components/tooltip/tooltip";
@forward "dialog-init";
@forward "../components/tab-item/tab-item";
@forward "../components/tab-list/tab-list";
@forward "../components/tabs/tabs";
Expand Down Expand Up @@ -108,29 +108,3 @@ db-notification,
dbnotification {
inline-size: inherit;
}

:has(> .db-badge[data-placement^="corner"]) {
position: relative;
}

@mixin show-tooltip($state) {
:has(
> :is(db-tooltip, dbtooltip) > .db-tooltip:not([data-open]),
> .db-tooltip:not([data-open])
) {
&:#{$state} {
.db-tooltip:first-of-type {
@extend %show-popover;
}
}
}
}

:has(> db-tooltip, > dbtooltip, > .db-tooltip) {
position: relative;
}

$popover-states: "hover", "focus";
@each $state in $popover-states {
@include show-tooltip($state);
}
43 changes: 43 additions & 0 deletions packages/components/test/import-styles/simple-button/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<!--<script type="module" src="./main.js"></script>-->
<link rel="stylesheet" href="test.css" />
nmerget marked this conversation as resolved.
Show resolved Hide resolved
</head>
<body>
<div style="display: flex">
<button class="db-button">Button</button>
<button class="db-button" data-icon="user">Icon Button</button>
<div class="db-input">
<label for="OVERWRITE_DEFAULT_ID">Label</label>
<input
aria-invalid="false"
id="OVERWRITE_DEFAULT_ID"
type="text"
placeholder=" "
aria-describedby=""
/>
(Default) Regular
<span
id="OVERWRITE_DEFAULT_ID-valid-message"
class="db-infotext"
data-semantic="successful"
data-size="small"
>
TODO: Add a validMessage
</span>
<span
id="OVERWRITE_DEFAULT_ID-invalid-message"
class="db-infotext"
data-semantic="critical"
data-size="small"
>
TODO: Add an invalidMessage
</span>
</div>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions packages/components/test/import-styles/simple-button/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// The theme contains all prop required for components like spacings, colors, ...
import '@db-ui/foundations/build/css/default-theme.css';
// The font include uses default font families based on your bundling paths (relative, absolute, webpack, rollup)
import '@db-ui/foundations/build/css/fonts/include-rollup.css';
// The required styles will normalize css and add focus and default font to body
import '@db-ui/foundations/build/css/init/required.css';
// The default root adds a default color space (neutral) and a density (regular)
import '@db-ui/foundations/build/css/init/default-root.css';

// Optional: Add animations / transitions for components
import '@db-ui/components/build/styles/component-animations.css';
// Optional: Add data-icon/data-icon-after to global attributes to enable icons for components
import '@db-ui/foundations/build/css/icons/include-rollup.css';

// Optional: Add components
import '@db-ui/components/build/components/button/button.css';
import '@db-ui/components/build/components/input/input.css';
15 changes: 15 additions & 0 deletions packages/components/test/import-styles/simple-button/test.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* The theme contains all prop required for components like spacings, colors, ... */
@import "@db-ui/foundations/build/css/default-theme.css";
/* The font include uses default font families based on your bundling paths (relative, absolute, webpack, rollup) */
@import "@db-ui/foundations/build/css/fonts/include-rollup.css";
/* The required styles will normalize css and add focus and default font to body */
@import "@db-ui/foundations/build/css/init/required.css";
/* The default root adds a default color space (neutral) and a density (regular) */
@import "@db-ui/foundations/build/css/init/default-root.css";
/* Optional: Add animations / transitions for components */
@import "@db-ui/components/build/styles/component-animations.css";
/* Optional: Add data-icon/data-icon-after to global attributes to enable icons for components */
@import "@db-ui/foundations/build/css/icons/include-rollup.css";
/* Optional: Add components */
@import "@db-ui/components/build/components/button/button.css";
@import "@db-ui/components/build/components/input/input.css";
Loading
Loading