0.1.0-beta.0 โ€ข Published 6 months ago

@afordin/unocss-preset-token v0.1.0-beta.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

unocss-preset-token npm

Preset to convert data from Design Token Plugin to Figma in theme to UnoCSS

๐Ÿš€ Usage

  • PNPM
pnpm i -D @afordin/unocss-preset-token
  • NPM
npm i -D @afordin/unocss-preset-token
  • Yarn
yarn add -D @afordin/unocss-preset-token

// unocss.config.js
import { defineConfig } from 'unocss';
import presetToken from '@afordin/unocss-preset-token';

export default defineConfig({
  presets: [
    presetToken({
      divider: '-',
      tokens: {},
    }),
  ],
});
export interface PresetTokenOptions {
  /**
   * Separation character for classes
   */
  divider?: '-' | '_' | '.';

  /**
   * Design Tokens Information
   */
  tokens: Record<string, any>;
}

divider

The character to separate naming class, default is -

// Tokens information
{
  "color": {
    "primary": {
      "description": "Primary color",
      "type": "color",
      "value": "#ff7a5cff",
      "blendMode": "normal"
    }
  }
}

The class naming in theme with divider default, color-primary

<div class="bg-color-primary" />

tokens

The token structure is based on the Figma Design Token plugin.

Theme tokens are based on the types of tokens handled by the plugin

// Tokens information
{
  "color": {
    "primary": {
      "description": "Primary color",
      "type": "color",
      "value": "#ff7a5cff",
      "blendMode": "normal"
    }
  },
  "secondary": {
    "description": "Secondary color",
    "type": "color",
    "value": "#ffc9d9ff",
    "blendMode": "normal"
  }
}

The classes naming in theme with divider default, color-primary and secondary

<div class="bg-color-primary" />
<div class="bg-secondary" />

๐Ÿคนโ€โ™‚๏ธ Playground

You can validate your token information in the playground

License

MIT License ยฉ 2023 jp

0.1.0-beta.0

6 months ago

0.0.6

6 months ago