-
Notifications
You must be signed in to change notification settings - Fork 29
Add panda-css option #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
isBatak
wants to merge
1
commit into
akd-io:develop
Choose a base branch
from
isBatak:feature/pandacss
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add panda-css option #265
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/create-next-stack/src/main/plugins/panda-css/add-content/pages/generate-index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import endent from "endent" | ||
| import { ValidCNSInputs } from "../../../../create-next-stack-types" | ||
| import { getProjectNameOfPath } from "../../../../helpers/get-project-name-of-path" | ||
|
|
||
| export const generateIndexPage = ({ args }: ValidCNSInputs): string => endent` | ||
| import { NextPage } from "next"; | ||
| import Head from "next/head"; | ||
| import { css } from '../../styled-system/css'; | ||
|
|
||
| const Index: NextPage = () => { | ||
| return ( | ||
| <> | ||
| <Head> | ||
| <title>${getProjectNameOfPath(args.app_name)}</title> | ||
| <meta name="description" content="Generated by Create Next Stack." /> | ||
| </Head> | ||
| <div className={css({ fontSize: "2xl", fontWeight: 'bold' })}>Hello 🐼!</div> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default Index; | ||
| ` |
121 changes: 121 additions & 0 deletions
121
packages/create-next-stack/src/main/plugins/panda-css/panda-css.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| import endent from "endent" | ||
| import { makeDirectory, writeFile } from "../../helpers/io" | ||
| import { createPlugin } from "../../plugin" | ||
| import { generateIndexPage } from "./add-content/pages/generate-index" | ||
|
|
||
| export const pandaCSSPlugin = createPlugin({ | ||
| id: "panda-css", | ||
| name: "Panda CSS", | ||
| description: "Adds support for Panda CSS", | ||
| active: ({ flags }) => flags["styling"] === "panda-css", | ||
| devDependencies: { | ||
| pandacss: { | ||
| name: "@pandacss/dev", | ||
| version: "^0.x.x", | ||
| }, | ||
| autoprefixer: { | ||
| name: "autoprefixer", | ||
| version: "^10.0.0", | ||
| }, | ||
| postcss: { | ||
| name: "postcss", | ||
| version: "^8.0.0", | ||
| }, | ||
| }, | ||
| technologies: [ | ||
| { | ||
| id: "pandaCSS", | ||
| name: "Panda CSS", | ||
| description: | ||
| "🐼 Universal, Type-Safe, CSS-in-JS Framework for Product Teams ⚡️", | ||
| links: [ | ||
| { title: "Website", url: "https://panda-css.com" }, | ||
| { title: "Docs", url: "https://panda-css.com/docs" }, | ||
| { title: "GitHub", url: "https://github.com/chakra-ui/panda" }, | ||
| ], | ||
| }, | ||
| ], | ||
| steps: { | ||
| setUpPandaCss: { | ||
| id: "setUpPandaCss", | ||
| description: "setting up panda CSS", | ||
| run: async () => { | ||
| await Promise.all([ | ||
| addPandaConfig(), | ||
| addPostcssConfig(), | ||
| addStylesGlobalsCss(), | ||
| ]) | ||
| }, | ||
| }, | ||
| addContent: { | ||
| id: "addContent", | ||
| description: "adding content", | ||
| run: async (inputs) => { | ||
| await Promise.all([ | ||
| writeFile("pages/index.tsx", generateIndexPage(inputs)), | ||
| ]) | ||
| }, | ||
| }, | ||
| }, | ||
| scripts: [ | ||
| { | ||
| name: "prepare", | ||
| description: "Run panda codegen after dependencies are installed", | ||
| command: "panda codegen", | ||
| }, | ||
| ], | ||
| slots: { | ||
| app: { | ||
| imports: `import "../styles/globals.css";`, | ||
| }, | ||
| }, | ||
| } as const) | ||
|
|
||
| const addPandaConfig = async () => { | ||
| // From running `npx panda init --postcss` and adding globs to the include array according to https://panda-css.com/docs/installation/nextjs?value=pages-dir#configure-the-content | ||
| const pandaConfigString = endent` | ||
| import { defineConfig } from "@pandacss/dev"; | ||
|
|
||
| export default defineConfig({ | ||
| // Whether to use css reset | ||
| preflight: true, | ||
|
|
||
| // Where to look for your css declarations | ||
| include: ["./src/**/*.{js,jsx,ts,tsx}", "./pages/**/*.{js,jsx,ts,tsx}"], | ||
|
|
||
| // Files to exclude | ||
| exclude: [], | ||
|
|
||
| // Useful for theme customization | ||
| theme: { | ||
| extend: {}, | ||
| }, | ||
|
|
||
| // The output directory for your css system | ||
| outdir: "styled-system", | ||
| }); | ||
| ` | ||
| await writeFile("panda.config.ts", pandaConfigString) | ||
| } | ||
|
|
||
| const addPostcssConfig = async () => { | ||
| // From https://panda-css.com/docs/installation/nextjs?value=pages-dir#install-panda-css | ||
| const postcssConfigString = endent` | ||
| module.exports = { | ||
| plugins: { | ||
| '@pandacss/dev/postcss': {}, | ||
| autoprefixer: {}, | ||
| }, | ||
| } | ||
| ` | ||
| await writeFile("postcss.config.js", postcssConfigString) | ||
| } | ||
|
|
||
| const addStylesGlobalsCss = async () => { | ||
| // From https://panda-css.com/docs/installation/nextjs?value=pages-dir#configure-the-entry-css-with-layers | ||
| const stylesGlobalsCssString = endent` | ||
| @layer reset, base, tokens, recipes, utilities; | ||
| ` | ||
| await makeDirectory("styles") | ||
| await writeFile("styles/globals.css", stylesGlobalsCssString) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/create-next-stack/src/tests/e2e/tests/panda-css/panda-css-all-flags.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { test } from "@jest/globals" | ||
| import { testArgsWithFinalChecks } from "../../helpers/test-args" | ||
| import { twentyMinutes } from "../../helpers/timeout" | ||
|
|
||
| test( | ||
| "testPandaCssAllFlags", | ||
| async () => { | ||
| await testArgsWithFinalChecks([ | ||
| "--debug", | ||
| "--package-manager=pnpm", | ||
| "--prettier", | ||
| "--styling=panda-css", | ||
| "--react-hook-form", | ||
| "--formik", | ||
| "--framer-motion", | ||
| "--formatting-pre-commit-hook", | ||
| "--react-icons", | ||
| "--react-query", | ||
| "--plausible", | ||
| "--vercel", | ||
| "--netlify", | ||
| ".", | ||
| ]) | ||
| }, | ||
| twentyMinutes | ||
| ) |
16 changes: 16 additions & 0 deletions
16
packages/create-next-stack/src/tests/e2e/tests/panda-css/panda-css-only.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { test } from "@jest/globals" | ||
| import { testArgsWithFinalChecks } from "../../helpers/test-args" | ||
| import { twentyMinutes } from "../../helpers/timeout" | ||
|
|
||
| test( | ||
| "testPandaCssOnly", | ||
| async () => { | ||
| await testArgsWithFinalChecks([ | ||
| "--debug", | ||
| "--package-manager=pnpm", | ||
| "--styling=panda-css", | ||
| ".", | ||
| ]) | ||
| }, | ||
| twentyMinutes | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akd-io
As it seems this part will not overwrite the original
pages/index.tsx. I guess this part is executed beforecreateNextStackPlugin.But here it noted that steps run form top to bottom
create-next-stack/CONTRIBUTING.md
Line 99 in b0aa3ae