astahmer / pandabox

a toolbox for Panda CSS
https://pandabox.vercel.app/
53 stars 4 forks source link
css panda pandacss recipes theme toolbox typesafe unplugin vite

@pandabox

This will be the home for utilities around Panda CSS.

@pandabox/prettier-plugin

Prettier plugin for Panda CSS.

Will sort style props based on your local panda.config.ts:

Installation

pnpm add -D prettier @pandabox/prettier-plugin
{
  "plugins": ["@pandabox/prettier-plugin"]
}

@pandabox/panda-plugins

Installation

pnpm add -D @pandabox/panda-plugins

Usage

import { defineConfig } from '@pandacss/dev'
import { pluginStrictTokensScope, pluginRemoveNegativeSpacing, pluginRemoveFeatures } from '@pandabox/panda-plugins'

export default defineConfig({
  // ...
  strictTokens: true,
  // can also be used together with
  // strictPropertyValues: true,
  //
  plugins: [
    pluginStrictTokensScope({ categories: ['colors', 'spacing'] }),
    pluginRemoveFeatures({ features: ['no-jsx', 'no-cva'] }),
    pluginRemoveNegativeSpacing({ spacingTokenType: true, tokenType: true }),
  ],
})

@pandabox/unplugin

Alternative distribution entrypoint for Panda CSS (other than the CLI and PostCSS plugin).

Optionally inline your styled-system functions and components results as class names (atomic or grouped) (with optimizeJs option).

pnpm i @pandabox/unplugin

Usage

import { defineConfig } from 'vite'
import pandabox from '@pandabox/unplugin'

export default defineConfig({
  plugins: [
    pandabox.vite({
      /* options */
    }),
  ],
})

optimizeJs option

From:

import { css } from '../styled-system/css'

export const App = () => {
  return (
    <>
      <div
        className={css({
          display: 'flex',
          flexDirection: 'column',
          fontWeight: 'semibold',
          color: 'green.300',
          textAlign: 'center',
          textStyle: '4xl',
        })}
      >
        <span>Hello from Panda</span>
      </div>
      <styled.div
        display="flex"
        flexDirection="column"
        fontWeight="semibold"
        color="green.300"
        textAlign="center"
        textStyle="4xl"
        onClick={() => console.log('hello')}
        unresolvable={something}
      >
        <span>Hello from Panda</span>
      </styled.div>
    </>
  )
}

To (atomic):

import { css } from '../styled-system/css'

export const App = () => {
  return (
    <>
      <div className={'d_flex flex_column font_semibold text_green.300 text_center textStyle_4xl'}>
        <span>Hello from Panda</span>
      </div>
      <div
        className="d_flex flex_column font_semibold text_green.300 text_center textStyle_4xl"
        onClick={() => console.log('hello')}
        unresolvable={something}
      >
        <span>Hello from Panda</span>
      </div>
    </>
  )
}

@pandabox/utils

@pandabox/postcss-plugins

pnpm i @pandabox/postcss-plugins

@pandabox/define-recipe

pnpm i @pandabox/define-recipe

The defineRecipe method will now return a RecipeBuilder object instead of a RecipeConfig object. The RecipeBuilder object has the following methods:

const button = defineRecipe({
  className: 'btn',
  variants: {
    variant: { primary: { color: 'red' } },
  },
}).extend({
  variant: {
    primary: { px: 2 },
    secondary: { color: 'blue' },
  },
})

resulting in:

{
  "className": "btn",
  "variants": {
    "variant": {
      "primary": { "color": "red", "px": 2 },
      "secondary": { "color": "blue" }
    }
  }
}

More methods are available on the RecipeBuilder object, see the README for more