Skip to content

Commit

Permalink
Feat: add ppoba-ui workspace (storybook setting) (#1)
Browse files Browse the repository at this point in the history
feat: add ppoba-ui workspace
  • Loading branch information
poiu694 authored Jun 3, 2023
1 parent b65f267 commit 75db69c
Show file tree
Hide file tree
Showing 19 changed files with 6,837 additions and 1,349 deletions.
23 changes: 19 additions & 4 deletions packages/service-frontend/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import Image from 'next/image';
import Image from 'next/image'
import { Button } from '@ppoba/ui'

export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="bg-green-500">TEST</div>
<Button className="bg-blue-500 ml-8">Button Test</Button>
<Button className="bg-red-500 p-3">Button Test</Button>
<p className="text-3xl font-bold underline text-orange-500">Text</p>
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
Expand All @@ -15,7 +20,15 @@ export default function Home() {
target="_blank"
rel="noopener noreferrer"
>
By <Image src="/vercel.svg" alt="Vercel Logo" className="dark:invert" width={100} height={24} priority />
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className="dark:invert"
width={100}
height={24}
priority
/>
</a>
</div>
</div>
Expand Down Expand Up @@ -78,7 +91,9 @@ export default function Home() {
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>Explore the Next.js 13 playground.</p>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Explore the Next.js 13 playground.
</p>
</a>

<a
Expand All @@ -99,5 +114,5 @@ export default function Home() {
</a>
</div>
</main>
);
)
}
3 changes: 2 additions & 1 deletion packages/service-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@ppoba/ui": "workspace:*",
"@ppoba/types": "workspace:*",
"@types/node": "^18.11.18",
"@types/react": "18.2.6",
Expand All @@ -29,4 +30,4 @@
"eslint-config-prettier": "^8.8.0",
"sst": "^2.8.27"
}
}
}
13 changes: 13 additions & 0 deletions packages/ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
env: {
browser: true,
es2020: true
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:storybook/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
exclude: ['./dist']
};
24 changes: 24 additions & 0 deletions packages/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
19 changes: 19 additions & 0 deletions packages/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-styling',
],
framework: {
name: '@storybook/react-vite',
options: {},
},
docs: {
autodocs: 'tag',
},
};
export default config;
17 changes: 17 additions & 0 deletions packages/ui/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Preview } from '@storybook/react';

import '../src/tailwind.css';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};

export default preview;
50 changes: 50 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@ppoba/ui",
"private": true,
"version": "0.0.0",
"main": "./src/index.ts",
"types": "./src/index.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc && vite build",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@storybook/addon-essentials": "^7.0.18",
"@storybook/addon-interactions": "^7.0.18",
"@storybook/addon-links": "^7.0.18",
"@storybook/addon-styling": "^1.0.8",
"@storybook/blocks": "^7.0.18",
"@storybook/react": "^7.0.18",
"@storybook/react-vite": "^7.0.18",
"@storybook/testing-library": "^0.0.14-next.2",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@vitejs/plugin-react": "^4.0.0",
"autoprefixer": "10.4.14",
"eslint": "^8.38.0",
"eslint-plugin-storybook": "^0.6.12",
"less": "^4.1.3",
"postcss": "8.4.23",
"prop-types": "^15.8.1",
"storybook": "^7.0.18",
"tailwindcss": "^3.3.2",
"typescript": "^5.0.2",
"vite": "^4.3.9",
"vite-plugin-dts": "^2.3.0",
"webpack": "^5.82.1"
},
"publishConfig": {
"access": "public"
}
}
6 changes: 6 additions & 0 deletions packages/ui/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
13 changes: 13 additions & 0 deletions packages/ui/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

type Props = React.ComponentPropsWithoutRef<'button'>;

function Button({ children, className = '', ...props }: React.PropsWithChildren<Props>): JSX.Element {
return (
<button type="button" className={className} {...props}>
{children}
</button>
);
}

export default Button;
1 change: 1 addition & 0 deletions packages/ui/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Button } from './Button';
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components';
22 changes: 22 additions & 0 deletions packages/ui/src/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Meta, StoryObj } from '@storybook/react';
import { Button } from '../components';

// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
const meta = {
title: 'Button',
component: Button,
tags: ['autodocs'],
args: {},
} satisfies Meta<typeof Button>;

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

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
export const BaseButton: Story = {
args: {
children: 'BaseButton',
className: 'bg-blue-500 p-3 text-white',
onClick: () => console.log('BaseButton'),
},
};
3 changes: 3 additions & 0 deletions packages/ui/src/stories/Introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<main>
<h1>Welcome to PPOBA-UI</h1>
</main>
3 changes: 3 additions & 0 deletions packages/ui/src/tailwind.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind utilities;
@tailwind components;
10 changes: 10 additions & 0 deletions packages/ui/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [],
}
25 changes: 25 additions & 0 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"include": ["src", "postcss.config.js"],
"exclude": ["**/dist/*", "**/esm/*"],
"compilerOptions": {
"lib": ["DOM"],
"module": "ESNext",
"target": "ES6",
"jsx": "react-jsx",
"outDir": "./dist",

"composite": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "node",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
"skipLibCheck": true,
"strict": true
}
}
25 changes: 25 additions & 0 deletions packages/ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { resolve } from 'path';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
build: {
lib: {
entry: resolve(__dirname, './src/index.ts'),
name: '@ppoba/ui',
formats: ['es', 'cjs'],
fileName: 'index',
},
rollupOptions: {
external: ['react'],
output: {
globals: {
react: 'React',
},
},
},
},
plugins: [react(), dts()],
});
Loading

0 comments on commit 75db69c

Please sign in to comment.