From e4f49114aacd23567334faa6e64919e3db099f63 Mon Sep 17 00:00:00 2001 From: jinhojang6 Date: Thu, 6 Apr 2023 22:39:07 +0900 Subject: [PATCH] refactor: add variant of outlined and outlined bottom --- .../Autocomplete/Autocomplete.classes.ts | 3 ++- .../Autocomplete/Autocomplete.stories.tsx | 9 ++++++++- .../components/Autocomplete/Autocomplete.styles.ts | 11 ++++++----- .../src/components/Autocomplete/Autocomplete.tsx | 8 +++++--- .../src/components/Dropdown/Dropdown.classes.ts | 3 ++- .../src/components/Dropdown/Dropdown.stories.tsx | 11 ++++++++++- .../src/components/Dropdown/Dropdown.styles.ts | 14 +++++++------- .../lsd-react/src/components/Dropdown/Dropdown.tsx | 12 ++++++++---- .../src/components/TextField/TextField.classes.ts | 3 ++- .../src/components/TextField/TextField.stories.tsx | 9 ++++++++- .../src/components/TextField/TextField.styles.ts | 11 ++++++----- .../src/components/TextField/TextField.tsx | 8 +++++--- 12 files changed, 69 insertions(+), 33 deletions(-) diff --git a/packages/lsd-react/src/components/Autocomplete/Autocomplete.classes.ts b/packages/lsd-react/src/components/Autocomplete/Autocomplete.classes.ts index 046ca36..6b7da9f 100644 --- a/packages/lsd-react/src/components/Autocomplete/Autocomplete.classes.ts +++ b/packages/lsd-react/src/components/Autocomplete/Autocomplete.classes.ts @@ -14,5 +14,6 @@ export const autocompleteClasses = { large: `lsd-autocomplete--large`, medium: `lsd-autocomplete--medium`, withIcon: `lsd-autocomplete--with-icon`, - bottomOutline: `lsd-autocomplete--bottom-outline`, + outlined: `lsd-autocomplete--outlined`, + outlinedBottom: `lsd-autocomplete--outlined-bottom`, } diff --git a/packages/lsd-react/src/components/Autocomplete/Autocomplete.stories.tsx b/packages/lsd-react/src/components/Autocomplete/Autocomplete.stories.tsx index 4577aaf..d14128c 100644 --- a/packages/lsd-react/src/components/Autocomplete/Autocomplete.stories.tsx +++ b/packages/lsd-react/src/components/Autocomplete/Autocomplete.stories.tsx @@ -16,6 +16,13 @@ export default { }, defaultValue: 'large', }, + variant: { + type: { + name: 'enum', + value: ['outlined', 'outlined-bottom'], + }, + defaultValue: 'large', + }, }, } as Meta @@ -27,7 +34,7 @@ Root.args = { disabled: false, withIcon: false, error: false, - bottomOutline: false, + variant: 'outlined', placeholder: 'Placeholder', onChange: undefined, options: list, diff --git a/packages/lsd-react/src/components/Autocomplete/Autocomplete.styles.ts b/packages/lsd-react/src/components/Autocomplete/Autocomplete.styles.ts index fa7eacb..a2cc51e 100644 --- a/packages/lsd-react/src/components/Autocomplete/Autocomplete.styles.ts +++ b/packages/lsd-react/src/components/Autocomplete/Autocomplete.styles.ts @@ -4,7 +4,6 @@ import { autocompleteClasses } from './Autocomplete.classes' export const AutocompleteStyles = css` .${autocompleteClasses.root} { width: auto; - border: 1px solid rgb(var(--lsd-border-primary)); box-sizing: border-box; align-items: center; } @@ -81,9 +80,11 @@ export const AutocompleteStyles = css` white-space: pre; } - .${autocompleteClasses.bottomOutline} { - border-top: none; - border-left: none; - border-right: none; + .${autocompleteClasses.outlined} { + border: 1px solid rgb(var(--lsd-border-primary)); + } + + .${autocompleteClasses.outlinedBottom} { + border-bottom: 1px solid rgb(var(--lsd-border-primary)); } ` diff --git a/packages/lsd-react/src/components/Autocomplete/Autocomplete.tsx b/packages/lsd-react/src/components/Autocomplete/Autocomplete.tsx index 42166e6..fc050a1 100644 --- a/packages/lsd-react/src/components/Autocomplete/Autocomplete.tsx +++ b/packages/lsd-react/src/components/Autocomplete/Autocomplete.tsx @@ -21,7 +21,7 @@ export type AutocompleteProps = Omit< defaultValue?: string options?: string[] inputProps?: React.InputHTMLAttributes - bottomOutline?: boolean + variant?: 'outlined' | 'outlined-bottom' } export const Autocomplete: React.FC & { @@ -38,7 +38,7 @@ export const Autocomplete: React.FC & { onChange, options = [], inputProps = {}, - bottomOutline = false, + variant = 'outlined', ...props }) => { const ref = useRef(null) @@ -88,7 +88,9 @@ export const Autocomplete: React.FC & { autocompleteClasses[size], disabled && autocompleteClasses.disabled, withIcon && autocompleteClasses.withIcon, - bottomOutline && autocompleteClasses.bottomOutline, + variant === 'outlined' + ? autocompleteClasses.outlined + : autocompleteClasses.outlinedBottom, )} {...props} > diff --git a/packages/lsd-react/src/components/Dropdown/Dropdown.classes.ts b/packages/lsd-react/src/components/Dropdown/Dropdown.classes.ts index 417a49b..5320e5c 100644 --- a/packages/lsd-react/src/components/Dropdown/Dropdown.classes.ts +++ b/packages/lsd-react/src/components/Dropdown/Dropdown.classes.ts @@ -18,5 +18,6 @@ export const dropdownClasses = { small: `lsd-dropdown--small`, medium: `lsd-dropdown--medium`, large: `lsd-dropdown--large`, - bottomOutline: `lsd-dropdown--bottom-outline`, + outlined: `lsd-dropdown--outlined`, + outlinedBottom: `lsd-dropdown--outlined-bottom`, } diff --git a/packages/lsd-react/src/components/Dropdown/Dropdown.stories.tsx b/packages/lsd-react/src/components/Dropdown/Dropdown.stories.tsx index 24921ba..f4d9cd9 100644 --- a/packages/lsd-react/src/components/Dropdown/Dropdown.stories.tsx +++ b/packages/lsd-react/src/components/Dropdown/Dropdown.stories.tsx @@ -4,6 +4,15 @@ import { Dropdown, DropdownProps } from './Dropdown' export default { title: 'Dropdown', component: Dropdown, + argTypes: { + variant: { + type: { + name: 'enum', + value: ['outlined', 'outlined-bottom'], + }, + defaultValue: 'large', + }, + }, } as Meta export const Root: Story = (args) => ( @@ -19,7 +28,7 @@ Root.args = { disabled: false, error: false, multi: false, - bottomOutline: false, + variant: 'outlined', onChange: undefined, options: new Array(16).fill(null).map((value, index) => ({ value: `${index}`, diff --git a/packages/lsd-react/src/components/Dropdown/Dropdown.styles.ts b/packages/lsd-react/src/components/Dropdown/Dropdown.styles.ts index c91c352..8643492 100644 --- a/packages/lsd-react/src/components/Dropdown/Dropdown.styles.ts +++ b/packages/lsd-react/src/components/Dropdown/Dropdown.styles.ts @@ -26,10 +26,10 @@ export const DropdownStyles = css` align-items: center; justify-content: space-between; padding: 10px 14px 10px 18px; + border: none; cursor: pointer; background: none; - border: 1px solid rgb(var(--lsd-border-primary)); &:focus { outline: none; @@ -102,11 +102,11 @@ export const DropdownStyles = css` } } - .${dropdownClasses.bottomOutline} { - .${dropdownClasses.trigger} { - border-top: none; - border-left: none; - border-right: none; - } + .${dropdownClasses.outlined} { + border: 1px solid rgb(var(--lsd-border-primary)); + } + + .${dropdownClasses.outlinedBottom} { + border-bottom: 1px solid rgb(var(--lsd-border-primary)); } ` diff --git a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx index 062e6d7..178f5bf 100644 --- a/packages/lsd-react/src/components/Dropdown/Dropdown.tsx +++ b/packages/lsd-react/src/components/Dropdown/Dropdown.tsx @@ -24,7 +24,7 @@ export type DropdownProps = Omit< options?: DropdownOption[] value?: string | string[] onChange?: (value: string | string[]) => void - bottomOutline?: boolean + variant?: 'outlined' | 'outlined-bottom' } export const Dropdown: React.FC & { @@ -40,7 +40,7 @@ export const Dropdown: React.FC & { onChange, options = [], multi = false, - bottomOutline = false, + variant = 'outlined', ...props }) => { const ref = useRef(null) @@ -72,12 +72,16 @@ export const Dropdown: React.FC & { error && dropdownClasses.error, disabled && dropdownClasses.disabled, open && dropdownClasses.open, - bottomOutline && dropdownClasses.bottomOutline, )} >