Skip to content

Commit

Permalink
[Feature] Box 컴포넌트 구현 (#45)
Browse files Browse the repository at this point in the history
* feature: Box 컴포넌트 기본 세팅

* feature: RightIcon 추가

* feature: storybook세팅

* fix: RightArrow 절대경로 수정

* fix: 파이프라인 이름 수정

* fix: panda config 수정

* fix: turbo 버전 조정

* fix: 상태관리 설정

* fix: 스토리북 수정

* fix: 스토리북 에러 수정

* fix: storybook 문서화 추가

* fix: 제네릭을 이용한 타입 정의

* fix: p5 코드리뷰

* fix: 제네릭 타입 깔끔하게 수정

* fix: 코드리뷰 반영

* fix: 터보레포 버전 변경

* fix: 파이프라인 수정

* fix: box props 네이밍 변경
  • Loading branch information
eugene028 authored Jun 23, 2024
1 parent 46a01f9 commit 08934fa
Show file tree
Hide file tree
Showing 23 changed files with 645 additions and 63 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = {
"plugin:import/typescript",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"eslint-config-turbo",
],
plugins: [
"@typescript-eslint/eslint-plugin",
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ yarn-error.log*
.DS_Store
*.pem

#bundle
stats.html

## Panda
styled-system-studio

Expand Down
1 change: 1 addition & 0 deletions apps/wow-docs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Home = () => {
<Checkbox />
<Chip label="Chip" />
<Switch />

<RadioGroup defaultValue="1학년" name="학년">
<RadioButton label="1학년" value="1학년" />
<RadioButton label="2학년" value="2학년" />
Expand Down
1 change: 1 addition & 0 deletions apps/wow-docs/panda.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "@pandacss/dev";
import { semanticTokens, textStyles, tokens } from "theme";

import { removeUnusedCssVars, removeUnusedKeyframes } from "theme/utils";

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion apps/wow-docs/styled-system/tokens/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ const tokens = {
variable: "var(--colors-outline)",
},
"colors.textBlack": {
value: "#000000",
value: "#121212",
variable: "var(--colors-text-black)",
},
"colors.textWhite": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"rollup-jest": "^3.1.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-preserve-directives": "^0.4.0",
"rollup-plugin-visualizer": "^5.12.0",
"shared-config": "workspace:^",
"theme": "workspace:^",
"ts-jest": "^29.1.2",
Expand Down
43 changes: 43 additions & 0 deletions packages/scripts/generateTokenList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { promises as fs } from "fs";

const TOKEN_DIR = "../wow-tokens/src/color.ts";
const outputFile = "../theme/src/config/colorTokenList.ts";

const extractTokenName = async (filePath: string): Promise<string[]> => {
try {
const data = await fs.readFile(filePath, "utf-8");
const regex = /export const (\w+) =/g;
const matches = data.match(regex);

if (!matches) {
throw new Error("Token file does not found");
}

const tokenNames = matches.map((match) => {
let tokenName = match.replace(/export const (\w+) =/, "$1").trim();

tokenName = tokenName.replace(/([a-zA-Z])([0-9])/g, "$1.$2");

return tokenName;
});

return tokenNames;
} catch (error) {
console.error("Error extracting or saving variable names:", error);
return [];
}
};

const generateColorTokenFiles = async (tokenNames: string[]) => {
const colorTokenContent = `export const colorTokenList = ${JSON.stringify(tokenNames, null, 2)}`;
await fs.writeFile(outputFile, colorTokenContent, "utf-8");
};

(async () => {
try {
const tokenNames = await extractTokenName(TOKEN_DIR);
await generateColorTokenFiles(tokenNames);
} catch (error) {
console.log("Error generating TokenList:", error);
}
})();
3 changes: 2 additions & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"exports": {
".": "./src/tokens/index.ts",
"./utils": "./src/utils/index.ts",
"./types": "./src/types/index.ts"
"./types": "./src/types/index.ts",
"./config": "./src/config/index.ts"
},
"devDependencies": {
"@pandacss/dev": "^0.39.0"
Expand Down
108 changes: 108 additions & 0 deletions packages/theme/src/config/colorTokenList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
export const colorTokenList = [
"blue.50",
"blue.100",
"blue.150",
"blue.200",
"blue.300",
"blue.400",
"blue.500",
"blue.600",
"blue.700",
"blue.800",
"blue.850",
"blue.900",
"blue.950",
"yellow.50",
"yellow.100",
"yellow.150",
"yellow.200",
"yellow.300",
"yellow.400",
"yellow.500",
"yellow.600",
"yellow.700",
"yellow.800",
"yellow.850",
"yellow.900",
"yellow.950",
"green.50",
"green.100",
"green.150",
"green.200",
"green.300",
"green.400",
"green.500",
"green.600",
"green.700",
"green.800",
"green.850",
"green.900",
"green.950",
"red.50",
"red.100",
"red.150",
"red.200",
"red.300",
"red.400",
"red.500",
"red.600",
"red.700",
"red.800",
"red.850",
"red.900",
"red.950",
"mono.50",
"mono.100",
"mono.150",
"mono.200",
"mono.300",
"mono.400",
"mono.500",
"mono.600",
"mono.700",
"mono.800",
"mono.850",
"mono.900",
"mono.950",
"white",
"black",
"whiteOpacity.20",
"whiteOpacity.40",
"whiteOpacity.60",
"whiteOpacity.80",
"blackOpacity.20",
"blackOpacity.40",
"blackOpacity.60",
"blackOpacity.80",
"primary",
"success",
"error",
"backgroundNormal",
"backgroundAlternative",
"backgroundDimmer",
"sub",
"outline",
"textBlack",
"textWhite",
"darkDisabled",
"lightDisabled",
"blueHover",
"monoHover",
"elevatedHover",
"bluePressed",
"blueBackgroundPressed",
"monoBackgroundPressed",
"shadowSmall",
"shadowMedium",
"blueShadow",
"discord",
"github",
"blueGradientDark",
"blueGradientLight",
"redGradientDark",
"redGradientLight",
"greenGradientDark",
"greenGradientLight",
"yellowGradientDark",
"yellowGradientLight",
];
1 change: 1 addition & 0 deletions packages/theme/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./colorTokenList.ts";
42 changes: 42 additions & 0 deletions packages/wow-icons/src/component/RightArrow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { forwardRef } from "react";
import { color } from "wowds-tokens";

import type { IconProps } from "@/types/Icon.ts";

const RightArrow = forwardRef<SVGSVGElement, IconProps>(
(
{
className,
width = "20",
height = "21",
viewBox = "0 0 20 21",
stroke = "white",
...rest
},
ref
) => {
return (
<svg
aria-label="rightArrow icon"
className={className}
fill="none"
height={height}
ref={ref}
viewBox={viewBox}
width={width}
xmlns="http://www.w3.org/2000/svg"
{...rest}
>
<path
d="M10 4.5L15 10.5L10 16.5"
stroke={color[stroke]}
strokeLinejoin="bevel"
strokeWidth="1.4"
/>
</svg>
);
}
);

RightArrow.displayName = "RightArrow";
export default RightArrow;
1 change: 1 addition & 0 deletions packages/wow-icons/src/component/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as Check } from "./Check.tsx";
export { default as RightArrow } from "./RightArrow.tsx";
3 changes: 3 additions & 0 deletions packages/wow-icons/src/svg/rightArrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion packages/wow-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
}
},
"scripts": {
"build": "rm -rf dist && rollup -c --bundleConfigAsCjs && tsc --emitDeclarationOnly"
"build": "pnpm generate:staticCSS && rm -rf dist && rollup -c --bundleConfigAsCjs && tsc --emitDeclarationOnly",
"generate:staticCSS": "tsx ../scripts/generateTokenList.ts"
},
"keywords": [],
"author": "gdsc-hongik",
Expand Down
2 changes: 1 addition & 1 deletion packages/wow-tokens/src/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const backgroundDimmer = blackOpacity80;

export const sub = mono700;
export const outline = mono400;
export const textBlack = black;
export const textBlack = mono950;
export const textWhite = white;

export const darkDisabled = mono400;
Expand Down
10 changes: 10 additions & 0 deletions packages/wow-ui/panda.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig, defineGlobalStyles } from "@pandacss/dev";
import { semanticTokens, textStyles, tokens, breakpoints } from "theme";
import { colorTokenList } from "theme/config";
import { removeUnusedCssVars, removeUnusedKeyframes } from "theme/utils";

const globalCss = defineGlobalStyles({
Expand All @@ -10,6 +11,15 @@ const globalCss = defineGlobalStyles({
});

export default defineConfig({
staticCss: {
css: [
{
properties: {
color: colorTokenList,
},
},
],
},
globalCss,
preflight: true,
minify: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/wow-ui/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import peerDepsExternal from "rollup-plugin-peer-deps-external";
import typescript from "@rollup/plugin-typescript";
import { fileURLToPath } from "url";
import preserveDirectives from "rollup-plugin-preserve-directives";
import { visualizer } from "rollup-plugin-visualizer";

const extensions = [".tsx", ".ts", ".js", ".jsx"];

Expand Down Expand Up @@ -76,6 +77,7 @@ export default {
terser(),
json(),
preserveDirectives.default(),
visualizer(),
],
onwarn: (warning) => {
if (warning.code !== "MODULE_LEVEL_DIRECTIVE") {
Expand Down
19 changes: 0 additions & 19 deletions packages/wow-ui/src/components/Box/Box.stories.ts

This file was deleted.

Loading

0 comments on commit 08934fa

Please sign in to comment.