|
| 1 | +# @db-ui/foundations |
| 2 | + |
| 3 | +A library containing all tokens of [DB UX System](https://github.com/db-ui/mono). |
| 4 | + |
| 5 | +We currently support: |
| 6 | + |
| 7 | +- [CSS](#css) |
| 8 | +- [SCSS](#scss) |
| 9 | +- [Tailwind](#tailwind) |
| 10 | + |
| 11 | +## Install |
| 12 | + |
| 13 | +`npm i @db-ui/foundations` |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +### CSS |
| 18 | + |
| 19 | +```ts |
| 20 | +// main.ts / main.js |
| 21 | +import "@db-ui/foundations/build/db-ui-foundations.css"; |
| 22 | +// optional: to use classes like e.g. db-ui-bg-success |
| 23 | +import "@db-ui/foundations/build/color-classes.css"; |
| 24 | +``` |
| 25 | + |
| 26 | +```css |
| 27 | +.my-container { |
| 28 | + padding: var(--db-spacing-fixed-md); |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +```html |
| 33 | +<div class="db-ui-regular db-ui-bg-success my-container"></div> |
| 34 | +``` |
| 35 | + |
| 36 | +### SCSS |
| 37 | + |
| 38 | +Based on your technology/setup you need to change the paths of the assets folder: |
| 39 | + |
| 40 | +- Default: points to `../assets` |
| 41 | +- Webpack: points to `~@db-ui/foundations/assets` |
| 42 | +- Rollup: points to `@db-ui/foundations/assets` |
| 43 | +- |
| 44 | + |
| 45 | +```scss |
| 46 | +// index.scss |
| 47 | +@use "@db-ui/foundations/build/scss/rollup.assets-paths" as *; |
| 48 | +@use "@db-ui/foundations/build/scss/icon/icons" as *; |
| 49 | +@use "@db-ui/foundations/build/db-ui-foundations" as *; |
| 50 | +// optional: to use db-ui-bg-success |
| 51 | +@import "@db-ui/foundations/build/color-classes" as *; |
| 52 | +// optional: to use use $db-spacing-fixed-md |
| 53 | +@use "@db-ui/foundations/build/scss/variables.global" as *; |
| 54 | + |
| 55 | +.my-container { |
| 56 | + padding: $db-spacing-fixed-md; |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +```html |
| 61 | +<div class="db-ui-regular db-ui-bg-success my-container"></div> |
| 62 | +``` |
| 63 | + |
| 64 | +### Tailwind |
| 65 | + |
| 66 | +```javascript |
| 67 | +//tailwind.config.cjs |
| 68 | + |
| 69 | +const tokens = require("@db-ui/foundations/build/tailwind/tailwind-tokens.json"); |
| 70 | + |
| 71 | +module.exports = { |
| 72 | + content: ["./index.html", "./src/**/*.{js,jsx,ts,tsx}"], |
| 73 | + plugins: [], |
| 74 | + theme: { |
| 75 | + screens: tokens.screens, |
| 76 | + spacing: tokens.spacing, |
| 77 | + boxShadow: tokens.elevation, |
| 78 | + gap: ({ theme }) => ({ |
| 79 | + ...theme("spacing") |
| 80 | + }), |
| 81 | + space: ({ theme }) => ({ |
| 82 | + ...theme("spacing") |
| 83 | + }) |
| 84 | + } |
| 85 | +}; |
| 86 | +``` |
| 87 | + |
| 88 | +```html |
| 89 | +<div class="p-fix-md"></div> |
| 90 | +``` |
0 commit comments