Skip to content

Commit 65d951a

Browse files
authored
chore: add examples using npm versions of @pandabox/unplugin (#52)
* chore: pnpm create vite@latest --template=react-ts ./examples/unplugin * chore(examples): add @pandacss/dev + @pandabox/unplugin with outfile * chore: init pnpm create solid@latest * chore(examples): add @pandacss/dev + @pandabox/unplugin * chore(unplugin): change optimizeJs default value to "macro" + readmes update * fix(unplugin/vite): hmr + initial CSS when using outfile * fix: e2e test dir
1 parent f9c3c10 commit 65d951a

40 files changed

+3624
-329
lines changed

.changeset/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"access": "restricted",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
10-
"ignore": ["sandbox-*", "website"]
10+
"ignore": ["sandbox-*", "website", "example-*"]
1111
}

.changeset/five-camels-unite.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pandabox/unplugin": patch
3+
---
4+
5+
Change `optimizeJs` default value to `macro`

.npmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ignore-workspace-root-check=true
22
strict-peer-dependencies=false
33
auto-install-peers=true
44
#
5-
link-workspace-packages=true
5+
link-workspace-packages=false
66
prefer-workspace-packages=true
77
#
88
hoist-pattern[]=@arktype/attest

README.md

+30-10
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,35 @@ export default defineConfig({
6363
})
6464
```
6565

66-
# @pandabox/unplugin-panda-macro
66+
# @pandabox/unplugin
6767

68-
Directly inline your `styled-system` functions and components results as class names (`atomic` or `grouped`)
68+
Alternative distribution entrypoint for Panda CSS (other than the [CLI](https://panda-css.com/docs/installation/cli) and
69+
[PostCSS plugin](https://panda-css.com/docs/installation/postcss)).
70+
71+
Optionally inline your `styled-system` functions and components results as class names (`atomic` or `grouped`) (with
72+
`optimizeJs` option).
6973

7074
```bash
71-
pnpm i @pandabox/unplugin-panda-macro
75+
pnpm i @pandabox/unplugin
7276
```
7377

78+
## Usage
79+
80+
```ts
81+
import { defineConfig } from 'vite'
82+
import { unplugin } from '@pandabox/unplugin'
83+
84+
export default defineConfig({
85+
plugins: [
86+
unplugin.vite({
87+
/* options */
88+
}),
89+
],
90+
})
91+
```
92+
93+
## `optimizeJs` option
94+
7495
From:
7596

7697
```tsx
@@ -133,13 +154,12 @@ export const App = () => {
133154

134155
# @pandabox/utils
135156

136-
```bash
137-
pnpm i @pandabox/utils
138-
```
139-
140-
- `assignInlineVars`
141-
- `cssVar`
142-
- `wrapValue`
157+
- `assignInlineVars` is like
158+
[the one from vanilla-extract](https://vanilla-extract.style/documentation/packages/dynamic/#assigninlinevars) but
159+
type-safe with typings using your own panda.config tokens
160+
- `cssVar` allows creating creating css vars as JS objects so you can reference them in your panda config or at runtime
161+
- `wrapValue` will wrap every objects inside the first argument with a { value: xxx }, mostly meant to easily migrate
162+
from a chakra theme tokens object to a panda.config tokens object
143163

144164
# @pandabox/postcss-plugins
145165

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
dist
3+
.solid
4+
.output
5+
.vercel
6+
.netlify
7+
netlify
8+
.vinxi
9+
10+
# Environment
11+
.env
12+
.env*.local
13+
14+
# dependencies
15+
/node_modules
16+
17+
# IDEs and editors
18+
/.idea
19+
.project
20+
.classpath
21+
*.launch
22+
.settings/
23+
24+
# Temp
25+
gitignore
26+
27+
# System Files
28+
.DS_Store
29+
Thumbs.db
30+
31+
## Panda
32+
styled-system
33+
styled-system-studio
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SolidStart
2+
3+
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
4+
5+
## Creating a project
6+
7+
```bash
8+
# create a new project in the current directory
9+
npm init solid@latest
10+
11+
# create a new project in my-app
12+
npm init solid@latest my-app
13+
```
14+
15+
## Developing
16+
17+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
18+
19+
```bash
20+
npm run dev
21+
22+
# or start the server and open the app in a new browser tab
23+
npm run dev -- --open
24+
```
25+
26+
## Building
27+
28+
Solid apps are built with _presets_, which optimise your project for deployment to different environments.
29+
30+
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add it to the `devDependencies` in `package.json` and specify in your `app.config.js`.
31+
32+
## This project was created with the [Solid CLI](https://solid-cli.netlify.app)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { defineConfig } from '@solidjs/start/config'
2+
import pandabox from '@pandabox/unplugin'
3+
4+
const isDev = process.env.NODE_ENV === 'development'
5+
6+
export default defineConfig({
7+
// middleware: './src/middleware.ts',
8+
// server: {
9+
// preset: 'cloudflare-module',
10+
// },
11+
vite: {
12+
plugins: [
13+
pandabox.vite({
14+
optimizeCss: !isDev,
15+
}),
16+
],
17+
},
18+
})
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "example-basic",
3+
"type": "module",
4+
"scripts": {
5+
"dev": "vinxi dev",
6+
"build": "vinxi build",
7+
"start": "vinxi start",
8+
"version": "vinxi version"
9+
},
10+
"dependencies": {
11+
"@pandabox/unplugin": "0.1.2",
12+
"@pandacss/dev": "^0.36.1",
13+
"@solidjs/meta": "^0.29.2",
14+
"@solidjs/router": "^0.13.1",
15+
"@solidjs/start": "^1.0.0-rc.0",
16+
"solid-js": "^1.8.16",
17+
"vinxi": "^0.3.11"
18+
},
19+
"engines": {
20+
"node": ">=18"
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { defineConfig } from '@pandacss/dev'
2+
3+
export default defineConfig({
4+
// Whether to use css reset
5+
preflight: true,
6+
7+
// Where to look for your css declarations
8+
include: ['./src/**/*.{js,jsx,ts,tsx}', './{App,main,minimal}*.{js,jsx,ts,tsx}'],
9+
10+
// Files to exclude
11+
exclude: [],
12+
13+
// Useful for theme customization
14+
theme: {
15+
extend: {
16+
recipes: {
17+
button: {
18+
className: 'button',
19+
description: 'The styles for the Button component',
20+
base: {
21+
display: 'flex',
22+
cursor: 'pointer',
23+
fontWeight: 'bold',
24+
},
25+
variants: {
26+
visual: {
27+
funky: { bg: 'blue.200', color: 'slate.800' },
28+
edgy: { border: '1px solid {colors.red.500}' },
29+
},
30+
size: {
31+
sm: { padding: '4', fontSize: '12px' },
32+
lg: { padding: '8', fontSize: '40px' },
33+
},
34+
shape: {
35+
square: { borderRadius: '0' },
36+
circle: { borderRadius: 'full' },
37+
},
38+
},
39+
defaultVariants: {
40+
visual: 'funky',
41+
size: 'sm',
42+
shape: 'circle',
43+
},
44+
},
45+
},
46+
},
47+
},
48+
49+
// The output directory for your css system
50+
outdir: 'styled-system',
51+
52+
// The JSX framework to use
53+
jsxFramework: 'react',
54+
})
664 Bytes
Binary file not shown.
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
body {
2+
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
3+
}
4+
5+
a {
6+
margin-right: 1rem;
7+
}
8+
9+
main {
10+
text-align: center;
11+
padding: 1em;
12+
margin: 0 auto;
13+
}
14+
15+
h1 {
16+
color: #335d92;
17+
text-transform: uppercase;
18+
font-size: 4rem;
19+
font-weight: 100;
20+
line-height: 1.1;
21+
margin: 4rem auto;
22+
max-width: 14rem;
23+
}
24+
25+
p {
26+
max-width: 14rem;
27+
margin: 2rem auto;
28+
line-height: 1.35;
29+
}
30+
31+
@media (min-width: 480px) {
32+
h1 {
33+
max-width: none;
34+
}
35+
36+
p {
37+
max-width: none;
38+
}
39+
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { MetaProvider, Title } from "@solidjs/meta";
2+
import { Router } from "@solidjs/router";
3+
import { FileRoutes } from "@solidjs/start/router";
4+
import { Suspense } from "solid-js";
5+
import "./app.css";
6+
7+
export default function App() {
8+
return (
9+
<Router
10+
root={props => (
11+
<MetaProvider>
12+
<Title>SolidStart - Basic</Title>
13+
<a href="/">Index</a>
14+
<a href="/about">About</a>
15+
<Suspense>{props.children}</Suspense>
16+
</MetaProvider>
17+
)}
18+
>
19+
<FileRoutes />
20+
</Router>
21+
);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { css, cva } from '../../styled-system/css'
2+
import { center } from '../../styled-system/patterns'
3+
import { button } from '../../styled-system/recipes'
4+
import { Stack, styled } from '../../styled-system/jsx'
5+
// import 'virtual:panda.css'
6+
import './panda.css'
7+
8+
const overrides = css.raw({
9+
bg: 'purple.500',
10+
})
11+
12+
const atomicRecipe = cva({
13+
base: {
14+
display: 'flex',
15+
},
16+
variants: {
17+
visual: {
18+
solid: { bg: 'red.200', color: 'white' },
19+
outline: { borderWidth: '1px', borderColor: 'red.200' },
20+
},
21+
size: {
22+
sm: { padding: '4', fontSize: '12px' },
23+
lg: { padding: '8', fontSize: '24px' },
24+
},
25+
},
26+
})
27+
28+
console.log(atomicRecipe({ visual: 'outline' }))
29+
30+
export const App = () => {
31+
return (
32+
<div class={center({ h: 'full' })}>
33+
<div
34+
class={css(
35+
{
36+
textStyle: '4xl',
37+
display: 'flex',
38+
flexDirection: 'column',
39+
color: 'green.300',
40+
textAlign: 'center',
41+
fontWeight: 'semibold',
42+
},
43+
{
44+
color: 'red.500',
45+
bg: 'yellow.200',
46+
},
47+
overrides,
48+
)}
49+
>
50+
<Stack fontSize="2xl">
51+
<styled.div border="2px solid token(colors.red.300)">🐼</styled.div>
52+
<span>Hello from Panda</span>
53+
</Stack>
54+
</div>
55+
<div class={button({ size: 'lg', visual: 'funky' })}>Button</div>
56+
<div class={atomicRecipe({ visual: 'solid', size: 'sm' })}>Atomic Button</div>
57+
</div>
58+
)
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.increment {
2+
font-family: inherit;
3+
font-size: inherit;
4+
padding: 1em 2em;
5+
color: #335d92;
6+
background-color: rgba(68, 107, 158, 0.1);
7+
border-radius: 2em;
8+
border: 2px solid rgba(68, 107, 158, 0);
9+
outline: none;
10+
width: 200px;
11+
font-variant-numeric: tabular-nums;
12+
}
13+
14+
.increment:focus {
15+
border: 2px solid #335d92;
16+
}
17+
18+
.increment:active {
19+
background-color: rgba(68, 107, 158, 0.2);
20+
}

0 commit comments

Comments
 (0)