Skip to content

Commit

Permalink
feat: test button with pandacss
Browse files Browse the repository at this point in the history
  • Loading branch information
lebmouse committed Jul 23, 2024
1 parent 1b585f1 commit 2011565
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 8 deletions.
119 changes: 113 additions & 6 deletions panda.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,127 @@
import { definePreset } from '@pandacss/dev';
import { defineConfig } from '@pandacss/dev';

const fontWeight = {
bold: 700,
semibold: 600,
medium: 500,
regular: 400,
};

const cdsPreset = definePreset({
name: 'cds',
theme: {
tokens: {
colors: {
main: {
black: { value: '#292929' },
yellow: { value: '#ffd464' },
},
grey: {
10: { value: '#363738' },
20: { value: '#515354' },
30: { value: '#737678' },
40: { value: '#aaacaf' },
50: { value: '#ced1d6' },
60: { value: '#e4e5e9' },
70: { value: '#f3f4f6' },
80: { value: '#f8f9fb' },
},
etc: {
white: { value: '#ffffff' },
focus: { value: '#3b79d7' },
active: {
30: { value: '#b10e1c' },
20: { value: '#fc685f' },
10: { value: '#ffe7e6' },
},
error: {
30: { value: '#037847' },
20: { value: '#14ba6d' },
10: { value: '#ecfdf3' },
},
},
},
},
textStyles: {
h1: {
description: 'heading1',
value: {
fontSize: '22px',
fontWeight: fontWeight.bold,
},
},
h2: {
description: 'heading2',
value: {
fontSize: '20px',
fontWeight: fontWeight.semibold,
},
},
b1: {
description: 'body1',
value: {
fontSize: '16px',
fontWeight: fontWeight.medium,
},
},
b2: {
description: 'body2',
value: {
fontSize: '14px',
fontWeight: fontWeight.regular,
},
},
b3: {
description: 'body3',
value: {
fontSize: '13px',
fontWeight: fontWeight.regular,
},
},
b4: {
description: 'body4',
value: {
fontSize: '12px',
fontWeight: fontWeight.semibold,
},
},
b5: {
description: 'body5',
value: {
fontSize: '12px',
fontWeight: fontWeight.regular,
},
},
b6: {
description: 'body6',
value: {
fontSize: '10px',
fontWeight: fontWeight.semibold,
},
},
b7: {
description: 'body7',
value: {
fontSize: '14px',
fontWeight: fontWeight.semibold,
},
},
},
},
});
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}'],
include: ['./src/**/*.{js,jsx,ts,tsx}'],

// Files to exclude
exclude: [],

// Useful for theme customization
theme: {
extend: {},
},
presets: [cdsPreset],

polyfill: true,
// The output directory for your css system
outdir: 'styled-system',
});
5 changes: 5 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import postCssPlugin from '@pandacss/dev/postcss';

export default {
plugins: [postCssPlugin()],
};
19 changes: 19 additions & 0 deletions src/component/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ReactNode } from 'react';
import { css } from '../../styled-system/css';

export interface IButtonProps {
children: ReactNode;
}

export const Button = ({ children }: IButtonProps) => {
return (
<button
className={css({
color: 'grey.20',
textStyle: 'b1',
})}
>
{children}
</button>
);
};
2 changes: 1 addition & 1 deletion src/component/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const component = 'component';
export { Button } from './button';
26 changes: 26 additions & 0 deletions src/component/pandabutton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { Meta, StoryObj } from '@storybook/react';
import { css } from '../../styled-system/css';

import { Button } from './button';

const meta = {
title: 'Example/Button',
component: Button,
tags: ['autodocs'],
decorators: [
Story => (
<div className={css({ m: 10 })}>
<Story />
</div>
),
],
} satisfies Meta<typeof Button>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
children: 'Hello2 🐼!',
},
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"experimentalDecorators": true,
"importHelpers": true
},
"include": ["src"],
"include": ["src", "styled-system"],
"exclude": ["**/dist/**, **/node_modules"],
"references": [{ "path": "./tsconfig.node.json" }]
}

0 comments on commit 2011565

Please sign in to comment.