@lunit/design-system 2.1.0 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc.json +1 -1
- package/README.md +22 -21
- package/dist/cjs/components/Alert/index.js +1 -1
- package/dist/cjs/components/Alert/index.js.map +1 -1
- package/dist/cjs/components/Button/index.js +1 -1
- package/dist/cjs/components/Button/index.js.map +1 -1
- package/dist/cjs/components/Checkbox/index.js +1 -1
- package/dist/cjs/components/Checkbox/index.js.map +1 -1
- package/dist/cjs/components/Chip/index.js +1 -1
- package/dist/cjs/components/Chip/index.js.map +1 -1
- package/dist/cjs/components/DataTable/index.js.map +1 -1
- package/dist/cjs/components/DatePicker/index.js.map +1 -1
- package/dist/cjs/components/Dialog/index.js +1 -1
- package/dist/cjs/components/Dialog/index.js.map +1 -1
- package/dist/cjs/components/Dropdown/index.js +1 -1
- package/dist/cjs/components/Dropdown/index.js.map +1 -1
- package/dist/cjs/components/FormLabel/index.js +1 -1
- package/dist/cjs/components/FormLabel/index.js.map +1 -1
- package/dist/cjs/components/Radio/index.js +1 -1
- package/dist/cjs/components/Radio/index.js.map +1 -1
- package/dist/cjs/components/RadioGroup/index.js.map +1 -1
- package/dist/cjs/components/TextField/index.js +1 -1
- package/dist/cjs/components/TextField/index.js.map +1 -1
- package/dist/cjs/components/Toggle/index.js +1 -1
- package/dist/cjs/components/Toggle/index.js.map +1 -1
- package/dist/cjs/components/ToggleButton/index.js +1 -1
- package/dist/cjs/components/ToggleButton/index.js.map +1 -1
- package/dist/cjs/components/Tooltip/index.js.map +1 -1
- package/dist/cjs/components/Typography/index.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/Alert/Alert.js +8 -8
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/Alert/Alert.styled.js +26 -26
- package/dist/components/Alert/Alert.styled.js.map +1 -1
- package/dist/components/Alert/Alert.utils.js +9 -9
- package/dist/components/Alert/Alert.utils.js.map +1 -1
- package/dist/components/Alert/index.js +1 -1
- package/dist/components/Button/Button.js +23 -17
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.styled.js +88 -88
- package/dist/components/Button/Button.styled.js.map +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/utils/getButtonPaddingBySizeAndKind.js +9 -9
- package/dist/components/Button/utils/getButtonPaddingBySizeAndKind.js.map +1 -1
- package/dist/components/Button/utils/getHoverStyle.js +1 -1
- package/dist/components/Button/utils/getHoverStyle.js.map +1 -1
- package/dist/components/Button/utils/getIconButtonPaddingBySizeAndKind.js +6 -12
- package/dist/components/Button/utils/getIconButtonPaddingBySizeAndKind.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +9 -9
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Chip/Chip.js +29 -26
- package/dist/components/Chip/Chip.js.map +1 -1
- package/dist/components/Chip/Chip.styled.js +52 -52
- package/dist/components/Chip/Chip.styled.js.map +1 -1
- package/dist/components/Chip/consts.js +5 -5
- package/dist/components/Chip/index.js +1 -1
- package/dist/components/DataTable/DataTable.js +1 -1
- package/dist/components/DataTable/index.js +1 -1
- package/dist/components/DatePicker/DatePicker.js +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Dialog/Dialog.js +18 -18
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Dialog/Dialog.styled.js +90 -90
- package/dist/components/Dialog/Dialog.styled.js.map +1 -1
- package/dist/components/Dialog/components/DialogAction.js +6 -6
- package/dist/components/Dialog/index.js +1 -1
- package/dist/components/Dropdown/Dropdown.js +23 -21
- package/dist/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.styled.js +85 -86
- package/dist/components/Dropdown/Dropdown.styled.js.map +1 -1
- package/dist/components/Dropdown/DropdownItem.js +14 -14
- package/dist/components/Dropdown/DropdownItem.js.map +1 -1
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/FormLabel/FormLabel.js +1 -1
- package/dist/components/FormLabel/FormLabel.styled.js +2 -2
- package/dist/components/FormLabel/FormLabel.styled.js.map +1 -1
- package/dist/components/FormLabel/index.js +1 -1
- package/dist/components/Radio/Radio.js +8 -8
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Radio/index.js +1 -1
- package/dist/components/RadioGroup/index.js +1 -1
- package/dist/components/TextField/TextField.js +8 -8
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/TextField.style.js +112 -112
- package/dist/components/TextField/TextField.style.js.map +1 -1
- package/dist/components/TextField/TextFieldIcon.js +2 -2
- package/dist/components/TextField/TextFieldIcon.js.map +1 -1
- package/dist/components/TextField/index.js +1 -1
- package/dist/components/Toast/Toast.js +13 -13
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/Toast.styled.js +26 -26
- package/dist/components/Toast/Toast.utils.js +3 -3
- package/dist/components/Toast/Toast.utils.js.map +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/Toggle/Toggle.js +3 -4
- package/dist/components/Toggle/Toggle.js.map +1 -1
- package/dist/components/Toggle/Toggle.styled.js +30 -30
- package/dist/components/Toggle/Toggle.styled.js.map +1 -1
- package/dist/components/Toggle/index.js +1 -1
- package/dist/components/ToggleButton/ToggleButton.js +6 -6
- package/dist/components/ToggleButton/ToggleButton.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.styled.js +20 -20
- package/dist/components/ToggleButton/ToggleButton.styled.js.map +1 -1
- package/dist/components/ToggleButton/index.js +1 -1
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.js +2 -2
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.js.map +1 -1
- package/dist/components/ToggleButtonGroup/index.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tooltip/index.js +1 -1
- package/dist/components/Typography/Typography.js +1 -1
- package/dist/components/Typography/Typography.js.map +1 -1
- package/dist/components/Typography/index.js +1 -1
- package/dist/foundation/Elevation/index.js +27 -27
- package/dist/foundation/Elevation/utils.js +1 -1
- package/dist/foundation/Elevation/utils.js.map +1 -1
- package/dist/foundation/Typography/index.js +35 -35
- package/dist/foundation/Typography/index.js.map +1 -1
- package/dist/foundation/Typography/tokens.js +136 -136
- package/dist/foundation/Typography/tokens.js.map +1 -1
- package/dist/foundation/colors/base/blue.js +12 -12
- package/dist/foundation/colors/base/green.js +12 -12
- package/dist/foundation/colors/base/grey.js +28 -28
- package/dist/foundation/colors/base/index.js +11 -11
- package/dist/foundation/colors/base/lunitGreen.js +11 -11
- package/dist/foundation/colors/base/lunitTeal.js +12 -12
- package/dist/foundation/colors/base/magenta.js +12 -12
- package/dist/foundation/colors/base/opacity.js +4 -4
- package/dist/foundation/colors/base/orange.js +12 -12
- package/dist/foundation/colors/base/purple.js +12 -12
- package/dist/foundation/colors/base/red.js +12 -12
- package/dist/foundation/colors/base/yellow.js +12 -12
- package/dist/foundation/colors/index.js +119 -121
- package/dist/foundation/colors/index.js.map +1 -1
- package/dist/foundation/colors/token/component.js +184 -212
- package/dist/foundation/colors/token/component.js.map +1 -1
- package/dist/foundation/colors/token/core.js +112 -133
- package/dist/foundation/colors/token/core.js.map +1 -1
- package/dist/foundation/colors/token/index.js +2 -2
- package/dist/foundation/index.js +5 -5
- package/dist/index.js +20 -20
- package/dist/theme.js +6 -6
- package/dist/types/components/Alert/Alert.d.ts +2 -2
- package/dist/types/components/Alert/Alert.styled.d.ts +1 -2
- package/dist/types/components/Alert/Alert.types.d.ts +2 -2
- package/dist/types/components/Alert/Alert.utils.d.ts +1 -1
- package/dist/types/components/Alert/index.d.ts +1 -1
- package/dist/types/components/Button/Button.d.ts +1 -1
- package/dist/types/components/Button/Button.styled.d.ts +249 -265
- package/dist/types/components/Button/Button.types.d.ts +16 -16
- package/dist/types/components/Button/index.d.ts +1 -1
- package/dist/types/components/Button/utils/getButtonPaddingBySizeAndKind.d.ts +4 -4
- package/dist/types/components/Button/utils/getHoverStyle.d.ts +2 -1
- package/dist/types/components/Button/utils/getIconButtonPaddingBySizeAndKind.d.ts +4 -4
- package/dist/types/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/types/components/Checkbox/index.d.ts +1 -1
- package/dist/types/components/Chip/Chip.d.ts +1 -1
- package/dist/types/components/Chip/Chip.styled.d.ts +6 -79
- package/dist/types/components/Chip/Chip.types.d.ts +15 -14
- package/dist/types/components/Chip/index.d.ts +1 -1
- package/dist/types/components/DataTable/index.d.ts +1 -1
- package/dist/types/components/DatePicker/index.d.ts +1 -1
- package/dist/types/components/Dialog/Dialog.d.ts +11 -11
- package/dist/types/components/Dialog/Dialog.styled.d.ts +3 -4
- package/dist/types/components/Dialog/components/DialogAction.d.ts +2 -2
- package/dist/types/components/Dialog/index.d.ts +2 -2
- package/dist/types/components/Dropdown/Dropdown.d.ts +2 -2
- package/dist/types/components/Dropdown/Dropdown.styled.d.ts +4 -39
- package/dist/types/components/Dropdown/Dropdown.types.d.ts +5 -5
- package/dist/types/components/Dropdown/DropdownItem.d.ts +3 -3
- package/dist/types/components/Dropdown/index.d.ts +3 -3
- package/dist/types/components/FormLabel/FormLabel.d.ts +1 -1
- package/dist/types/components/FormLabel/index.d.ts +1 -1
- package/dist/types/components/Radio/Radio.d.ts +1 -1
- package/dist/types/components/Radio/index.d.ts +1 -1
- package/dist/types/components/RadioGroup/index.d.ts +1 -1
- package/dist/types/components/TextField/TextField.d.ts +2 -2
- package/dist/types/components/TextField/TextField.style.d.ts +3 -4
- package/dist/types/components/TextField/TextField.types.d.ts +6 -6
- package/dist/types/components/TextField/TextFieldIcon.d.ts +2 -2
- package/dist/types/components/TextField/index.d.ts +2 -2
- package/dist/types/components/Toast/Toast.d.ts +2 -2
- package/dist/types/components/Toast/Toast.types.d.ts +3 -3
- package/dist/types/components/Toast/Toast.utils.d.ts +1 -1
- package/dist/types/components/Toast/index.d.ts +2 -2
- package/dist/types/components/Toggle/Toggle.d.ts +1 -1
- package/dist/types/components/Toggle/Toggle.styled.d.ts +2 -2
- package/dist/types/components/Toggle/Toggle.types.d.ts +3 -3
- package/dist/types/components/Toggle/index.d.ts +1 -1
- package/dist/types/components/ToggleButton/ToggleButton.d.ts +1 -1
- package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +2 -34
- package/dist/types/components/ToggleButton/ToggleButton.types.d.ts +10 -10
- package/dist/types/components/ToggleButton/index.d.ts +1 -1
- package/dist/types/components/ToggleButtonGroup/ToggleButtonGroup.d.ts +1 -1
- package/dist/types/components/ToggleButtonGroup/index.d.ts +1 -1
- package/dist/types/components/Tooltip/index.d.ts +1 -1
- package/dist/types/components/Typography/Typography.d.ts +6 -6
- package/dist/types/components/Typography/index.d.ts +1 -1
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/foundation/Elevation/index.d.ts +22 -22
- package/dist/types/foundation/Typography/index.d.ts +78 -78
- package/dist/types/foundation/Typography/tokens.d.ts +69 -69
- package/dist/types/foundation/colors/base/index.d.ts +11 -11
- package/dist/types/foundation/colors/index.d.ts +13 -20
- package/dist/types/foundation/colors/token/component.d.ts +1 -1
- package/dist/types/foundation/colors/token/core.d.ts +1 -1
- package/dist/types/foundation/colors/token/index.d.ts +2 -2
- package/dist/types/foundation/colors/types.d.ts +0 -7
- package/dist/types/foundation/index.d.ts +4 -11
- package/dist/types/foundation/spacing.d.ts +1 -1
- package/dist/types/index.d.ts +20 -20
- package/dist/types/theme.d.ts +1 -1
- package/package.json +22 -26
- package/src/components/Alert/Alert.styled.ts +39 -49
- package/src/components/Alert/Alert.tsx +10 -16
- package/src/components/Alert/Alert.types.ts +2 -2
- package/src/components/Alert/Alert.utils.ts +13 -22
- package/src/components/Alert/index.ts +1 -1
- package/src/components/Button/Button.styled.ts +98 -101
- package/src/components/Button/Button.tsx +71 -69
- package/src/components/Button/Button.types.ts +19 -21
- package/src/components/Button/index.ts +1 -1
- package/src/components/Button/utils/getButtonPaddingBySizeAndKind.ts +13 -13
- package/src/components/Button/utils/getHoverStyle.ts +4 -2
- package/src/components/Button/utils/getIconButtonPaddingBySizeAndKind.ts +10 -19
- package/src/components/Checkbox/Checkbox.tsx +13 -25
- package/src/components/Checkbox/index.ts +1 -1
- package/src/components/Chip/Chip.styled.ts +69 -72
- package/src/components/Chip/Chip.tsx +33 -55
- package/src/components/Chip/Chip.types.ts +18 -24
- package/src/components/Chip/consts.ts +5 -5
- package/src/components/Chip/index.ts +1 -1
- package/src/components/DataTable/DataTable.tsx +2 -2
- package/src/components/DataTable/index.ts +1 -1
- package/src/components/DatePicker/DatePicker.tsx +2 -2
- package/src/components/DatePicker/index.ts +1 -1
- package/src/components/Dialog/Dialog.styled.ts +112 -114
- package/src/components/Dialog/Dialog.tsx +41 -46
- package/src/components/Dialog/components/DialogAction.tsx +8 -8
- package/src/components/Dialog/index.ts +3 -3
- package/src/components/Dropdown/Dropdown.styled.tsx +88 -89
- package/src/components/Dropdown/Dropdown.tsx +29 -30
- package/src/components/Dropdown/Dropdown.types.ts +6 -5
- package/src/components/Dropdown/DropdownItem.tsx +18 -29
- package/src/components/Dropdown/index.ts +3 -7
- package/src/components/FormLabel/FormLabel.styled.ts +3 -3
- package/src/components/FormLabel/FormLabel.tsx +3 -3
- package/src/components/FormLabel/index.ts +1 -1
- package/src/components/Radio/Radio.tsx +12 -29
- package/src/components/Radio/index.ts +1 -1
- package/src/components/RadioGroup/index.ts +1 -1
- package/src/components/TextField/TextField.style.ts +123 -132
- package/src/components/TextField/TextField.tsx +50 -62
- package/src/components/TextField/TextField.types.ts +7 -8
- package/src/components/TextField/TextFieldIcon.tsx +4 -7
- package/src/components/TextField/index.ts +2 -2
- package/src/components/Toast/Toast.styled.ts +26 -26
- package/src/components/Toast/Toast.tsx +14 -28
- package/src/components/Toast/Toast.types.ts +3 -8
- package/src/components/Toast/Toast.utils.ts +5 -8
- package/src/components/Toast/index.tsx +2 -2
- package/src/components/Toggle/Toggle.styled.ts +31 -32
- package/src/components/Toggle/Toggle.tsx +5 -11
- package/src/components/Toggle/Toggle.types.ts +3 -3
- package/src/components/Toggle/index.ts +1 -1
- package/src/components/ToggleButton/ToggleButton.styled.ts +47 -49
- package/src/components/ToggleButton/ToggleButton.tsx +91 -97
- package/src/components/ToggleButton/ToggleButton.types.ts +10 -10
- package/src/components/ToggleButton/index.ts +1 -1
- package/src/components/ToggleButtonGroup/ToggleButtonGroup.tsx +3 -8
- package/src/components/ToggleButtonGroup/index.tsx +1 -1
- package/src/components/Tooltip/Tooltip.tsx +2 -2
- package/src/components/Tooltip/index.ts +1 -1
- package/src/components/Typography/Typography.tsx +7 -10
- package/src/components/Typography/index.ts +1 -1
- package/src/components/index.ts +2 -2
- package/src/foundation/Elevation/index.ts +27 -27
- package/src/foundation/Elevation/utils.ts +14 -8
- package/src/foundation/Typography/index.ts +58 -57
- package/src/foundation/Typography/tokens.ts +138 -138
- package/src/foundation/colors/base/blue.ts +12 -12
- package/src/foundation/colors/base/green.ts +12 -12
- package/src/foundation/colors/base/grey.ts +28 -28
- package/src/foundation/colors/base/index.ts +11 -11
- package/src/foundation/colors/base/lunitGreen.ts +11 -11
- package/src/foundation/colors/base/lunitTeal.ts +12 -12
- package/src/foundation/colors/base/magenta.ts +12 -12
- package/src/foundation/colors/base/opacity.ts +4 -4
- package/src/foundation/colors/base/orange.ts +12 -12
- package/src/foundation/colors/base/purple.ts +12 -12
- package/src/foundation/colors/base/red.ts +12 -12
- package/src/foundation/colors/base/yellow.ts +12 -12
- package/src/foundation/colors/index.ts +119 -120
- package/src/foundation/colors/token/component.ts +185 -213
- package/src/foundation/colors/token/core.ts +113 -134
- package/src/foundation/colors/token/index.ts +2 -2
- package/src/foundation/colors/types.ts +0 -7
- package/src/foundation/index.ts +8 -8
- package/src/foundation/spacing.ts +1 -1
- package/src/index.ts +20 -20
- package/src/stories/GettingStarted.mdx +9 -15
- package/src/stories/components/Alert/Alert.stories.tsx +39 -46
- package/src/stories/components/Button/BasicButton.stories.tsx +68 -59
- package/src/stories/components/Button/ButtonDocs.mdx +17 -41
- package/src/stories/components/Button/Color.stories.tsx +28 -51
- package/src/stories/components/Button/IconButton.stories.tsx +40 -47
- package/src/stories/components/Button/Kind.stories.tsx +100 -213
- package/src/stories/components/CheckBox/BasicCheckbox.stories.tsx +52 -71
- package/src/stories/components/CheckBox/CheckboxDocs.mdx +6 -6
- package/src/stories/components/Chip/Chip.stories.tsx +75 -75
- package/src/stories/components/Chip/ChipDocs.mdx +12 -13
- package/src/stories/components/DataTable/DataTable.stories.tsx +4 -4
- package/src/stories/components/DatePicker/DatePicker.stories.tsx +4 -4
- package/src/stories/components/Dialog/Dialog.stories.tsx +103 -124
- package/src/stories/components/Dialog/DialogDocs.mdx +7 -13
- package/src/stories/components/Dropdown/Dropdown.stories.tsx +96 -82
- package/src/stories/components/Dropdown/DropdownDocs.mdx +275 -0
- package/src/stories/components/Dropdown/DropdownExamples.stories.tsx +40 -47
- package/src/stories/components/Dropdown/DropdownItem.stories.tsx +113 -98
- package/src/stories/components/SelectControl/RadioGroup.stories.tsx +17 -30
- package/src/stories/components/SelectControl/RadioStatus.stories.tsx +16 -23
- package/src/stories/components/SelectControl/Toggle.stories.tsx +33 -78
- package/src/stories/components/TextField/BasicTextField.stories.tsx +44 -60
- package/src/stories/components/TextField/TextFieldDocs.mdx +8 -12
- package/src/stories/components/TextField/TextFieldMulti.stories.tsx +39 -58
- package/src/stories/components/TextField/TextFieldSingle.stories.tsx +74 -121
- package/src/stories/components/TextField/TextFieldSize.stories.tsx +35 -56
- package/src/stories/components/Toast/Toast.stories.tsx +39 -49
- package/src/stories/components/ToggleButton/Basic.stories.tsx +237 -235
- package/src/stories/components/ToggleButton/ToggleButtonDocs.mdx +10 -14
- package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +144 -203
- package/src/stories/components/ToggleButton/WithIcon.stories.tsx +87 -107
- package/src/stories/components/Tooltip/Tooltip.stories.tsx +4 -4
- package/src/stories/foundation/Elevation/Elevation.stories.tsx +48 -73
- package/src/stories/foundation/Elevation/styled.ts +3 -3
- package/src/stories/foundation/Typography/Typography.mdx +9 -13
- package/src/stories/foundation/Typography/Typography.stories.tsx +25 -41
- package/src/stories/foundation/Typography/TypographyGroup.tsx +14 -25
- package/src/stories/foundation/Typography/const.ts +13 -19
- package/src/stories/foundation/colors/ColorSystem.tsx +42 -40
- package/src/stories/foundation/colors/Colors.stories.tsx +40 -41
- package/src/stories/foundation/colors/Docs.mdx +73 -77
- package/src/stories/foundation/colors/Mui.stories.tsx +6 -8
- package/src/stories/foundation/colors/Token.inComponent.stories.tsx +81 -71
- package/src/stories/foundation/colors/TokenPaletteTable.stories.tsx +7 -7
- package/src/stories/foundation/colors/TokenPaletteTable.tsx +23 -49
- package/src/stories/foundation/colors/styled.ts +26 -26
- package/src/theme.ts +6 -6
- package/src/types.d.ts +1 -1
- package/tsconfig.build.json +1 -5
- package/tsconfig.json +0 -1
- package/src/stories/components/ToggleButton/Group.stories.tsx +0 -221
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import { styled } from
|
|
2
|
-
import { Button as MuiButton } from
|
|
1
|
+
import { styled } from '@mui/material/styles';
|
|
2
|
+
import { Button as MuiButton } from '@mui/material';
|
|
3
3
|
|
|
4
|
-
import { ColorToken } from
|
|
5
|
-
import { PADDING_OF_FOCUS, OUTLINED_BORDER_WIDTH } from
|
|
6
|
-
import { getButtonPaddingBySizeAndKind } from
|
|
7
|
-
import { getIconButtonPaddingBySizeAndKind } from
|
|
8
|
-
import getHoverStyle from
|
|
4
|
+
import { ColorToken } from '@/foundation/colors/types';
|
|
5
|
+
import { PADDING_OF_FOCUS, OUTLINED_BORDER_WIDTH } from './const';
|
|
6
|
+
import { getButtonPaddingBySizeAndKind } from './utils/getButtonPaddingBySizeAndKind';
|
|
7
|
+
import { getIconButtonPaddingBySizeAndKind } from './utils/getIconButtonPaddingBySizeAndKind';
|
|
8
|
+
import getHoverStyle from './utils/getHoverStyle';
|
|
9
9
|
|
|
10
|
-
import type { ButtonProps } from
|
|
11
|
-
import type { ToggleButtonProps } from
|
|
12
|
-
import type {
|
|
10
|
+
import type { ButtonProps } from './Button.types';
|
|
11
|
+
import type { ToggleButtonProps } from '../ToggleButton/ToggleButton.types';
|
|
12
|
+
import type { TypographyVariants } from '@mui/material/styles';
|
|
13
13
|
|
|
14
|
-
type KindStyleParams = Pick<ButtonProps,
|
|
14
|
+
type KindStyleParams = Pick<ButtonProps, 'kind' | 'color'> & {
|
|
15
15
|
lunit_token: ColorToken;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
type CustomButtonProps = ButtonProps & { hasIconOnly: boolean };
|
|
19
19
|
|
|
20
|
-
type sizeStyleParams = Pick<
|
|
21
|
-
|
|
22
|
-
"size" | "hasIconOnly" | "kind"
|
|
23
|
-
> &
|
|
24
|
-
Pick<ToggleButtonProps, "selected"> & { typography: Typography };
|
|
20
|
+
type sizeStyleParams = Pick<CustomButtonProps, 'size' | 'hasIconOnly' | 'kind'> &
|
|
21
|
+
Pick<ToggleButtonProps, 'selected'> & { typography: TypographyVariants };
|
|
25
22
|
|
|
26
|
-
const borderRadius =
|
|
23
|
+
const borderRadius = '8px';
|
|
27
24
|
|
|
28
25
|
export const sizeStyle = ({
|
|
29
26
|
size,
|
|
@@ -32,145 +29,145 @@ export const sizeStyle = ({
|
|
|
32
29
|
typography,
|
|
33
30
|
selected = false,
|
|
34
31
|
}: sizeStyleParams) => ({
|
|
35
|
-
...(size ===
|
|
32
|
+
...(size === 'small' && {
|
|
36
33
|
...typography.button2,
|
|
37
34
|
padding: `${
|
|
38
35
|
hasIconOnly
|
|
39
36
|
? getIconButtonPaddingBySizeAndKind({ kind, size, selected })
|
|
40
37
|
: getButtonPaddingBySizeAndKind({ kind, size, selected })
|
|
41
38
|
}`,
|
|
42
|
-
minWidth:
|
|
43
|
-
height:
|
|
39
|
+
minWidth: '28px',
|
|
40
|
+
height: '28px',
|
|
44
41
|
}),
|
|
45
|
-
...(size ===
|
|
42
|
+
...(size === 'medium' && {
|
|
46
43
|
...typography.button2,
|
|
47
44
|
padding: `${
|
|
48
45
|
hasIconOnly
|
|
49
46
|
? getIconButtonPaddingBySizeAndKind({ kind, size, selected })
|
|
50
47
|
: getButtonPaddingBySizeAndKind({ kind, size, selected })
|
|
51
48
|
}`,
|
|
52
|
-
minWidth:
|
|
53
|
-
height:
|
|
49
|
+
minWidth: '36px',
|
|
50
|
+
height: '36px',
|
|
54
51
|
}),
|
|
55
|
-
...(size ===
|
|
52
|
+
...(size === 'large' && {
|
|
56
53
|
...typography.button1,
|
|
57
54
|
padding: `${
|
|
58
55
|
hasIconOnly
|
|
59
56
|
? getIconButtonPaddingBySizeAndKind({ kind, size, selected })
|
|
60
57
|
: getButtonPaddingBySizeAndKind({ kind, size, selected })
|
|
61
58
|
}`,
|
|
62
|
-
minWidth:
|
|
63
|
-
height:
|
|
59
|
+
minWidth: '44px',
|
|
60
|
+
height: '44px',
|
|
64
61
|
}),
|
|
65
62
|
});
|
|
66
63
|
|
|
67
64
|
export const kindStyle = ({ kind, color, lunit_token }: KindStyleParams) => ({
|
|
68
65
|
// kind: container
|
|
69
|
-
...(kind ===
|
|
70
|
-
color ===
|
|
66
|
+
...(kind === 'contained' &&
|
|
67
|
+
color === 'primary' && {
|
|
71
68
|
color: lunit_token.component.btn_primary_text_2,
|
|
72
69
|
backgroundColor: lunit_token.component.btn_primary_bg,
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
'&:hover': getHoverStyle(lunit_token.component.btn_primary_bg),
|
|
71
|
+
'&.Mui-disabled': {
|
|
75
72
|
opacity: 0.38,
|
|
76
|
-
border:
|
|
73
|
+
border: 'none',
|
|
77
74
|
color: lunit_token.component.btn_primary_text_2,
|
|
78
75
|
},
|
|
79
76
|
}),
|
|
80
|
-
...(kind ===
|
|
81
|
-
color ===
|
|
77
|
+
...(kind === 'contained' &&
|
|
78
|
+
color === 'secondary' && {
|
|
82
79
|
color: lunit_token.component.btn_secondary_text,
|
|
83
80
|
backgroundColor: lunit_token.component.btn_secondary_bg,
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
'&:hover': getHoverStyle(lunit_token.component.btn_secondary_bg),
|
|
82
|
+
'&.Mui-disabled': {
|
|
86
83
|
opacity: 0.38,
|
|
87
|
-
border:
|
|
84
|
+
border: 'none',
|
|
88
85
|
color: lunit_token.component.btn_secondary_text,
|
|
89
86
|
},
|
|
90
87
|
}),
|
|
91
|
-
...(kind ===
|
|
92
|
-
color ===
|
|
88
|
+
...(kind === 'contained' &&
|
|
89
|
+
color === 'error' && {
|
|
93
90
|
color: lunit_token.component.btn_primary_text_2,
|
|
94
91
|
backgroundColor: lunit_token.component.btn_error_bg,
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
'&:hover': getHoverStyle(lunit_token.component.btn_error_bg),
|
|
93
|
+
'&.Mui-disabled': {
|
|
97
94
|
opacity: 0.38,
|
|
98
|
-
border:
|
|
95
|
+
border: 'none',
|
|
99
96
|
color: lunit_token.component.btn_primary_text_2,
|
|
100
97
|
},
|
|
101
98
|
}),
|
|
102
99
|
// kind: ghost
|
|
103
|
-
...(kind ===
|
|
104
|
-
color ===
|
|
100
|
+
...(kind === 'ghost' &&
|
|
101
|
+
color === 'primary' && {
|
|
105
102
|
color: lunit_token.component.btn_primary_text_1,
|
|
106
|
-
border:
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
border: 'none',
|
|
104
|
+
'&:hover': getHoverStyle('none'),
|
|
105
|
+
'&.Mui-disabled': {
|
|
109
106
|
opacity: 0.38,
|
|
110
|
-
border:
|
|
107
|
+
border: 'none',
|
|
111
108
|
color: lunit_token.component.btn_primary_text_1,
|
|
112
109
|
},
|
|
113
110
|
}),
|
|
114
|
-
...(kind ===
|
|
115
|
-
color ===
|
|
111
|
+
...(kind === 'ghost' &&
|
|
112
|
+
color === 'secondary' && {
|
|
116
113
|
color: lunit_token.component.btn_secondary_text,
|
|
117
|
-
border:
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
border: 'none',
|
|
115
|
+
'&:hover': getHoverStyle('none'),
|
|
116
|
+
'&.Mui-disabled': {
|
|
120
117
|
opacity: 0.38,
|
|
121
|
-
border:
|
|
118
|
+
border: 'none',
|
|
122
119
|
color: lunit_token.component.btn_secondary_text,
|
|
123
120
|
},
|
|
124
121
|
}),
|
|
125
|
-
...(kind ===
|
|
126
|
-
color ===
|
|
122
|
+
...(kind === 'ghost' &&
|
|
123
|
+
color === 'error' && {
|
|
127
124
|
color: lunit_token.component.btn_error_text,
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
'&:hover': getHoverStyle('none'),
|
|
126
|
+
'&.Mui-disabled': {
|
|
130
127
|
opacity: 0.38,
|
|
131
|
-
border:
|
|
128
|
+
border: 'none',
|
|
132
129
|
color: lunit_token.component.btn_error_text,
|
|
133
130
|
},
|
|
134
131
|
}),
|
|
135
132
|
// kind: outlined
|
|
136
|
-
...(kind ===
|
|
137
|
-
color ===
|
|
133
|
+
...(kind === 'outlined' &&
|
|
134
|
+
color === 'primary' && {
|
|
138
135
|
color: lunit_token.component.btn_primary_text_1,
|
|
139
136
|
border: `${OUTLINED_BORDER_WIDTH}px solid ${lunit_token.component.btn_primary_border}`,
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
'&:hover': getHoverStyle('none'),
|
|
138
|
+
'&:hover:before': {
|
|
142
139
|
content: "''",
|
|
143
|
-
position:
|
|
144
|
-
left:
|
|
145
|
-
top:
|
|
146
|
-
width:
|
|
147
|
-
height:
|
|
140
|
+
position: 'absolute',
|
|
141
|
+
left: '-1px',
|
|
142
|
+
top: '-1px',
|
|
143
|
+
width: 'calc(100% + 2px)',
|
|
144
|
+
height: 'calc(100% + 2px)',
|
|
148
145
|
zIndex: -1,
|
|
149
|
-
backgroundColor: lunit_token.core.
|
|
146
|
+
backgroundColor: lunit_token.core.status_hover,
|
|
150
147
|
borderRadius,
|
|
151
148
|
},
|
|
152
|
-
|
|
149
|
+
'&.Mui-disabled': {
|
|
153
150
|
opacity: 0.38,
|
|
154
151
|
color: lunit_token.component.btn_primary_text_1,
|
|
155
152
|
},
|
|
156
153
|
}),
|
|
157
|
-
...(kind ===
|
|
158
|
-
color ===
|
|
154
|
+
...(kind === 'outlined' &&
|
|
155
|
+
color === 'secondary' && {
|
|
159
156
|
color: lunit_token.component.btn_secondary_text,
|
|
160
157
|
border: `${OUTLINED_BORDER_WIDTH}px solid ${lunit_token.core.border_medium}`,
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
'&:hover': getHoverStyle('none'),
|
|
159
|
+
'&:hover:before': {
|
|
163
160
|
content: "''",
|
|
164
|
-
position:
|
|
165
|
-
left:
|
|
166
|
-
top:
|
|
167
|
-
width:
|
|
168
|
-
height:
|
|
161
|
+
position: 'absolute',
|
|
162
|
+
left: '-1px',
|
|
163
|
+
top: '-1px',
|
|
164
|
+
width: 'calc(100% + 2px)',
|
|
165
|
+
height: 'calc(100% + 2px)',
|
|
169
166
|
zIndex: -1,
|
|
170
|
-
backgroundColor: lunit_token.core.
|
|
167
|
+
backgroundColor: lunit_token.core.status_hover,
|
|
171
168
|
borderRadius,
|
|
172
169
|
},
|
|
173
|
-
|
|
170
|
+
'&.Mui-disabled': {
|
|
174
171
|
opacity: 0.38,
|
|
175
172
|
color: lunit_token.component.btn_secondary_text,
|
|
176
173
|
},
|
|
@@ -179,50 +176,50 @@ export const kindStyle = ({ kind, color, lunit_token }: KindStyleParams) => ({
|
|
|
179
176
|
|
|
180
177
|
export const commonStyle = ({ lunit_token }: { lunit_token: ColorToken }) =>
|
|
181
178
|
({
|
|
182
|
-
fontWeight:
|
|
179
|
+
fontWeight: '500',
|
|
183
180
|
borderRadius,
|
|
184
|
-
textTransform:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
position:
|
|
181
|
+
textTransform: 'initial',
|
|
182
|
+
'&.Mui-focusVisible': {
|
|
183
|
+
'&::after': {
|
|
184
|
+
position: 'absolute',
|
|
188
185
|
width: `calc(100% + ${PADDING_OF_FOCUS}px)`,
|
|
189
186
|
height: `calc(100% + ${PADDING_OF_FOCUS}px)`,
|
|
190
187
|
content: '""',
|
|
191
|
-
borderRadius:
|
|
192
|
-
border: `1px solid ${lunit_token.core.
|
|
193
|
-
boxSizing:
|
|
188
|
+
borderRadius: '11px',
|
|
189
|
+
border: `1px solid ${lunit_token.core.status_focused}`,
|
|
190
|
+
boxSizing: 'border-box',
|
|
194
191
|
},
|
|
195
192
|
},
|
|
196
|
-
|
|
193
|
+
'&:hover:before': {
|
|
197
194
|
content: "''",
|
|
198
|
-
position:
|
|
195
|
+
position: 'absolute',
|
|
199
196
|
left: 0,
|
|
200
197
|
top: 0,
|
|
201
|
-
width:
|
|
202
|
-
height:
|
|
198
|
+
width: '100%',
|
|
199
|
+
height: '100%',
|
|
203
200
|
zIndex: -1,
|
|
204
|
-
backgroundColor: lunit_token.core.
|
|
201
|
+
backgroundColor: lunit_token.core.status_hover,
|
|
205
202
|
borderRadius,
|
|
206
203
|
},
|
|
207
|
-
} as const
|
|
204
|
+
}) as const;
|
|
208
205
|
|
|
209
206
|
export const iconStyle = ({
|
|
210
207
|
size,
|
|
211
208
|
hasIconOnly,
|
|
212
|
-
}: Pick<CustomButtonProps,
|
|
213
|
-
|
|
209
|
+
}: Pick<CustomButtonProps, 'size' | 'hasIconOnly'>) => ({
|
|
210
|
+
'& .MuiButton-startIcon': {
|
|
214
211
|
margin: 0,
|
|
215
|
-
marginRight: hasIconOnly ?
|
|
212
|
+
marginRight: hasIconOnly ? '0px' : size === 'large' ? '8px' : '4px',
|
|
216
213
|
|
|
217
|
-
|
|
218
|
-
fontSize:
|
|
214
|
+
'*:nth-of-type(1)': {
|
|
215
|
+
fontSize: '20px',
|
|
219
216
|
},
|
|
220
217
|
},
|
|
221
218
|
});
|
|
222
219
|
|
|
223
220
|
export const CustomButton = styled(MuiButton, {
|
|
224
221
|
shouldForwardProp: (prop: string) => {
|
|
225
|
-
return ![
|
|
222
|
+
return !['kind', 'hasIconOnly', 'variant'].includes(prop);
|
|
226
223
|
},
|
|
227
224
|
})<CustomButtonProps>(
|
|
228
225
|
({
|
|
@@ -239,5 +236,5 @@ export const CustomButton = styled(MuiButton, {
|
|
|
239
236
|
...iconStyle({ size, hasIconOnly }),
|
|
240
237
|
...sizeStyle({ size, kind, hasIconOnly, typography }),
|
|
241
238
|
...kindStyle({ kind, color, lunit_token }),
|
|
242
|
-
})
|
|
239
|
+
}),
|
|
243
240
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { forwardRef } from
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
|
|
3
|
-
import { CustomButton } from
|
|
3
|
+
import { CustomButton } from './Button.styled';
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
6
|
ButtonType,
|
|
@@ -8,49 +8,52 @@ import type {
|
|
|
8
8
|
GhostButtonProps,
|
|
9
9
|
OutlinedButtonProps,
|
|
10
10
|
ContainedButtonProps,
|
|
11
|
-
} from
|
|
11
|
+
} from './Button.types';
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const GhostButton = forwardRef<HTMLButtonElement, GhostButtonProps & { hasIconOnly: boolean }>(
|
|
14
|
+
(props, ref) => {
|
|
15
|
+
const {
|
|
16
|
+
size = 'small',
|
|
17
|
+
icon,
|
|
18
|
+
className,
|
|
19
|
+
children,
|
|
20
|
+
startIcon,
|
|
21
|
+
hasIconOnly,
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
23
|
+
variant: _variant,
|
|
24
|
+
...restProps
|
|
25
|
+
} = props;
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
return (
|
|
28
|
+
<CustomButton
|
|
29
|
+
{...restProps}
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={`ghost ${className ? className : ''}`}
|
|
32
|
+
kind="ghost"
|
|
33
|
+
color={props.color ?? 'primary'}
|
|
34
|
+
size={size}
|
|
35
|
+
startIcon={startIcon || icon}
|
|
36
|
+
hasIconOnly={hasIconOnly}
|
|
37
|
+
>
|
|
38
|
+
{!hasIconOnly && <>{children}</>}
|
|
39
|
+
</CustomButton>
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
24
43
|
|
|
25
|
-
|
|
26
|
-
<ContainedButton
|
|
27
|
-
{...props}
|
|
28
|
-
kind="contained"
|
|
29
|
-
variant="contained"
|
|
30
|
-
ref={ref}
|
|
31
|
-
hasIconOnly={hasIconOnly}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* There is an issue between React 18, Mui's OverridableComponent type and the
|
|
37
|
-
* type coercion to temporarily fix it.
|
|
38
|
-
* https://github.com/lunit-io/design-system/pull/143#issuecomment-1831127232
|
|
39
|
-
*/
|
|
40
|
-
}) as ButtonType;
|
|
41
|
-
|
|
42
|
-
const GhostButton = forwardRef<
|
|
44
|
+
const OutlinedButton = forwardRef<
|
|
43
45
|
HTMLButtonElement,
|
|
44
|
-
|
|
46
|
+
OutlinedButtonProps & { hasIconOnly: boolean }
|
|
45
47
|
>((props, ref) => {
|
|
46
48
|
const {
|
|
47
|
-
size =
|
|
49
|
+
size = 'small',
|
|
48
50
|
icon,
|
|
49
51
|
className,
|
|
50
52
|
children,
|
|
51
53
|
startIcon,
|
|
52
54
|
hasIconOnly,
|
|
53
|
-
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
56
|
+
variant: _variant,
|
|
54
57
|
...restProps
|
|
55
58
|
} = props;
|
|
56
59
|
|
|
@@ -58,9 +61,9 @@ const GhostButton = forwardRef<
|
|
|
58
61
|
<CustomButton
|
|
59
62
|
{...restProps}
|
|
60
63
|
ref={ref}
|
|
61
|
-
className={`
|
|
62
|
-
kind="
|
|
63
|
-
color={props.color ??
|
|
64
|
+
className={`outlined ${className ? className : ''}`}
|
|
65
|
+
kind="outlined"
|
|
66
|
+
color={props.color ?? 'primary'}
|
|
64
67
|
size={size}
|
|
65
68
|
startIcon={startIcon || icon}
|
|
66
69
|
hasIconOnly={hasIconOnly}
|
|
@@ -70,18 +73,19 @@ const GhostButton = forwardRef<
|
|
|
70
73
|
);
|
|
71
74
|
});
|
|
72
75
|
|
|
73
|
-
const
|
|
76
|
+
const ContainedButton = forwardRef<
|
|
74
77
|
HTMLButtonElement,
|
|
75
|
-
|
|
78
|
+
ContainedButtonProps & { hasIconOnly: boolean }
|
|
76
79
|
>((props, ref) => {
|
|
77
80
|
const {
|
|
78
|
-
size =
|
|
81
|
+
size = 'small',
|
|
79
82
|
icon,
|
|
80
83
|
className,
|
|
81
84
|
children,
|
|
82
85
|
startIcon,
|
|
83
86
|
hasIconOnly,
|
|
84
|
-
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
88
|
+
variant: _variant,
|
|
85
89
|
...restProps
|
|
86
90
|
} = props;
|
|
87
91
|
|
|
@@ -89,9 +93,9 @@ const OutlinedButton = forwardRef<
|
|
|
89
93
|
<CustomButton
|
|
90
94
|
{...restProps}
|
|
91
95
|
ref={ref}
|
|
92
|
-
className={
|
|
93
|
-
kind=
|
|
94
|
-
color={props.color ??
|
|
96
|
+
className={`${props.kind ?? 'contained'} ${className ? className : ''}`}
|
|
97
|
+
kind={props.kind ?? 'contained'}
|
|
98
|
+
color={props.color ?? 'primary'}
|
|
95
99
|
size={size}
|
|
96
100
|
startIcon={startIcon || icon}
|
|
97
101
|
hasIconOnly={hasIconOnly}
|
|
@@ -101,35 +105,33 @@ const OutlinedButton = forwardRef<
|
|
|
101
105
|
);
|
|
102
106
|
});
|
|
103
107
|
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
variant,
|
|
116
|
-
...restProps
|
|
117
|
-
} = props;
|
|
108
|
+
const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
109
|
+
const { kind, variant, icon, children, startIcon } = props;
|
|
110
|
+
const hasIconOnly = Boolean((startIcon || icon) && !children);
|
|
111
|
+
|
|
112
|
+
if (kind === 'outlined' || variant === 'outlined') {
|
|
113
|
+
return <OutlinedButton {...props} ref={ref} hasIconOnly={hasIconOnly} />;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (kind === 'ghost' || variant === 'text' || variant === 'ghost') {
|
|
117
|
+
return <GhostButton {...props} ref={ref} hasIconOnly={hasIconOnly} />;
|
|
118
|
+
}
|
|
118
119
|
|
|
119
120
|
return (
|
|
120
|
-
<
|
|
121
|
-
{...
|
|
121
|
+
<ContainedButton
|
|
122
|
+
{...props}
|
|
123
|
+
kind="contained"
|
|
124
|
+
variant="contained"
|
|
122
125
|
ref={ref}
|
|
123
|
-
className={`${props.kind ?? "contained"} ${className ? className : ""}`}
|
|
124
|
-
kind={props.kind ?? "contained"}
|
|
125
|
-
color={props.color ?? "primary"}
|
|
126
|
-
size={size}
|
|
127
|
-
startIcon={startIcon || icon}
|
|
128
126
|
hasIconOnly={hasIconOnly}
|
|
129
|
-
|
|
130
|
-
{!hasIconOnly && <>{children}</>}
|
|
131
|
-
</CustomButton>
|
|
127
|
+
/>
|
|
132
128
|
);
|
|
133
|
-
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* There is an issue between React 18, Mui's OverridableComponent type and the
|
|
132
|
+
* type coercion to temporarily fix it.
|
|
133
|
+
* https://github.com/lunit-io/design-system/pull/143#issuecomment-1831127232
|
|
134
|
+
*/
|
|
135
|
+
}) as ButtonType;
|
|
134
136
|
|
|
135
137
|
export default Button;
|
|
@@ -1,47 +1,45 @@
|
|
|
1
|
+
import type React from 'react';
|
|
1
2
|
import type {
|
|
2
3
|
ButtonProps as MuiButtonProps,
|
|
3
4
|
ButtonTypeMap as MuiButtonTypeMap,
|
|
4
|
-
} from
|
|
5
|
-
import type { OverridableComponent } from
|
|
5
|
+
} from '@mui/material';
|
|
6
|
+
import type { OverridableComponent } from '@mui/material/OverridableComponent';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* TODO: Omit 을 사용할 경우 component prop 타입 추론이 안되는 이슈 발생
|
|
9
10
|
* https://github.com/lunit-io/design-system/pull/133#discussion_r1354277785
|
|
10
11
|
* */
|
|
11
|
-
export interface BaseButtonProps extends Omit<MuiButtonProps,
|
|
12
|
+
export interface BaseButtonProps extends Omit<MuiButtonProps, 'variant'> {
|
|
12
13
|
icon?: React.ReactNode;
|
|
13
|
-
variant?:
|
|
14
|
+
variant?: 'contained' | 'outlined' | 'text' | 'ghost';
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface ContainedButtonProps extends BaseButtonProps {
|
|
17
|
-
kind?:
|
|
18
|
-
variant?:
|
|
19
|
-
color?:
|
|
18
|
+
kind?: 'contained';
|
|
19
|
+
variant?: 'contained';
|
|
20
|
+
color?: 'primary' | 'secondary' | 'error';
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export interface GhostButtonProps extends BaseButtonProps {
|
|
23
|
-
kind?:
|
|
24
|
-
variant?:
|
|
25
|
-
color?:
|
|
24
|
+
kind?: 'ghost';
|
|
25
|
+
variant?: 'text' | 'ghost';
|
|
26
|
+
color?: 'primary' | 'secondary' | 'error';
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export interface OutlinedButtonProps extends BaseButtonProps {
|
|
29
|
-
kind?:
|
|
30
|
-
variant?:
|
|
31
|
-
color?:
|
|
30
|
+
kind?: 'outlined';
|
|
31
|
+
variant?: 'outlined';
|
|
32
|
+
color?: 'primary' | 'secondary';
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
export type ButtonProps =
|
|
35
|
-
| ContainedButtonProps
|
|
36
|
-
| GhostButtonProps
|
|
37
|
-
| OutlinedButtonProps;
|
|
35
|
+
export type ButtonProps = ContainedButtonProps | GhostButtonProps | OutlinedButtonProps;
|
|
38
36
|
|
|
39
|
-
export
|
|
37
|
+
export interface ButtonTypeMap<
|
|
40
38
|
P = {},
|
|
41
|
-
D extends React.ElementType = MuiButtonTypeMap[
|
|
42
|
-
>
|
|
39
|
+
D extends React.ElementType = MuiButtonTypeMap['defaultComponent'],
|
|
40
|
+
> {
|
|
43
41
|
props: P & ButtonProps;
|
|
44
42
|
defaultComponent: D;
|
|
45
|
-
}
|
|
43
|
+
}
|
|
46
44
|
|
|
47
45
|
export type ButtonType = OverridableComponent<ButtonTypeMap>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from
|
|
1
|
+
export { default } from './Button';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { OUTLINED_BORDER_WIDTH } from
|
|
1
|
+
import { OUTLINED_BORDER_WIDTH } from '../const';
|
|
2
2
|
|
|
3
|
-
import type { ButtonProps } from
|
|
4
|
-
import { ToggleButtonProps } from
|
|
3
|
+
import type { ButtonProps } from '../Button.types';
|
|
4
|
+
import { ToggleButtonProps } from '@/components/ToggleButton/ToggleButton.types';
|
|
5
5
|
|
|
6
|
-
type GetButtonPaddingBySizeAndKindParams = Pick<ButtonProps,
|
|
7
|
-
Pick<ToggleButtonProps,
|
|
6
|
+
type GetButtonPaddingBySizeAndKindParams = Pick<ButtonProps, 'kind' | 'size'> &
|
|
7
|
+
Pick<ToggleButtonProps, 'selected'>;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* When kind is outlined,
|
|
@@ -16,20 +16,20 @@ export const getButtonPaddingBySizeAndKind = ({
|
|
|
16
16
|
size,
|
|
17
17
|
selected = false,
|
|
18
18
|
}: GetButtonPaddingBySizeAndKindParams) => {
|
|
19
|
-
if (size ===
|
|
20
|
-
return kind ===
|
|
19
|
+
if (size === 'small') {
|
|
20
|
+
return kind === 'outlined' && !selected
|
|
21
21
|
? `${4 - OUTLINED_BORDER_WIDTH}px ${8 - OUTLINED_BORDER_WIDTH}px`
|
|
22
|
-
:
|
|
22
|
+
: '4px 8px';
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if (size ===
|
|
26
|
-
return kind ===
|
|
25
|
+
if (size === 'medium') {
|
|
26
|
+
return kind === 'outlined' && !selected
|
|
27
27
|
? `${8 - OUTLINED_BORDER_WIDTH}px ${12 - OUTLINED_BORDER_WIDTH}px`
|
|
28
|
-
:
|
|
28
|
+
: '8px 12px';
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// size === "large"
|
|
32
|
-
return kind ===
|
|
32
|
+
return kind === 'outlined' && !selected
|
|
33
33
|
? `${10 - OUTLINED_BORDER_WIDTH}px ${12 - OUTLINED_BORDER_WIDTH}px`
|
|
34
|
-
:
|
|
34
|
+
: '10px 12px';
|
|
35
35
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
const getHoverStyle = (backgroundColor: CSSProperties['color']) => ({
|
|
4
|
+
position: 'relative',
|
|
3
5
|
zIndex: 0,
|
|
4
6
|
backgroundColor,
|
|
5
7
|
});
|