From 8b66f5463432c5e8d837e070a2df3138683e3c1e Mon Sep 17 00:00:00 2001 From: ziponia Date: Sat, 6 Feb 2021 01:01:11 +0900 Subject: [PATCH 01/11] add badge --- lib/atoms/Badge/Badge.scss | 22 ++++++++++++++++++++++ lib/atoms/Badge/Badge.tsx | 25 +++++++++++++++++++++++++ lib/atoms/Badge/index.ts | 1 + lib/index.ts | 1 + stories/atoms/Badge.stories.tsx | 21 +++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 lib/atoms/Badge/Badge.scss create mode 100644 lib/atoms/Badge/Badge.tsx create mode 100644 lib/atoms/Badge/index.ts create mode 100644 stories/atoms/Badge.stories.tsx 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/index.ts b/lib/index.ts index 842ab1d..b6a3381 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -7,6 +7,7 @@ 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" 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 = {} From ba54048406dc0a94a7a6fee1e5e8868213602761 Mon Sep 17 00:00:00 2001 From: ziponia Date: Sat, 6 Feb 2021 15:43:42 +0900 Subject: [PATCH 02/11] add color --- lib/style/_colors.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/style/_colors.scss b/lib/style/_colors.scss index 898854e..986f3da 100644 --- a/lib/style/_colors.scss +++ b/lib/style/_colors.scss @@ -6,4 +6,10 @@ $colors: ( "lightGray": #e6e6e6, "border": #dae1e6, "disabled": #6c757d65, + "danger": #ff4444, + "danger-dark": #cc0000, + "warning": #ffbb33, + "warning-dark": #ff8800, + "success": #00c851, + "success-dark": #007e33, ); From 093798b61743216a6e1e370f470de7e80af39b36 Mon Sep 17 00:00:00 2001 From: ziponia Date: Sat, 6 Feb 2021 16:45:26 +0900 Subject: [PATCH 03/11] add button variant --- lib/atoms/Button/Button.scss | 17 ++++++++++++++++- lib/atoms/Button/Button.tsx | 3 ++- stories/atoms/Button.stories.tsx | 14 +++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/atoms/Button/Button.scss b/lib/atoms/Button/Button.scss index d2fbf41..996ef33 100644 --- a/lib/atoms/Button/Button.scss +++ b/lib/atoms/Button/Button.scss @@ -4,13 +4,28 @@ @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"); 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/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", } From 9378596482628915322edefa03f09d5cda385116 Mon Sep 17 00:00:00 2001 From: ziponia Date: Sat, 6 Feb 2021 17:09:12 +0900 Subject: [PATCH 04/11] add form input --- lib/molecules/FormInput/FormInput.scss | 13 ++++++++++ lib/molecules/FormInput/FormInput.tsx | 28 ++++++++++++++++++++++ lib/molecules/FormInput/index.ts | 1 + stories/molecules/FormInput.stories.tsx | 32 +++++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 lib/molecules/FormInput/FormInput.scss create mode 100644 lib/molecules/FormInput/FormInput.tsx create mode 100644 lib/molecules/FormInput/index.ts create mode 100644 stories/molecules/FormInput.stories.tsx 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/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", +} From 65a9e369b5fa68c881aaedbcf1e26242b4b1802e Mon Sep 17 00:00:00 2001 From: ziponia Date: Sun, 7 Feb 2021 19:52:08 +0900 Subject: [PATCH 05/11] =?UTF-8?q?modal=20animation=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/organisms/Modal/Modal.scss | 119 ++++++++++------------------ lib/organisms/Modal/Modal.tsx | 77 ++++++++++-------- stories/organisms/Modal.stories.tsx | 4 +- 3 files changed, 89 insertions(+), 111 deletions(-) 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/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, } From afb91da4dc00cc644c6a6247431dbee0a91dced5 Mon Sep 17 00:00:00 2001 From: ziponia Date: Sun, 7 Feb 2021 19:58:22 +0900 Subject: [PATCH 06/11] update contributor --- package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 32fbb41..e71eb04 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,13 @@ "email": "thtjwls@gmail.com", "url": "https://github.com/ziponia" }, - "contributors": [], + "contributors": [ + { + "email": "jehy0807@gmail.com", + "name": "JiEun-Choi-Dev", + "url": "https://github.com/JiEun-Choi-Dev" + } + ], "main": "dist/index.js", "types": "dist/lib/index.d.ts", "files": [ From 0f5b703282ab5e2f87bbadb7c4eb701bef0efd5d Mon Sep 17 00:00:00 2001 From: ziponia Date: Sun, 7 Feb 2021 20:25:32 +0900 Subject: [PATCH 07/11] change hosting netlify --- .github/workflows/build-ui.yml | 12 +----------- README.md => README.mdx | 1 + package.json | 6 +++--- 3 files changed, 5 insertions(+), 14 deletions(-) rename README.md => README.mdx (76%) 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/README.md b/README.mdx similarity index 76% rename from README.md rename to README.mdx index f1bf62d..414401e 100644 --- a/README.md +++ b/README.mdx @@ -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/package.json b/package.json index e71eb04..6bebcc4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "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" @@ -18,8 +18,8 @@ }, "contributors": [ { - "email": "jehy0807@gmail.com", "name": "JiEun-Choi-Dev", + "email": "jehy0807@gmail.com", "url": "https://github.com/JiEun-Choi-Dev" } ], @@ -31,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", From b297782698490eea962c7a3fd29abc2f0b53302d Mon Sep 17 00:00:00 2001 From: ziponia Date: Mon, 8 Feb 2021 20:45:16 +0900 Subject: [PATCH 08/11] closed #12 --- lib/atoms/Button/Button.scss | 2 ++ lib/atoms/CheckBox/CheckBox.scss | 7 +++++++ lib/atoms/Input/Input.scss | 9 ++++++++- lib/atoms/TextArea/TextArea.scss | 2 ++ lib/style/_colors.scss | 3 ++- lib/style/_import.scss | 8 ++++---- lib/style/_mixin.scss | 2 +- stories/atoms/Checkbox.stories.tsx | 8 +++++--- stories/atoms/Input.stories.tsx | 10 +++++++--- stories/atoms/TextArea.stories.tsx | 1 + 10 files changed, 39 insertions(+), 13 deletions(-) diff --git a/lib/atoms/Button/Button.scss b/lib/atoms/Button/Button.scss index 996ef33..a1cdbfb 100644 --- a/lib/atoms/Button/Button.scss +++ b/lib/atoms/Button/Button.scss @@ -28,6 +28,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/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/style/_colors.scss b/lib/style/_colors.scss index 986f3da..7cae31d 100644 --- a/lib/style/_colors.scss +++ b/lib/style/_colors.scss @@ -5,7 +5,8 @@ $colors: ( "lightDark": #666666, "lightGray": #e6e6e6, "border": #dae1e6, - "disabled": #6c757d65, + "disabled": #cccccc, + "disabled-dark": #888888, "danger": #ff4444, "danger-dark": #cc0000, "warning": #ffbb33, 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/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: "", } From 5a5f9d56f6080a2455d6f056c0fddf74d6e54e08 Mon Sep 17 00:00:00 2001 From: JiEun-Choi-Dev Date: Mon, 8 Feb 2021 22:51:20 +0900 Subject: [PATCH 09/11] Add Basic Calendar --- lib/index.ts | 1 + lib/organisms/DatePicker/DatePicker.scss | 107 +++++++++++++++++++++++ lib/organisms/DatePicker/DatePicker.tsx | 101 +++++++++++++++++++++ lib/organisms/DatePicker/index.ts | 1 + package.json | 5 ++ stories/organisms/DatePicker.stories.tsx | 55 ++++++++++++ 6 files changed, 270 insertions(+) create mode 100644 lib/organisms/DatePicker/DatePicker.scss create mode 100644 lib/organisms/DatePicker/DatePicker.tsx create mode 100644 lib/organisms/DatePicker/index.ts create mode 100644 stories/organisms/DatePicker.stories.tsx diff --git a/lib/index.ts b/lib/index.ts index b6a3381..fcfecc3 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -13,3 +13,4 @@ export * from "./molecules/ButtonGroup" export * from "./molecules/Panel" export * from "./organisms/Modal" +export * from "./organisms/DatePicker" 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/package.json b/package.json index 6bebcc4..94c98ec 100644 --- a/package.json +++ b/package.json @@ -43,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/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, +} From a5eb03bb85529e8d4c99c60feb7aeccd5448528c Mon Sep 17 00:00:00 2001 From: ziponia Date: Mon, 8 Feb 2021 23:23:45 +0900 Subject: [PATCH 10/11] v0.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 94c98ec..b834017 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keobee-ui", - "version": "0.4.0", + "version": "0.5.0", "keywords": [ "react", "react-ui" From f30554e623ccd886cb3815f4469db3e6713dbee6 Mon Sep 17 00:00:00 2001 From: ziponia Date: Tue, 9 Feb 2021 22:54:20 +0900 Subject: [PATCH 11/11] =?UTF-8?q?Project=20Guideline=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 26 ++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.mdx => README.md | 0 3 files changed, 47 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE rename README.mdx => README.md (100%) 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.mdx b/README.md similarity index 100% rename from README.mdx rename to README.md