Skip to content

Commit

Permalink
Merge branch 'main' into feat/select
Browse files Browse the repository at this point in the history
  • Loading branch information
sohee-K authored Jun 22, 2024
2 parents 11edb8a + 281f7ac commit b9bf5d5
Show file tree
Hide file tree
Showing 48 changed files with 1,258 additions and 194 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
72 changes: 52 additions & 20 deletions apps/docs/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,81 @@
import { Test } from '@sopt-makers/ui';
import './App.css';
import { useState, ChangeEvent } from 'react';
import TextField from '../../../packages/ui/Input/TextField';
import TextArea from '../../../packages/ui/Input/TextArea';
import SearchField from '../../../packages/ui/Input/SearchField';
import "./App.css";

import { ChangeEvent, useState } from "react";

import SearchField from "../../../packages/ui/Input/SearchField";
import { Test } from "@sopt-makers/ui";
import TextArea from "../../../packages/ui/Input/TextArea";
import TextField from "../../../packages/ui/Input/TextField";

function App() {
const [input, setInput] = useState('');
const [textarea, setTextarea] = useState('');
const [search, setSearch] = useState('');
const [input, setInput] = useState("");
const [textarea, setTextarea] = useState("");
const [search, setSearch] = useState("");

const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
setInput(e.target.value);
}
};

const inputValidation = (input: string) => {
if (input && input.length > 10) return true;
return false;
}
};

const handleTextareaChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
setTextarea(e.target.value);
}
};

const textareaValidation = (input: string) => {
if (input && input.length > 10) return true;
return false;
}
};

const handleTextareaSubmit = () => { console.log(textarea) }
const handleTextareaSubmit = () => {
console.log(textarea);
};

const handleSearchChange = (e: ChangeEvent<HTMLInputElement>) => {
setSearch(e.target.value);
}
};

const handleSearchSubmit = () => { console.log(search) }
const handleSearchSubmit = () => {
console.log(search);
};

const handleSearchReset = () => { setSearch('') }
const handleSearchReset = () => {
setSearch("");
};

return (
<>
<Test text="Test Component" size="big" color="blue" />
<TextField<string> placeholder="Placeholder..." required labelText="Label" descriptionText="description" validationFn={inputValidation} value={input} onChange={handleInputChange} />
<TextArea placeholder="Placeholder..." required labelText="Label" descriptionText="description" validationFn={textareaValidation} value={textarea} onChange={handleTextareaChange} onSubmit={handleTextareaSubmit} maxLength={300} />
<SearchField placeholder="Placeholder..." value={search} onChange={handleSearchChange} onSubmit={handleSearchSubmit} onReset={handleSearchReset} />
<TextField<string>
placeholder="Placeholder..."
required
labelText="Label"
descriptionText="description"
validationFn={inputValidation}
value={input}
onChange={handleInputChange}
/>
<TextArea
placeholder="Placeholder..."
required
labelText="Label"
descriptionText="description"
validationFn={textareaValidation}
value={textarea}
onChange={handleTextareaChange}
onSubmit={handleTextareaSubmit}
maxLength={300}
/>
<SearchField
placeholder="Placeholder..."
value={search}
onChange={handleSearchChange}
onSubmit={handleSearchSubmit}
onReset={handleSearchReset}
/>
</>
);
}
Expand Down
17 changes: 11 additions & 6 deletions apps/docs/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,41 @@
}

body {
background-color: rgb(0, 0, 0);
background-color: #1e1e1e;
}

@font-face {
font-family: "SUIT";
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Light.woff2") format("woff2");
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Light.woff2")
format("woff2");
font-weight: 300;
font-style: normal;
}
@font-face {
font-family: "SUIT";
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Regular.woff2") format("woff2");
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Regular.woff2")
format("woff2");
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: "SUIT";
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Medium.woff2") format("woff2");
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Medium.woff2")
format("woff2");
font-weight: 500;
font-style: normal;
}
@font-face {
font-family: "SUIT";
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-SemiBold.woff2") format("woff2");
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-SemiBold.woff2")
format("woff2");
font-weight: 600;
font-style: normal;
}
@font-face {
font-family: "SUIT";
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Bold.woff2") format("woff2");
src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_suit@1.0/SUIT-Bold.woff2")
format("woff2");
font-weight: 700;
font-style: normal;
}
Expand Down
24 changes: 17 additions & 7 deletions apps/docs/src/stories/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meta, StoryObj } from '@storybook/react';
import { Button } from '@sopt-makers/ui';
import { IconPlus, IconChevronRight } from '@sopt-makers/icons';

interface ButtonOwnProps {
size?: 'sm' | 'md' | 'lg';
Expand All @@ -16,6 +17,13 @@ export default {
title: 'Components/Button',
component: Button,
tags: ['autodocs'],
argTypes: {
size: { control: 'radio', options: ['sm', 'md', 'lg'] },
theme: { control: 'radio', options: ['white', 'black', 'blue', 'red'] },
rounded: { control: 'radio', options: ['md', 'lg'] },
LeftIcon: { control: false },
RightIcon: { control: false }
}
} as Meta<ButtonStoryProps>;

// 기본 버튼 스토리
Expand All @@ -30,22 +38,24 @@ export const Default: StoryObj<ButtonStoryProps> = {
};

// 커스텀 버튼 스토리
export const Another: StoryObj<ButtonStoryProps> = {
export const LeftIcon: StoryObj<ButtonStoryProps> = {
args: {
children: 'Another Button',
size: 'lg',
children: 'LeftIcon Button',
size: 'sm',
theme: 'red',
rounded: 'lg',
disabled: false,
LeftIcon: IconPlus,
},
};

export const Disabled: StoryObj<ButtonStoryProps> = {
export const RightIcon: StoryObj<ButtonStoryProps> = {
args: {
children: 'Disabled Button',
size: 'md',
children: 'RightIcon Button',
size: 'lg',
theme: 'blue',
rounded: 'lg',
disabled: true,
disabled: false,
RightIcon: IconChevronRight,
},
};
73 changes: 73 additions & 0 deletions apps/docs/src/stories/Callout.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Callout } from "@sopt-makers/ui";
import { Meta, StoryObj } from "@storybook/react";

interface CalloutProps {
children: React.ReactNode;
type: "danger" | "information" | "warning";
hasIcon?: boolean;
buttonLabel?: string;
isButtonDisabled?: boolean;
onClick?: () => void;
}

export default {
title: "Components/Callout",
component: Callout,
tags: ["autodocs"],
argTypes: {
type: { control: 'radio', options: ['danger', 'information', 'warning'] },
}
} as Meta<CalloutProps>;

// danger 콜아웃 스토리
export const Danger: StoryObj<CalloutProps> = {
args: {
children: "hasIcon 옵션으로 통해 아이콘을 표시할 수 있어요",
type: "danger",
hasIcon: false,
},
};
// information 콜아웃 스토리
export const Information: StoryObj<CalloutProps> = {
args: {
children: "hasIcon 옵션으로 통해 아이콘을 표시할 수 있어요",
type: "information",
hasIcon: false,
},
};
// warning 콜아웃 스토리
export const Warning: StoryObj<CalloutProps> = {
args: {
children: "hasIcon 옵션으로 통해 아이콘을 표시할 수 있어요",
type: "warning",
hasIcon: false,
},
};

// warning+icon+button 콜아웃 스토리
export const CalloutWithBtn: StoryObj<CalloutProps> = {
args: {
children: (
<>
버튼이 있는 경우 hasIcon과 무관하게 아이콘이 항상 표시돼요. <br />
isButtonDisabled 옵션으로 disabled state를 확인해보세요.
</>
),
type: "warning",
hasIcon: true,
buttonLabel: "hover, press 해보세요!",
isButtonDisabled: false,
},
};

// 여러줄 텍스트 콜아웃 스토리
export const CalloutWithLongText: StoryObj<CalloutProps> = {
args: {
children:
"Facebook 정책이 변경되어, 앞으로 Facebook 로그인이 불가해요. 다른 계정으로 재설정 부탁드려요. Facebook 정책이 변경되어, 앞으로 Facebook 로그인이 불가해요. 다른 계정으로 재설정 부탁드려요.",
type: "information",
hasIcon: true,
buttonLabel: "소셜 계정 재설정하기",
isButtonDisabled: false,
},
};
24 changes: 15 additions & 9 deletions apps/docs/src/stories/CheckBox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { Meta, StoryObj } from '@storybook/react';
import { CheckBox } from '@sopt-makers/ui';
import type { Meta, StoryObj } from "@storybook/react";
import { CheckBox } from "@sopt-makers/ui";

const meta = {
title: 'Components/CheckBox',
title: "Components/Control/CheckBox",
component: CheckBox,
tags: ['autodocs'],
tags: ["autodocs"],
argTypes: {
size: { control: 'radio', options: ['sm', 'lg'] },
label: { control: 'text' },
color: { control: 'color' },
}
} as Meta<typeof CheckBox>;

export default meta;
Expand All @@ -13,22 +18,23 @@ type Story = StoryObj<typeof meta>;
export const Default: Story = {
args: {
checked: true,
size: 'small',
size: "sm",
label: "Label",
},
};

export const LargeLabel: StoryObj = {
args: {
checked: false,
size: 'large',
label: 'Label'
size: "lg",
label: "Label",
},
};

export const SmallLabel: StoryObj = {
args: {
checked: false,
size: 'small',
label: 'Label'
size: "sm",
label: "Label",
},
};
64 changes: 64 additions & 0 deletions apps/docs/src/stories/Chip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Meta, StoryObj } from '@storybook/react';
import { Chip } from '@sopt-makers/ui';
import { IconCheck, IconAlarmClock } from '@sopt-makers/icons';

interface ChipOwnProps {
iconColor?: string;
size?: 'sm' | 'md';
active?: boolean;
LeftIcon?: React.ComponentType;
RightIcon?: React.ComponentType;
}

type ChipStoryProps = ChipOwnProps & { children: string };

export default {
title: 'Components/Chip',
component: Chip,
tags: ['autodocs'],
argTypes: {
size: { control: 'radio', options: ['sm', 'md'] },
iconColor: { control: 'color' },
LeftIcon: { control: false },
RightIcon: { control: false },
}
} as Meta<ChipStoryProps>;

// 기본 chip 스토리
export const Default: StoryObj<ChipStoryProps> = {
args: {
children: 'Default Chip',
size: 'sm',
active: false,
},
};

// active chip 스토리
export const Active: StoryObj<ChipStoryProps> = {
args: {
children: 'Active Chip',
size: 'md',
active: true,
},
};

// left icon (with color) chip 스토리
export const LeftIcon: StoryObj<ChipStoryProps> = {
args: {
children: 'Chip with a LeftIcon',
size: 'sm',
active: false,
LeftIcon: IconCheck,
},
};

// colored right icon chip 스토리
export const RightIconWithColor: StoryObj<ChipStoryProps> = {
args: {
children: 'Chip with a colored RightIcon',
iconColor: '#cd24ea',
size: 'sm',
active: false,
RightIcon: IconAlarmClock,
},
};
Loading

0 comments on commit b9bf5d5

Please sign in to comment.