Code Monkey home page Code Monkey logo

pandabox's Introduction

@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:

  • in any Panda function like css({ ... }) or stack({ ... })
  • in the css prop of any JSX component
  • etc...

Installation

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

@pandabox/panda-plugins

  • missing-css-warnings - Logs a warning message when a CSS rule was used at runtime but couldn't be statically extracted
  • strict-tokens-scope - Enforce strictTokens only for a set of TokenCategory or style props
  • strict-tokens-runtime - Enforce strictTokens at runtime, optionally scope this behaviour to a set of TokenCategory or style props
    • restrict-styled-props - Adds a props on the styled JSX Factory to restrict the props that can be passed to the component
  • remove-negative-spacing - Removes negative spacing tokens
  • remove-features - Removes features from the styled-system
  • minimal-setup - Removes the built-in presets and allow removing features from the styled-system

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

  • assignInlineVars is like the one from vanilla-extract but type-safe with typings using your own panda.config tokens
  • cssVar allows creating creating css vars as JS objects so you can reference them in your panda config or at runtime
  • wrapValue will wrap every objects inside the first argument with a { value: xxx }, mostly meant to easily migrate from a chakra theme tokens object to a panda.config tokens object

@pandabox/postcss-plugins

pnpm i @pandabox/postcss-plugins
  • removeUnusedCssVars
  • removeUnusedKeyframes

@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:

  • extend: add additional variants to or override variants of a recipe.
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

pandabox's People

Contributors

astahmer avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pandabox's Issues

Question on usage: @pandabox/define-theme

Hello!

I just wanted to make sure I understand the usage around the defineTheme and its purpose. It's not to help define the config but add stricter typing to the theme?

I'm unsure what to do with const config = theme.build() once that's run. Do I use config in the defineConfig settings? It seems I still need to update the defineConfig function as if I'm not using pandabox at all.

Code examples below:

define-theme.ts file

import { defineTheme } from '@pandabox/define-theme';
import pandaBase from '@pandacss/preset-base';
import { externalTokenObj, externalSemanticTokenObj, externalTextStylesObj } from '@external/tokens'

const { conditions, utilities } = pandaBase;

const t = defineTheme();

export const LegacyTheme = t
  .conditions(conditions)
  .tokens(externalTokenObj)
  .semanticTokens(externalSemanticTokenObj)
  .textStyles(externalTextStylesObj)
  .utilities(utilities);

preset.ts file

import { definePreset, defineSemanticTokens, defineTextStyles, defineTokens } from '@pandacss/dev';
import pandaBase from '@pandacss/preset-base';

import { externalTokenObj, externalSemanticTokenObj, externalTextStylesObj } from '@external/tokens'

const { conditions, utilities } = pandaBase;

export const ConstellationLegacyPreset = async () => {
  return definePreset({
    conditions,
    utilities,
    theme: {
      tokens: defineTokens(externalTokenObj),
      semanticTokens: defineSemanticTokens(externalSemanticTokenObj),
      textStyles: defineTextStyles(externalTextStylesObj),
    },
  });
};

Thanks for all you for the Panda CSS community!

Macro converts unrelated components

I made a small reproduction here: https://github.com/astahmer/pandabox/compare/main...nucleartux:pandabox:repro?expand=1
image
From the code, you can see that I don't import Stack from anywhere. However, for some reason, the Panda macro converts Stack to its own component (first div in the screenshot). If I rename Stack to Stack2, everything works as expected (second div in the screenshot).
Is this the expected behavior? I have many components in my project with conflicting names (like Stack, Container, Circle), which should not be changed in any way by Panda.

"@pandabox/unplugin/vite" does not work in "solid-start"

I'm not sure if this is related to the fact that Solid uses its own Babel plugin to transform JSX, but in solid-start, macros are not generating anything for the utilities layer, and the class in JSX is not being rewritten by the macro.

app.config.ts

export default defineConfig({
  middleware: './src/middleware.ts',
  server: {
    preset: 'cloudflare-module',
  },
  vite: {
    plugins: [
      panda({
        optimizeCss: !isDev,
        // output: isDev ? 'atomic' : 'grouped',
        output: 'grouped',
      }),
    ],
  },
})

app.tsx

import 'virtual:panda.css'

Request for deny list when using pluginStrictTokensScope

I want to set up deny list when I set up categories in pluginStrictTokensScope.

example.

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

export default defineConfig({
  // ...
  strictTokens: true,
  // can also be used together with
  // strictPropertyValues: true,
  //
  plugins: [
    pluginStrictTokensScope({ excludeCategories: ['colors', 'spacing'] }),
  ],
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.