diff --git a/.github/workflows/build-ui.yml b/.github/workflows/build-ui.yml index 907bb19..a16c38a 100644 --- a/.github/workflows/build-ui.yml +++ b/.github/workflows/build-ui.yml @@ -1,4 +1,4 @@ -name: UI Component Build +name: release build on: push: @@ -39,16 +39,6 @@ jobs: - name: Building UI Component run: npm run build-storybook - - uses: shallwefootball/s3-upload-action@master - name: Upload S3 - id: S3 - with: - aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} - aws_bucket: ${{ secrets.AWS_BUCKET }} - source_dir: "storybook-static" - destination_dir: "" - - uses: JS-DevTools/npm-publish@v1 with: token: ${{ secrets.NPM_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9b53663 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing + +If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request. + +### How to make a clean pull request + +Look for a project's contribution instructions. If there are any, follow them. + +- Create a personal fork of the project on Github. +- Clone the fork on your local machine. Your remote repo on Github is called `origin`. +- Add the original repository as a remote called `upstream`. +- If you created your fork a while ago be sure to pull upstream changes into your local repository. +- Create a new branch to work on! Branch from `develop` if it exists, else from `master`. +- Implement/fix your feature, comment your code. +- Follow the code style of the project, including indentation. +- If the project has tests run them! +- Write or adapt tests as needed. +- Add or change the documentation as needed. +- Squash your commits into a single commit with git's [interactive rebase](https://help.github.com/articles/interactive-rebase). Create a new branch if necessary. +- Push your branch to your fork on Github, the remote `origin`. +- From your fork open a pull request in the correct branch. Target the project's `develop` branch if there is one, else go for `master`! +- If the maintainer requests further changes just push them to your branch. The PR will be updated automatically. +- Once the pull request is approved and merged you can pull the changes from `upstream` to your local repo and delete + your extra branch(es). + +And last but not least: Always write your commit messages in the present tense. Your commit message should describe what the commit, when applied, does to the code – not what you did to the code. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b0c6086 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 linkube + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index f1bf62d..414401e 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ React Admin Template UI ![UI Component Build](https://github.com/linkube-team/keobee-ui/workflows/UI%20Component%20Build/badge.svg) ![dev test](https://github.com/linkube-team/keobee-ui/workflows/dev%20test/badge.svg) +[![Netlify Status](https://api.netlify.com/api/v1/badges/e1d36418-7aaa-4781-981f-bed4d44081bf/deploy-status)](https://app.netlify.com/sites/keobee-ui/deploys) ## Getting Start diff --git a/lib/atoms/Badge/Badge.scss b/lib/atoms/Badge/Badge.scss new file mode 100644 index 0000000..e71aaf7 --- /dev/null +++ b/lib/atoms/Badge/Badge.scss @@ -0,0 +1,22 @@ +@import "../../style/import"; + +.#{$prefix}__badge { + @include size; + font-size: 9px; + padding: 3px 6px; + display: inline-block; + vertical-align: middle; + + &--primary { + border: 1px solid transparent; + background-color: map-get($colors, "primary"); + color: #ffffff; + } + + &--disabled { + border: 1px solid transparent; + background-color: map-get($colors, "disabled"); + color: #ffffff; + cursor: not-allowed; + } +} diff --git a/lib/atoms/Badge/Badge.tsx b/lib/atoms/Badge/Badge.tsx new file mode 100644 index 0000000..28db3a7 --- /dev/null +++ b/lib/atoms/Badge/Badge.tsx @@ -0,0 +1,25 @@ +import React, { HTMLAttributes } from "react" +import cx from "classnames" +import { useUi } from "@lib/hooks" + +import "./Badge.scss" + +export type BadgeProps = HTMLAttributes & { + variant?: "primary" | "disabled" +} + +export const Badge = React.forwardRef( + ({ children, className, variant = "primary", ...props }, ref) => { + const { getPrefix } = useUi() + + const prefix = getPrefix("badge") + + const classes = cx([prefix, className, `${prefix}--${variant}`]) + + return ( + + {children} + + ) + }, +) diff --git a/lib/atoms/Badge/index.ts b/lib/atoms/Badge/index.ts new file mode 100644 index 0000000..9d37d5f --- /dev/null +++ b/lib/atoms/Badge/index.ts @@ -0,0 +1 @@ +export * from "./Badge" diff --git a/lib/atoms/Button/Button.scss b/lib/atoms/Button/Button.scss index d2fbf41..a1cdbfb 100644 --- a/lib/atoms/Button/Button.scss +++ b/lib/atoms/Button/Button.scss @@ -4,15 +4,32 @@ @include size; cursor: pointer; + border: 1px solid transparent; &--primary { - border: 1px solid transparent; background-color: map-get($colors, "primary"); color: #ffffff; } + &--success { + background-color: map-get($colors, "success"); + color: #ffffff; + } + + &--danger { + background-color: map-get($colors, "danger"); + color: #ffffff; + } + + &--warning { + background-color: map-get($colors, "warning"); + color: #ffffff; + } + &:disabled { background-color: map-get($colors, "disabled"); + color: map-get($colors, "disabled-dark"); + border: 1px solid map-get($colors, "disabled-dark"); cursor: not-allowed; } } diff --git a/lib/atoms/Button/Button.tsx b/lib/atoms/Button/Button.tsx index 88dce2a..4cf4a12 100644 --- a/lib/atoms/Button/Button.tsx +++ b/lib/atoms/Button/Button.tsx @@ -5,7 +5,7 @@ import cx from "classnames" import "./Button.scss" export type ButtonProps = React.ButtonHTMLAttributes & { - variant?: "primary" + variant?: "primary" | "success" | "danger" | "warning" size?: "small" | "medium" | "large" | "xlarge" disabled?: boolean } @@ -17,6 +17,7 @@ export const Button = React.forwardRef( variant = "primary", type = "button", disabled = false, + size = "medium", className, ...rest }, diff --git a/lib/atoms/CheckBox/CheckBox.scss b/lib/atoms/CheckBox/CheckBox.scss index 815775c..16aaaf0 100644 --- a/lib/atoms/CheckBox/CheckBox.scss +++ b/lib/atoms/CheckBox/CheckBox.scss @@ -37,5 +37,12 @@ color: #ffffff; } } + + &:disabled + span { + background-color: map-get($colors, "disabled"); + color: map-get($colors, "disabled-dark"); + border: 1px solid map-get($colors, "disabled-dark"); + cursor: not-allowed; + } } } diff --git a/lib/atoms/Input/Input.scss b/lib/atoms/Input/Input.scss index 43e6623..c4ac73a 100644 --- a/lib/atoms/Input/Input.scss +++ b/lib/atoms/Input/Input.scss @@ -1,4 +1,4 @@ -@import "../../style/import.scss"; +@import "../../style/import"; .#{$prefix}__input { @include base; @@ -7,4 +7,11 @@ &--primary { border: 1px solid map-get($colors, "primary"); } + + &:disabled { + background-color: #{map-get($map: $colors, $key: "disabled")}; + border: 1px solid map-get($colors, "disabled-dark"); + cursor: not-allowed; + color: map-get($colors, "disabled-dark"); + } } diff --git a/lib/atoms/TextArea/TextArea.scss b/lib/atoms/TextArea/TextArea.scss index d328907..701d35e 100644 --- a/lib/atoms/TextArea/TextArea.scss +++ b/lib/atoms/TextArea/TextArea.scss @@ -14,6 +14,8 @@ } &:disabled { background-color: map-get($colors, "disabled"); + color: map-get($colors, "disabled-dark"); + border: 1px solid map-get($colors, "disabled-dark"); cursor: not-allowed; } } diff --git a/lib/index.ts b/lib/index.ts index 842ab1d..fcfecc3 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -7,8 +7,10 @@ export * from "./atoms/CheckBox" export * from "./atoms/Radio" export * from "./atoms/Select" export * from "./atoms/TextArea" +export * from "./atoms/Badge" export * from "./molecules/ButtonGroup" export * from "./molecules/Panel" export * from "./organisms/Modal" +export * from "./organisms/DatePicker" diff --git a/lib/molecules/FormInput/FormInput.scss b/lib/molecules/FormInput/FormInput.scss new file mode 100644 index 0000000..21e49b1 --- /dev/null +++ b/lib/molecules/FormInput/FormInput.scss @@ -0,0 +1,13 @@ +@import "../../style/import"; + +.#{$prefix}__form-input { + &__form-group { + display: inline-block; + } + + &__title { + display: block; + font-size: 13px; + margin-bottom: 5px; + } +} diff --git a/lib/molecules/FormInput/FormInput.tsx b/lib/molecules/FormInput/FormInput.tsx new file mode 100644 index 0000000..07900fc --- /dev/null +++ b/lib/molecules/FormInput/FormInput.tsx @@ -0,0 +1,28 @@ +import React from "react" +import cx from "classnames" +import { Input, InputProps } from "@lib/atoms/Input" +import { useUi } from "@lib/hooks" + +import "./FormInput.scss" + +export type FormInputProps = InputProps & { + label?: string +} + +export const FormInput = React.forwardRef( + ({ children, label, ...props }, ref) => { + const { getPrefix } = useUi() + + const prefix = getPrefix("form-input") + + const wrappedClass = cx([`${prefix}__form-group`]) + const titleClass = cx([`${prefix}__title`]) + + return ( + + ) + }, +) diff --git a/lib/molecules/FormInput/index.ts b/lib/molecules/FormInput/index.ts new file mode 100644 index 0000000..c7ad972 --- /dev/null +++ b/lib/molecules/FormInput/index.ts @@ -0,0 +1 @@ +export * from "./FormInput" diff --git a/lib/organisms/DatePicker/DatePicker.scss b/lib/organisms/DatePicker/DatePicker.scss new file mode 100644 index 0000000..5dd5482 --- /dev/null +++ b/lib/organisms/DatePicker/DatePicker.scss @@ -0,0 +1,107 @@ +@import "../../style/import.scss"; + +.#{$prefix}__calednar { + border-radius: unset; + border: 1px solid map-get($colors, "border") !important; + top: -11px; + left: -1px; + + .react-datepicker { + font-size: 1.3rem !important; + } + .react-datepicker__triangle { + display: none; + } + + .btn_month { + background: none; + line-height: 1.7rem; + text-align: center; + cursor: pointer; + top: 10px; + width: 0; + padding: 0; + border: 0.45rem solid transparent; + z-index: 1; + height: 10px; + width: 10px; + text-indent: -999em; + overflow: hidden; + } + .btn_month-prev { + border-right-color: #fff; + } + .btn_month-next { + border-left-color: #fff; + } + .month-day { + font-size: 1.6rem; + color: #fff; + font-weight: 400; + } + + .react-datepicker__current-month { + font-size: 1.5rem !important; + color: #fff; + } + + .react-datepicker__header { + padding-top: 6px; + background-color: map-get($colors, "primary"); + border-bottom: transparent; + border-radius: unset; + } + .react-datepicker__navigation { + top: 13px; + } + .react-datepicker__week { + padding: 1px; + } + .react-datepicker__day-names { + background-color: #fff; + } + .react-datepicker__day-name { + font-size: 1rem; + color: #000; + padding: 1px; + } + .react-datepicker__day-name, + .react-datepicker__day { + margin: 0.5rem; + font-size: 1rem; + } + .react-datepicker__day { + padding: 1px; + } + .react-datepicker__day:hover { + border-radius: 50%; + background-color: #dbe7ff; + padding: 1px; + } + .react-datepicker__day--disabled { + color: #cccccc !important; + } + .react-datepicker__day--selected { + background-color: map-get($colors, "primary"); + border-radius: 50%; + padding: 1px; + } + .react-datepicker__day--keyboard-selected, + .react-datepicker__month-text--keyboard-selected, + .react-datepicker__quarter-text--keyboard-selected, + .react-datepicker__year-text--keyboard-selected { + background-color: map-get($colors, "primary"); + border-radius: 50%; + padding: 1px; + } + + .react-datepicker__day-name:nth-child(1) { + color: #ff5249; + } + .react-datepicker__day--outside-month { + color: #ccc !important; + } + .sunday { + color: #ff5249; + } +} diff --git a/lib/organisms/DatePicker/DatePicker.tsx b/lib/organisms/DatePicker/DatePicker.tsx new file mode 100644 index 0000000..3121680 --- /dev/null +++ b/lib/organisms/DatePicker/DatePicker.tsx @@ -0,0 +1,101 @@ +import React, { useRef } from "react" +import ReactDOM from "react-dom" +import { useUi } from "@lib/hooks" +import { Input } from "@lib/atoms/Input" +import cx from "classnames" + +import ReactDatePicker, { + ReactDatePickerProps, + registerLocale, +} from "react-datepicker" + +import { getYear, getMonth, isSunday } from "date-fns" + +import "react-datepicker/dist/react-datepicker.css" +import "./DatePicker.scss" + +import { ko } from "date-fns/locale" + +export type DatePickerProps = ReactDatePickerProps & { + dateFormat?: string + onCalendarOpen?: () => void + onCalendarClose?: () => void + disabled?: boolean +} + +export const DatePicker = React.forwardRef( + ( + { + className, + popperPlacement = "top-start", + dateFormat = "yyyy.MM.dd (eee)", + onCalendarOpen, + onCalendarClose, + disabled = false, + minDate, + maxDate, + ...props + }, + ref, + ) => { + const { getPrefix } = useUi() + const prefixClass = getPrefix("datepicker") + const calendarClassName = getPrefix("calednar") + + const _className = cx(prefixClass, [className]) + + registerLocale("ko", ko) + + return ( + } + locale="ko" + dayClassName={(date) => (isSunday(date) ? "sunday" : null)} + useWeekdaysShort={true} + dateFormat={!dateFormat ? "yyyy.MM.dd (eee)" : dateFormat} + onCalendarOpen={onCalendarOpen} + onCalendarClose={onCalendarClose} + disabled={disabled} + minDate={minDate} + maxDate={maxDate} + renderCustomHeader={({ + date, + prevMonthButtonDisabled, + nextMonthButtonDisabled, + decreaseMonth, + increaseMonth, + }) => { + return ( + <> +
+ +
+ {getYear(date)}.{getMonth(date) + 1} +
+ + +
+ + ) + }} + {...props} + /> + ) + }, +) diff --git a/lib/organisms/DatePicker/index.ts b/lib/organisms/DatePicker/index.ts new file mode 100644 index 0000000..2d3498d --- /dev/null +++ b/lib/organisms/DatePicker/index.ts @@ -0,0 +1 @@ +export * from "./DatePicker" diff --git a/lib/organisms/Modal/Modal.scss b/lib/organisms/Modal/Modal.scss index 0492f9c..dd6a1bc 100644 --- a/lib/organisms/Modal/Modal.scss +++ b/lib/organisms/Modal/Modal.scss @@ -1,88 +1,53 @@ @import "../../style/import"; -.#{$prefix}__modal { - display: block; - - // &--entering { - // } - // &--entered { - // } - - // &--exiting { - // } - &--exited { - display: none; - transition: all 150ms linear; - } -} - -.#{$prefix}__modal--overlay { +.#{$prefix}__modal-root { $overlay-color: #{map-get( $map: $colors, $key: "dark", )}; - display: block; - position: fixed; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: #{$overlay-color}00; - transition: background-color 150ms linear; - &--entering { - background-color: #{$overlay-color}70; - } - &--entered { - background-color: #{$overlay-color}70; - } - - &--exiting { - background-color: #{$overlay-color}00; - } - &--exited { + .#{$prefix}__modal--overlay { background-color: #{$overlay-color}00; - } -} - -.#{$prefix}__modal--content { - @include size; - transition: all 150ms ease-in-out; - background-color: #ffffff; - margin: 40px auto; - transform: translateY(-100px); - opacity: 0; - // size - &--xsmall { - width: 360px; - } - &--small { - width: 420px; - } - &--medium { - width: 650px; - } - &--large { - width: 860px; - } - &--xlarge { - width: 1200px; - } - - &--entering { - opacity: 1; - transform: translateY(0); - } - &--entered { - transform: translateY(0); - opacity: 1; - } - - &--exiting { - opacity: 0; - } - &--exited { - opacity: 0; + transition: background-color 100ms linear; + display: block; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + } + + .#{$prefix}__modal--container { + @include size; + background-color: #ffffff; + margin: 40px auto; transition: all 150ms ease-out; + transform: translateY(-40px); + opacity: 0; + &--xsmall { + width: 360px; + } + &--small { + width: 420px; + } + &--medium { + width: 650px; + } + &--large { + width: 860px; + } + &--xlarge { + width: 1200px; + } + } + + &.appear { + .#{$prefix}__modal--overlay { + background-color: #{$overlay-color}70; + } + .#{$prefix}__modal--container { + transform: translateY(0); + opacity: 1; + } } } diff --git a/lib/organisms/Modal/Modal.tsx b/lib/organisms/Modal/Modal.tsx index 558e0be..6e6253f 100644 --- a/lib/organisms/Modal/Modal.tsx +++ b/lib/organisms/Modal/Modal.tsx @@ -1,6 +1,11 @@ -import React from "react" +import React, { useState } from "react" import cx from "classnames" -import { Transition } from "react-transition-group" +import { + Transition, + CSSTransition, + TransitionGroup, + SwitchTransition, +} from "react-transition-group" import { useUi } from "@lib/hooks" import { Portal } from "./Portal" @@ -24,49 +29,57 @@ export const Modal: React.FC = ({ ...props }) => { const { getPrefix } = useUi() + const [appear, setAppear] = useState(false) const prefix = getPrefix("modal") - const classes = cx([prefix]) - - const handleContentClick = (e: React.MouseEvent) => { - e.preventDefault() - e.stopPropagation() - } + const rootClass = cx(`${prefix}-root`, { + appear, + }) + const overlayClass = cx(`${prefix}--overlay`) + const containerClass = cx( + `${prefix}--container`, + `${prefix}--container--${size}`, + ) const _onClose = (e: React.MouseEvent) => { e.preventDefault() e.stopPropagation() onClose && onClose() } + const handleEnter = () => { + setTimeout(() => setAppear(true), 0) + + window.addEventListener("keydown", _handleESCKeyPress, false) + } + + const handleExiting = () => { + setAppear(false) + window.removeEventListener("keydown", _handleESCKeyPress, false) + } + + const _handleESCKeyPress = (e: KeyboardEvent) => { + if (e.key === "Escape") { + _onClose(e as any) + } + } + return ( <> - - {(state) => ( -
-
-
- {children} -
-
-
- )} -
+ +
+
+
{children}
+
+ ) diff --git a/lib/style/_colors.scss b/lib/style/_colors.scss index 898854e..7cae31d 100644 --- a/lib/style/_colors.scss +++ b/lib/style/_colors.scss @@ -5,5 +5,12 @@ $colors: ( "lightDark": #666666, "lightGray": #e6e6e6, "border": #dae1e6, - "disabled": #6c757d65, + "disabled": #cccccc, + "disabled-dark": #888888, + "danger": #ff4444, + "danger-dark": #cc0000, + "warning": #ffbb33, + "warning-dark": #ff8800, + "success": #00c851, + "success-dark": #007e33, ); diff --git a/lib/style/_import.scss b/lib/style/_import.scss index 7a14d1e..a5b9e23 100644 --- a/lib/style/_import.scss +++ b/lib/style/_import.scss @@ -1,7 +1,7 @@ -@import "./fonts.scss"; +@import "./fonts"; @import "./variable"; -@import "./colors.scss"; -@import "./mixin.scss"; -@import "./functions.scss"; +@import "./colors"; +@import "./mixin"; +@import "./functions"; $prefix: "kb"; diff --git a/lib/style/_mixin.scss b/lib/style/_mixin.scss index ead7124..6da69ac 100644 --- a/lib/style/_mixin.scss +++ b/lib/style/_mixin.scss @@ -21,7 +21,7 @@ padding: 7px 14px; } -@mixin input { +@mixin input($disable: false) { @include size; background-color: #fff; diff --git a/package.json b/package.json index 32fbb41..b834017 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "keobee-ui", - "version": "0.4.0", + "version": "0.5.0", "keywords": [ "react", "react-ui" ], - "homepage": "https://ui.linkube.com", + "homepage": "https://keobee-ui.netlify.app", "repository": { "type": "git", "url": "https://github.com/linkube-team/keobee-ui" @@ -16,7 +16,13 @@ "email": "thtjwls@gmail.com", "url": "https://github.com/ziponia" }, - "contributors": [], + "contributors": [ + { + "name": "JiEun-Choi-Dev", + "email": "jehy0807@gmail.com", + "url": "https://github.com/JiEun-Choi-Dev" + } + ], "main": "dist/index.js", "types": "dist/lib/index.d.ts", "files": [ @@ -25,7 +31,7 @@ "scripts": { "prebuild": "rimraf dist", "build": "rollup -c", - "build-storybook": "build-storybook", + "build-storybook": "NODE_ENV=production build-storybook", "lint": "yarn lint:js && yarn lint:scss", "lint:js": "eslint './lib/**/*.{ts,tsx,js,jsx}'", "lint:scss": "stylelint ./lib/**/*.scss", @@ -37,6 +43,11 @@ "pre-commit": "sort-package-json && pretty-quick --staged && yarn test" } }, + "dependencies": { + "@types/react-datepicker": "^3.1.3", + "date-fns": "^2.17.0", + "react-datepicker": "^3.4.1" + }, "devDependencies": { "@babel/core": "^7.12.10", "@babel/preset-env": "^7.12.11", diff --git a/stories/atoms/Badge.stories.tsx b/stories/atoms/Badge.stories.tsx new file mode 100644 index 0000000..4fdcb1a --- /dev/null +++ b/stories/atoms/Badge.stories.tsx @@ -0,0 +1,21 @@ +import React from "react" +import { Story, Meta } from "@storybook/react/types-6-0" +import { Badge, BadgeProps } from "@lib/atoms/Badge" +import { action } from "@storybook/addon-actions" + +export default { + title: "@atoms/Badge", + component: Badge, +} as Meta + +const Template: Story = (args) => { + return ( + + Badge + + ) +} + +export const Basic = Template.bind({}) + +Basic.args = {} diff --git a/stories/atoms/Button.stories.tsx b/stories/atoms/Button.stories.tsx index c6bed24..5047604 100644 --- a/stories/atoms/Button.stories.tsx +++ b/stories/atoms/Button.stories.tsx @@ -19,6 +19,18 @@ const Template: Story = (args) => { export const Primary = Template.bind({}) Primary.args = { - size: "small", disabled: false, + variant: "primary", +} + +export const Danger = Template.bind({}) + +Danger.args = { + variant: "danger", +} + +export const Success = Template.bind({}) + +Success.args = { + variant: "success", } diff --git a/stories/atoms/Checkbox.stories.tsx b/stories/atoms/Checkbox.stories.tsx index f1101bc..da65abc 100644 --- a/stories/atoms/Checkbox.stories.tsx +++ b/stories/atoms/Checkbox.stories.tsx @@ -11,11 +11,13 @@ export default { const Template: Story = (args) => { return ( <> - + ) } -export const Primary = Template.bind({}) +export const Basic = Template.bind({}) -Primary.args = {} +Basic.args = { + disabled: false, +} diff --git a/stories/atoms/Input.stories.tsx b/stories/atoms/Input.stories.tsx index ac9bb35..55e20e1 100644 --- a/stories/atoms/Input.stories.tsx +++ b/stories/atoms/Input.stories.tsx @@ -9,9 +9,13 @@ export default { } as Meta const Template: Story = (args) => { - return + return } -export const Default = Template.bind({}) +export const Basic = Template.bind({}) -Default.args = {} +Basic.args = { + disabled: false, + placeholder: "entered input...", + value: "", +} diff --git a/stories/atoms/TextArea.stories.tsx b/stories/atoms/TextArea.stories.tsx index 3f40a09..5bae851 100644 --- a/stories/atoms/TextArea.stories.tsx +++ b/stories/atoms/TextArea.stories.tsx @@ -19,4 +19,5 @@ export const Basic = Template.bind({}) Basic.args = { disabled: false, placeholder: "Leave your comment.", + value: "", } diff --git a/stories/molecules/FormInput.stories.tsx b/stories/molecules/FormInput.stories.tsx new file mode 100644 index 0000000..367edb8 --- /dev/null +++ b/stories/molecules/FormInput.stories.tsx @@ -0,0 +1,32 @@ +import React from "react" +import { Story, Meta } from "@storybook/react/types-6-0" +import { FormInput, FormInputProps } from "@lib/molecules/FormInput" + +export default { + title: "@molecules/Form/FormInput", + component: FormInput, + argTypes: { + label: { + name: "label", + control: { + type: "text", + }, + }, + }, +} as Meta + +const Template: Story = (args) => { + return ( + <> + + + ) +} + +export const Basic = Template.bind({}) + +Basic.args = { + disabled: true, + label: "username", + placeholder: "username", +} diff --git a/stories/organisms/DatePicker.stories.tsx b/stories/organisms/DatePicker.stories.tsx new file mode 100644 index 0000000..b36af1f --- /dev/null +++ b/stories/organisms/DatePicker.stories.tsx @@ -0,0 +1,55 @@ +import React, { useState, useEffect } from "react" +import { Story, Meta } from "@storybook/react/types-6-0" +import { DatePicker, DatePickerProps } from "@lib/organisms/DatePicker" +import { action } from "@storybook/addon-actions" + +export default { + title: "@organisms/DatePicker", + component: DatePicker, + argTypes: { + selected: { + defaultValue: new Date(), + control: { + type: "date", + }, + }, + minDate: { + defaultValue: new Date(), + control: { + type: "date", + }, + }, + maxDate: { + control: { + type: "date", + }, + }, + }, +} as Meta + +const Template: Story = (args) => { + const [date, setDate] = useState(args.selected) + + const onChange = (date: Date | [Date, Date]) => { + setDate(date as Date) + } + + useEffect(() => { + action("change")(date) + }, [date]) + return ( + <> + + + ) +} + +export const Basic = Template.bind({}) + +Basic.args = { + selected: new Date(), + dateFormat: "yyyy.MM.dd (eee)", + onCalendarOpen: () => null, + onCalendarClose: () => null, + disabled: false, +} diff --git a/stories/organisms/Modal.stories.tsx b/stories/organisms/Modal.stories.tsx index 83ed39e..3d3b5f6 100644 --- a/stories/organisms/Modal.stories.tsx +++ b/stories/organisms/Modal.stories.tsx @@ -20,7 +20,7 @@ const Template: Story = (args) => { return ( <> - setOpen(false)}> + setOpen(false)}>

this is my modal

@@ -30,7 +30,7 @@ const Template: Story = (args) => { export const Basic = Template.bind({}) Basic.args = { - open: true, + open: false, node: document.body, onClose: () => null, }