npm.io
16.0.1 • Published 2 months ago

@maggioli-design-system/styles

Licence
ISC
Version
16.0.1
Deps
6
Size
261 kB
Vulns
0
Weekly
0

@maggioli-design-system/styles

These are the CSS and Tailwind styles used by components libraries of Magma Design System to use the palette generated by @maggioli-design-system/design-tokens.


Compatibility

Use the version of this package matching the major version of @maggioli-design-system/magma you are using:

magma design-tokens styles
1.x (before Magma 2) 13.x (latest 13.7.2) 15.x (latest 15.11.1)
2.x and later >= 14 >= 16

Installation

Install the component via npm by running the following command:

npm i @maggioli-design-system/styles

Integration

The layer order is thinked to be used with tailwindcss, so the first layer is the reset, then the vendor, then the theme, then the base, then the components, and finally the utilities.

@layer reset, vendor, theme, base, components, utilities, overrides;

@import 'normalize.css' layer(reset);
@import '@fontsource/karla/400.css' layer(vendor);
@import '@fontsource/karla/700.css' layer(vendor);
@import '@fontsource/merriweather/300.css' layer(vendor);
@import '@fontsource/merriweather/400.css' layer(vendor);
@import '@fontsource/merriweather/700.css' layer(vendor);
@import '@fontsource/roboto-mono/400.css' layer(vendor);
@import '@fontsource/roboto/500.css' layer(vendor);
@import '@fontsource/roboto/700.css' layer(vendor);
@import '@fontsource/roboto/900.css' layer(vendor);
@import './iconsauce.css' layer(vendor);
@import '@maggioli-design-system/styles/dist/css/reset.css' layer(reset);
@import '@maggioli-design-system/styles/dist/css/globals.css' layer(theme);
@import '@maggioli-design-system/styles/dist/css/colors-rgb.css' layer(theme);
@import '@maggioli-design-system/styles/dist/css/hydrated.css' layer(base);
@import '@maggioli-design-system/styles/dist/css/animations.css' layer(base);
@import '@maggioli-design-system/styles/dist/css/base.css' layer(base);
@import './tailwind.css';

@layer overrides {
  body {
    @apply
    bg-tone-neutral
    text-tone-neutral-03
      transition-colors
      duration-300
      ease-in-out;
  }

  mds-button {
    border-radius: var(--radius-2xl);
  }
}
Imports
Colors with tailwind or web components

If you use tailwind or web components, you need to import rgb format of colors:

import '@maggioli-design-system/styles/dist/css/colors-rgb-tones.css';
import '@maggioli-design-system/styles/dist/css/colors-rgb-status.css';
import '@maggioli-design-system/styles/dist/css/colors-rgb-label.css';
import '@maggioli-design-system/styles/dist/css/colors-rgb-brand.css';

You need to import colors because web components and our tailwind config works with our palette, which are custom properties in rgb format (rr, gg, bb).

If for some reason you need to use colors outside tailwind:

.selector {
  color: rgb(var(--tone-neutral-01));
}
Hex colors

If you need just the hex format of colors, you can import them like this:

import '@maggioli-design-system/styles/dist/css/colors-hex-tones.css';
import '@maggioli-design-system/styles/dist/css/colors-hex-status.css';
import '@maggioli-design-system/styles/dist/css/colors-hex-label.css';
import '@maggioli-design-system/styles/dist/css/colors-hex-brand.css';

Then you can use them like this:

.selector {
  color: var(--tone-neutral-01);
}

Dark mode format

our color palette already supports dark mode, either according to your computer settings, or with manual support:

Manual mode

Just add the dark-mode class to the html tag:

<html class="dark-mode">
OS settings mode

Just add the system-mode class to the html tag:

<html class="system-mode">

There are other practices to handle dark mode, check how tailwind handle dark mode, or how is handled by next-themes.


Tailwindcss config

You can use styles with tailwindcss config, palette colors and the rest of it's Design Tokens. There are various ways to use it, check out tailwindcss documentation.

To extend the default tailwind config:

module.exports = {
  content: [
    './src/**/*.{ts,tsx}',
  ],
  important: false,
  presets: [
    require('@maggioli-design-system/styles'),
  ],
}

Fonts

Use @fontsource fonts, which are up to date with Google fonts, styles used in Magma Design System are:

TypeScript

Importing fonts in TypeScript:


```ts
import '@fontsource/karla/400.css'
import '@fontsource/karla/700.css'
import '@fontsource/merriweather/400.css'
import '@fontsource/merriweather/700.css'
import '@fontsource/roboto-mono/400.css'
import '@fontsource/roboto/500.css'
import '@fontsource/roboto/700.css'
import '@fontsource/roboto/900.css'
CSS

Importing fonts in CSS:

@import '@fontsource/karla/400.css';
@import '@fontsource/karla/700.css';
@import '@fontsource/merriweather/400.css';
@import '@fontsource/merriweather/700.css';
@import '@fontsource/roboto-mono/400.css';
@import '@fontsource/roboto/500.css';
@import '@fontsource/roboto/700.css';
@import '@fontsource/roboto/900.css';

Fontsource supports variable fonts.


Dist folder

The dist folder contains the following files:

Folder For File name
css both globals.css
css both reset.css
css plain css base.css
css plain css colors-hex-*.css
css plain css utility-typography.css
css plain css typography.css
css tailwind or web components colors-rgb-*.css
tailwind tailwind base.css
tailwind tailwind components components.css

Keywords