taishinaritomi / kaze-style

Kaze [風] zero-runtime CSS in JS
https://npmjs.com/package/@kaze-style/core
MIT License
25 stars 1 forks source link

Creating Palette API as a Design System Manager #138

Open taishinaritomi opened 1 year ago

taishinaritomi commented 1 year ago

Still in the thinking stage 🧠

import { style, mergeStyle } from '@kaze-style/core';

import React from 'react';

// from https://cva.style/
// from https://vanilla-extract.style/documentation/api/style-variants/
// from https://stitches.dev/docs/variants

const palette = (..._) => (...__) => _[0];

const classes = style({
  $base: {
    display: 'flex',
  },
})

const className = palette({
  base: {
    display: 'flex',
  },
  color: {
    default: {
      color: 'black'
    },
    red: {
      color: 'red',
    },
    blue: {
      color: 'blue',
    },
  },
  space: {
    2: {
      margin: '10px',
      padding: '10px',
    },
    4: {
      margin: '10px',
      padding: '10px',
    },
  },
});

<div className={mergeStyle(classes.$base, className({ color: 'red', spase: 2 }))}></div>
taishinaritomi commented 1 year ago

reference https://github.com/taishinaritomi/kaze-style/issues/118#issuecomment-1430068333