@iota/apps-ui-kit 0.2.0 → 0.2.1
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/CHANGELOG.md +20 -0
- package/dist/index.d.ts +1622 -0
- package/dist/index.es.js +8805 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +198 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +5 -2
- package/src/lib/components/atoms/badge/Badge.tsx +37 -0
- package/src/lib/components/atoms/badge/badge.classes.ts +24 -0
- package/src/lib/components/atoms/badge/badge.enums.ts +8 -0
- package/src/lib/components/atoms/badge/index.ts +6 -0
- package/src/lib/components/atoms/button/Button.tsx +99 -0
- package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +23 -0
- package/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx +27 -0
- package/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts +11 -0
- package/src/lib/components/atoms/button/button-variants/index.ts +5 -0
- package/src/lib/components/atoms/button/button.classes.ts +53 -0
- package/src/lib/components/atoms/button/button.enums.ts +21 -0
- package/src/lib/components/atoms/button/index.ts +7 -0
- package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +86 -0
- package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +45 -0
- package/src/lib/components/atoms/button-segment/buttonSegment.enums.ts +7 -0
- package/src/lib/components/atoms/button-segment/index.ts +5 -0
- package/src/lib/components/atoms/checkbox/Checkbox.tsx +114 -0
- package/src/lib/components/atoms/checkbox/index.ts +4 -0
- package/src/lib/components/atoms/divider/Divider.tsx +48 -0
- package/src/lib/components/atoms/divider/divider.classes.ts +11 -0
- package/src/lib/components/atoms/divider/divider.enums.ts +7 -0
- package/src/lib/components/atoms/divider/index.ts +6 -0
- package/src/lib/components/atoms/header/Header.tsx +73 -0
- package/src/lib/components/atoms/header/index.ts +4 -0
- package/src/lib/components/atoms/index.ts +22 -0
- package/src/lib/components/atoms/info-box/InfoBox.tsx +73 -0
- package/src/lib/components/atoms/info-box/index.ts +5 -0
- package/src/lib/components/atoms/info-box/infoBox.classes.ts +14 -0
- package/src/lib/components/atoms/info-box/infoBox.enums.ts +12 -0
- package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +156 -0
- package/src/lib/components/atoms/key-value-info/index.ts +6 -0
- package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
- package/src/lib/components/atoms/label-text/LabelText.tsx +93 -0
- package/src/lib/components/atoms/label-text/index.ts +5 -0
- package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
- package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
- package/src/lib/components/atoms/list-item/ListItem.tsx +89 -0
- package/src/lib/components/atoms/list-item/index.ts +4 -0
- package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
- package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
- package/src/lib/components/atoms/panel/Panel.tsx +30 -0
- package/src/lib/components/atoms/panel/index.ts +4 -0
- package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
- package/src/lib/components/atoms/placeholder/index.ts +4 -0
- package/src/lib/components/atoms/radio-button/RadioButton.tsx +68 -0
- package/src/lib/components/atoms/radio-button/index.ts +4 -0
- package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +28 -0
- package/src/lib/components/atoms/secondary-text/index.ts +4 -0
- package/src/lib/components/atoms/skeleton/Skeleton.tsx +47 -0
- package/src/lib/components/atoms/skeleton/index.ts +4 -0
- package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
- package/src/lib/components/atoms/snackbar/index.ts +5 -0
- package/src/lib/components/atoms/snackbar/snackbar.classes.ts +14 -0
- package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +7 -0
- package/src/lib/components/atoms/tooltip/Tooltip.tsx +34 -0
- package/src/lib/components/atoms/tooltip/index.ts +5 -0
- package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
- package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
- package/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx +93 -0
- package/src/lib/components/atoms/visual-asset-card/index.ts +5 -0
- package/src/lib/components/atoms/visual-asset-card/visualAssetCard.enums.ts +7 -0
- package/src/lib/components/index.ts +8 -0
- package/src/lib/components/molecules/account/Account.tsx +174 -0
- package/src/lib/components/molecules/account/index.ts +4 -0
- package/src/lib/components/molecules/address/Address.tsx +101 -0
- package/src/lib/components/molecules/address/index.ts +4 -0
- package/src/lib/components/molecules/card/Card.tsx +70 -0
- package/src/lib/components/molecules/card/CardAction.tsx +78 -0
- package/src/lib/components/molecules/card/CardBody.tsx +61 -0
- package/src/lib/components/molecules/card/CardImage.tsx +43 -0
- package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
- package/src/lib/components/molecules/card/card.classes.ts +26 -0
- package/src/lib/components/molecules/card/card.enums.ts +25 -0
- package/src/lib/components/molecules/card/index.ts +8 -0
- package/src/lib/components/molecules/chip/Chip.tsx +105 -0
- package/src/lib/components/molecules/chip/chip.classes.ts +32 -0
- package/src/lib/components/molecules/chip/chip.enums.ts +7 -0
- package/src/lib/components/molecules/chip/index.ts +4 -0
- package/src/lib/components/molecules/display-stats/DisplayStats.tsx +104 -0
- package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
- package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
- package/src/lib/components/molecules/display-stats/index.ts +5 -0
- package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
- package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
- package/src/lib/components/molecules/dropdown/index.ts +5 -0
- package/src/lib/components/molecules/index.ts +17 -0
- package/src/lib/components/molecules/input/Input.tsx +245 -0
- package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
- package/src/lib/components/molecules/input/TextArea.tsx +149 -0
- package/src/lib/components/molecules/input/index.ts +8 -0
- package/src/lib/components/molecules/input/input.classes.ts +14 -0
- package/src/lib/components/molecules/input/input.enums.ts +14 -0
- package/src/lib/components/molecules/input/input.types.ts +29 -0
- package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +48 -0
- package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
- package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
- package/src/lib/components/molecules/navbar-item/index.ts +5 -0
- package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
- package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
- package/src/lib/components/molecules/search/Search.tsx +189 -0
- package/src/lib/components/molecules/search/index.ts +5 -0
- package/src/lib/components/molecules/search/search.classes.ts +20 -0
- package/src/lib/components/molecules/search/search.enums.ts +7 -0
- package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +34 -0
- package/src/lib/components/molecules/segmented-button/index.ts +6 -0
- package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
- package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
- package/src/lib/components/molecules/select/Select.tsx +223 -0
- package/src/lib/components/molecules/select/index.ts +5 -0
- package/src/lib/components/molecules/select/select.enums.ts +7 -0
- package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
- package/src/lib/components/molecules/table-cell/index.ts +4 -0
- package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +126 -0
- package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
- package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
- package/src/lib/components/molecules/title/Title.tsx +69 -0
- package/src/lib/components/molecules/title/index.ts +5 -0
- package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
- package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
- package/src/lib/components/organisms/accordion/Accordion.tsx +111 -0
- package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
- package/src/lib/components/organisms/accordion/index.ts +4 -0
- package/src/lib/components/organisms/dialog/Dialog.tsx +122 -0
- package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
- package/src/lib/components/organisms/dialog/index.ts +5 -0
- package/src/lib/components/organisms/index.ts +7 -0
- package/src/lib/components/organisms/navbar/Navbar.tsx +100 -0
- package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +58 -0
- package/src/lib/components/organisms/navbar/index.ts +5 -0
- package/src/lib/components/organisms/table/Table.tsx +224 -0
- package/src/lib/components/organisms/table/TableContext.tsx +55 -0
- package/src/lib/components/organisms/table/index.ts +4 -0
- package/src/lib/constants/colors.constants.ts +127 -0
- package/src/lib/constants/index.ts +4 -0
- package/src/lib/enums/index.ts +4 -0
- package/src/lib/enums/screenSize.enums.ts +9 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/styles/fonts.css +5 -0
- package/src/lib/styles/index.css +136 -0
- package/src/lib/tailwind/base.presets.ts +47 -0
- package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
- package/src/lib/tailwind/constants/index.ts +6 -0
- package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
- package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
- package/src/lib/tailwind/helpers.ts +20 -0
- package/src/lib/tailwind/index.ts +5 -0
- package/src/lib/tailwind/responsive.presets.ts +36 -0
- package/src/lib/tailwind/static.presets.ts +25 -0
- package/src/lib/tailwind/types.ts +6 -0
- package/src/lib/utils/format.ts +8 -0
- package/src/lib/utils/index.ts +4 -0
- package/src/storybook/blocks/Showcase.tsx +20 -0
- package/src/storybook/blocks/TypeSet.tsx +34 -0
- package/src/storybook/blocks/TypeSetItem.tsx +74 -0
- package/src/storybook/blocks/index.ts +6 -0
- package/src/storybook/constants/index.ts +5 -0
- package/src/storybook/constants/typeset.constants.ts +39 -0
- package/src/storybook/constants/variableSpacing.constants.ts +6 -0
- package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
- package/src/storybook/helpers/index.ts +4 -0
- package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
- package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
- package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
- package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
- package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
- package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
- package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
- package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
- package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
- package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
- package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
- package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
- package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
- package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
- package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
- package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
- package/src/storybook/stories/atoms/Snackbar.stories.tsx +42 -0
- package/src/storybook/stories/atoms/Tooltip.stories.tsx +57 -0
- package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +56 -0
- package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
- package/src/storybook/stories/components/index.ts +4 -0
- package/src/storybook/stories/design-tokens/colors.stories.mdx +23 -0
- package/src/storybook/stories/design-tokens/icons.stories.mdx +17 -0
- package/src/storybook/stories/design-tokens/typeset.stories.mdx +15 -0
- package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +10 -0
- package/src/storybook/stories/molecules/Account.stories.tsx +69 -0
- package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
- package/src/storybook/stories/molecules/Card.stories.tsx +115 -0
- package/src/storybook/stories/molecules/Chip.stories.tsx +122 -0
- package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
- package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
- package/src/storybook/stories/molecules/Input.stories.tsx +161 -0
- package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
- package/src/storybook/stories/molecules/Search.stories.tsx +100 -0
- package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +107 -0
- package/src/storybook/stories/molecules/Select.stories.tsx +102 -0
- package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
- package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
- package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
- package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
- package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
- package/src/storybook/stories/organisms/Dialog.stories.tsx +103 -0
- package/src/storybook/stories/organisms/Navbar.stories.tsx +77 -0
- package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iota/apps-ui-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "github.com:iotaledger/iota.git"
|
|
7
7
|
},
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"files": [
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"src",
|
|
10
13
|
"dist"
|
|
11
14
|
],
|
|
12
15
|
"exports": {
|
|
@@ -27,7 +30,7 @@
|
|
|
27
30
|
"react": "^18.3.1",
|
|
28
31
|
"react-dom": "^18.3.1",
|
|
29
32
|
"react-number-format": "^5.2.2",
|
|
30
|
-
"@iota/apps-ui-icons": "0.2.
|
|
33
|
+
"@iota/apps-ui-icons": "0.2.1"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
36
|
"@chromatic-com/storybook": "^1.6.0",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import { BadgeType } from './badge.enums';
|
|
6
|
+
import { BACKGROUND_COLORS, BADGE_TEXT_CLASS, BORDER_COLORS, TEXT_COLORS } from './badge.classes';
|
|
7
|
+
|
|
8
|
+
interface BadgeProps {
|
|
9
|
+
/**
|
|
10
|
+
* The type of the badge.
|
|
11
|
+
*/
|
|
12
|
+
type: BadgeType;
|
|
13
|
+
/**
|
|
14
|
+
* The label of the badge.
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function Badge({ type, label }: BadgeProps): React.JSX.Element {
|
|
20
|
+
const backgroundClasses = BACKGROUND_COLORS[type];
|
|
21
|
+
const textClasses = TEXT_COLORS[type];
|
|
22
|
+
const borderClasses = BORDER_COLORS[type];
|
|
23
|
+
const labelClasses = label ? 'px-xs py-xxs' : 'h-1.5 w-1.5';
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
className={cx(
|
|
28
|
+
'inline-flex items-center space-x-2 rounded-full border disabled:opacity-30',
|
|
29
|
+
backgroundClasses,
|
|
30
|
+
borderClasses,
|
|
31
|
+
labelClasses,
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
<span className={cx(BADGE_TEXT_CLASS, textClasses)}>{label}</span>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { BadgeType } from './badge.enums';
|
|
5
|
+
|
|
6
|
+
export const BACKGROUND_COLORS = {
|
|
7
|
+
[BadgeType.PrimarySolid]: 'bg-primary-30',
|
|
8
|
+
[BadgeType.Neutral]: 'bg-neutral-92 dark:bg-neutral-12',
|
|
9
|
+
[BadgeType.PrimarySoft]: 'bg-primary-90 dark:bg-primary-10',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const TEXT_COLORS: Record<BadgeType, string> = {
|
|
13
|
+
[BadgeType.PrimarySolid]: 'text-primary-100',
|
|
14
|
+
[BadgeType.Neutral]: 'text-neutral-10 dark:text-neutral-92',
|
|
15
|
+
[BadgeType.PrimarySoft]: 'text-primary-20 dark:text-primary-90',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const BORDER_COLORS: Record<BadgeType, string> = {
|
|
19
|
+
[BadgeType.PrimarySolid]: 'border-primary-30',
|
|
20
|
+
[BadgeType.Neutral]: 'border-neutral-92 dark:border-neutral-12',
|
|
21
|
+
[BadgeType.PrimarySoft]: 'border-primary-90 dark:border-primary-10',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const BADGE_TEXT_CLASS = 'text-label-md';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonHtmlType, ButtonSize, ButtonType } from './button.enums';
|
|
5
|
+
import {
|
|
6
|
+
PADDINGS,
|
|
7
|
+
PADDINGS_ONLY_ICON,
|
|
8
|
+
BACKGROUND_COLORS,
|
|
9
|
+
TEXT_COLORS,
|
|
10
|
+
TEXT_CLASSES,
|
|
11
|
+
TEXT_COLOR_DISABLED,
|
|
12
|
+
DISABLED_BACKGROUND_COLORS,
|
|
13
|
+
} from './button.classes';
|
|
14
|
+
import cx from 'classnames';
|
|
15
|
+
|
|
16
|
+
export interface ButtonProps {
|
|
17
|
+
/**
|
|
18
|
+
* The size of the button.
|
|
19
|
+
*/
|
|
20
|
+
size?: ButtonSize;
|
|
21
|
+
/**
|
|
22
|
+
* The type of the button
|
|
23
|
+
*/
|
|
24
|
+
type?: ButtonType;
|
|
25
|
+
/**
|
|
26
|
+
* The text of the button.
|
|
27
|
+
*/
|
|
28
|
+
text?: string;
|
|
29
|
+
/**
|
|
30
|
+
The icon of the button
|
|
31
|
+
*/
|
|
32
|
+
icon?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Should the icon be after the text.
|
|
35
|
+
*/
|
|
36
|
+
iconAfterText?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The button is disabled or not.
|
|
39
|
+
*/
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The onClick event of the button.
|
|
43
|
+
*/
|
|
44
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the button should have the full width.
|
|
47
|
+
*/
|
|
48
|
+
fullWidth?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The type of the button. Available options are 'button', 'submit', 'reset'.
|
|
51
|
+
*/
|
|
52
|
+
htmlType?: ButtonHtmlType;
|
|
53
|
+
/**
|
|
54
|
+
* The tab index of the button.
|
|
55
|
+
*/
|
|
56
|
+
tabIndex?: number;
|
|
57
|
+
/**
|
|
58
|
+
* The 'data-testid' attribute value (used in e2e tests)
|
|
59
|
+
*/
|
|
60
|
+
testId?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function Button({
|
|
64
|
+
icon,
|
|
65
|
+
text,
|
|
66
|
+
disabled,
|
|
67
|
+
onClick,
|
|
68
|
+
fullWidth,
|
|
69
|
+
htmlType = ButtonHtmlType.Button,
|
|
70
|
+
size = ButtonSize.Medium,
|
|
71
|
+
type = ButtonType.Primary,
|
|
72
|
+
iconAfterText = false,
|
|
73
|
+
tabIndex = 0,
|
|
74
|
+
testId,
|
|
75
|
+
}: ButtonProps): React.JSX.Element {
|
|
76
|
+
const paddingClasses = icon && !text ? PADDINGS_ONLY_ICON[size] : PADDINGS[size];
|
|
77
|
+
const textSizes = TEXT_CLASSES[size];
|
|
78
|
+
const backgroundColors = disabled ? DISABLED_BACKGROUND_COLORS[type] : BACKGROUND_COLORS[type];
|
|
79
|
+
const textColors = disabled ? TEXT_COLOR_DISABLED[type] : TEXT_COLORS[type];
|
|
80
|
+
return (
|
|
81
|
+
<button
|
|
82
|
+
onClick={onClick}
|
|
83
|
+
type={htmlType}
|
|
84
|
+
className={cx(
|
|
85
|
+
'state-layer relative flex items-center justify-center gap-2 rounded-full transition-all duration-150 ease-in disabled:cursor-not-allowed disabled:opacity-40',
|
|
86
|
+
paddingClasses,
|
|
87
|
+
backgroundColors,
|
|
88
|
+
fullWidth && 'w-full',
|
|
89
|
+
!iconAfterText ? 'flex-row' : 'flex-row-reverse',
|
|
90
|
+
)}
|
|
91
|
+
disabled={disabled}
|
|
92
|
+
tabIndex={tabIndex}
|
|
93
|
+
data-testid={testId}
|
|
94
|
+
>
|
|
95
|
+
{icon && <span className={cx(textColors)}>{icon}</span>}
|
|
96
|
+
{text && <span className={cx('font-inter', textColors, textSizes)}>{text}</span>}
|
|
97
|
+
</button>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonHtmlType } from '../button.enums';
|
|
5
|
+
import { ButtonVariantProps } from './buttonVariants.types';
|
|
6
|
+
|
|
7
|
+
export function ButtonPill({
|
|
8
|
+
htmlType = ButtonHtmlType.Button,
|
|
9
|
+
children,
|
|
10
|
+
tabIndex = 0,
|
|
11
|
+
...buttonProps
|
|
12
|
+
}: Omit<ButtonVariantProps, 'className'>) {
|
|
13
|
+
return (
|
|
14
|
+
<button
|
|
15
|
+
className="flex items-center justify-center rounded-xl border border-neutral-70 px-sm text-body-md text-neutral-40 disabled:opacity-40 dark:border-neutral-40 dark:text-neutral-60"
|
|
16
|
+
type={htmlType}
|
|
17
|
+
tabIndex={tabIndex}
|
|
18
|
+
{...buttonProps}
|
|
19
|
+
>
|
|
20
|
+
{children}
|
|
21
|
+
</button>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonHtmlType } from '../button.enums';
|
|
5
|
+
import { ButtonVariantProps } from './buttonVariants.types';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
|
|
8
|
+
export function ButtonUnstyled({
|
|
9
|
+
htmlType = ButtonHtmlType.Button,
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
tabIndex = 0,
|
|
13
|
+
testId,
|
|
14
|
+
...buttonProps
|
|
15
|
+
}: ButtonVariantProps): React.JSX.Element {
|
|
16
|
+
return (
|
|
17
|
+
<button
|
|
18
|
+
type={htmlType}
|
|
19
|
+
{...buttonProps}
|
|
20
|
+
className={cx('appearance-none', className)}
|
|
21
|
+
tabIndex={tabIndex}
|
|
22
|
+
data-testid={testId}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</button>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonProps } from '../Button';
|
|
5
|
+
|
|
6
|
+
type ButtonPickedProps = Pick<ButtonProps, 'htmlType' | 'testId'>;
|
|
7
|
+
type PropsFromButtonElement = Omit<React.HTMLProps<HTMLButtonElement>, 'type'>;
|
|
8
|
+
|
|
9
|
+
export interface ButtonVariantProps extends ButtonPickedProps, PropsFromButtonElement {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonSize, ButtonType } from './button.enums';
|
|
5
|
+
|
|
6
|
+
export const PADDINGS: Record<ButtonSize, string> = {
|
|
7
|
+
[ButtonSize.Small]: 'px-md py-xs',
|
|
8
|
+
[ButtonSize.Medium]: 'px-md py-sm',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const PADDINGS_ONLY_ICON: Record<ButtonSize, string> = {
|
|
12
|
+
[ButtonSize.Small]: 'p-xs',
|
|
13
|
+
[ButtonSize.Medium]: 'p-sm',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const BACKGROUND_COLORS: Record<ButtonType, string> = {
|
|
17
|
+
[ButtonType.Primary]: 'bg-primary-30',
|
|
18
|
+
[ButtonType.Secondary]: 'bg-neutral-90 dark:bg-neutral-20',
|
|
19
|
+
[ButtonType.Ghost]: 'bg-transparent',
|
|
20
|
+
[ButtonType.Outlined]: 'bg-transparent border border-neutral-50',
|
|
21
|
+
[ButtonType.Destructive]: 'bg-error-90',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const DISABLED_BACKGROUND_COLORS: Record<ButtonType, string> = {
|
|
25
|
+
[ButtonType.Primary]: 'bg-neutral-80 dark:bg-neutral-30',
|
|
26
|
+
[ButtonType.Secondary]: 'bg-neutral-90 dark:bg-neutral-20',
|
|
27
|
+
[ButtonType.Ghost]: 'bg-transparent',
|
|
28
|
+
[ButtonType.Outlined]: 'bg-transparent border border-neutral-50',
|
|
29
|
+
[ButtonType.Destructive]: 'bg-error-90',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const DEFAULT_TEXT_COLORS: string = 'text-neutral-10 dark:text-neutral-92';
|
|
33
|
+
|
|
34
|
+
export const TEXT_COLORS: Record<ButtonType, string> = {
|
|
35
|
+
[ButtonType.Primary]: 'text-primary-100',
|
|
36
|
+
[ButtonType.Secondary]: DEFAULT_TEXT_COLORS,
|
|
37
|
+
[ButtonType.Ghost]: DEFAULT_TEXT_COLORS,
|
|
38
|
+
[ButtonType.Outlined]: DEFAULT_TEXT_COLORS,
|
|
39
|
+
[ButtonType.Destructive]: 'text-error-20',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const TEXT_CLASSES: Record<ButtonSize, string> = {
|
|
43
|
+
[ButtonSize.Small]: 'text-label-md',
|
|
44
|
+
[ButtonSize.Medium]: 'text-label-lg',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const TEXT_COLOR_DISABLED: Record<ButtonType, string> = {
|
|
48
|
+
[ButtonType.Primary]: DEFAULT_TEXT_COLORS,
|
|
49
|
+
[ButtonType.Secondary]: DEFAULT_TEXT_COLORS,
|
|
50
|
+
[ButtonType.Ghost]: DEFAULT_TEXT_COLORS,
|
|
51
|
+
[ButtonType.Outlined]: DEFAULT_TEXT_COLORS,
|
|
52
|
+
[ButtonType.Destructive]: 'text-error-20',
|
|
53
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export enum ButtonSize {
|
|
5
|
+
Small = 'small',
|
|
6
|
+
Medium = 'medium',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum ButtonType {
|
|
10
|
+
Primary = 'primary',
|
|
11
|
+
Secondary = 'secondary',
|
|
12
|
+
Ghost = 'ghost',
|
|
13
|
+
Outlined = 'outlined',
|
|
14
|
+
Destructive = 'destructive',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum ButtonHtmlType {
|
|
18
|
+
Button = 'button',
|
|
19
|
+
Submit = 'submit',
|
|
20
|
+
Reset = 'reset',
|
|
21
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BACKGROUND_COLORS,
|
|
6
|
+
BACKGROUND_COLORS_SELECTED,
|
|
7
|
+
TEXT_COLORS,
|
|
8
|
+
TEXT_COLORS_SELECTED,
|
|
9
|
+
UNDERLINED,
|
|
10
|
+
UNDERLINED_SELECTED,
|
|
11
|
+
} from './buttonSegment.classes';
|
|
12
|
+
import cx from 'classnames';
|
|
13
|
+
import { ButtonSegmentType } from './buttonSegment.enums';
|
|
14
|
+
import { ButtonUnstyled } from '../button';
|
|
15
|
+
|
|
16
|
+
interface ButtonSegmentProps {
|
|
17
|
+
/**
|
|
18
|
+
* The label of the button.
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
/**
|
|
22
|
+
The icon of the button
|
|
23
|
+
*/
|
|
24
|
+
icon?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
The selected flag of the button
|
|
27
|
+
*/
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The button is disabled or not.
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The onClick event of the button.
|
|
35
|
+
*/
|
|
36
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
37
|
+
/**
|
|
38
|
+
* The type of the button.
|
|
39
|
+
*/
|
|
40
|
+
type?: ButtonSegmentType;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function ButtonSegment({
|
|
44
|
+
icon,
|
|
45
|
+
label,
|
|
46
|
+
selected,
|
|
47
|
+
disabled,
|
|
48
|
+
onClick,
|
|
49
|
+
type = ButtonSegmentType.Rounded,
|
|
50
|
+
}: ButtonSegmentProps): React.JSX.Element {
|
|
51
|
+
const isUnderlined = type === ButtonSegmentType.Underlined;
|
|
52
|
+
|
|
53
|
+
const backgroundColors = selected
|
|
54
|
+
? isUnderlined
|
|
55
|
+
? 'bg-transparent'
|
|
56
|
+
: BACKGROUND_COLORS_SELECTED
|
|
57
|
+
: BACKGROUND_COLORS;
|
|
58
|
+
|
|
59
|
+
const underlined = isUnderlined ? (selected ? UNDERLINED_SELECTED : UNDERLINED) : '';
|
|
60
|
+
const textColors = selected ? TEXT_COLORS_SELECTED : TEXT_COLORS;
|
|
61
|
+
const padding = isUnderlined ? 'px-lg py-md' : 'px-sm py-[6px]';
|
|
62
|
+
const borderRadius = isUnderlined ? '' : 'rounded-full';
|
|
63
|
+
const textSize = isUnderlined ? 'text-title-md' : 'text-label-lg';
|
|
64
|
+
return (
|
|
65
|
+
<ButtonUnstyled
|
|
66
|
+
onClick={onClick}
|
|
67
|
+
className={cx(
|
|
68
|
+
'enabled:state-layer relative flex items-center disabled:opacity-40',
|
|
69
|
+
backgroundColors,
|
|
70
|
+
textColors,
|
|
71
|
+
padding,
|
|
72
|
+
borderRadius,
|
|
73
|
+
underlined,
|
|
74
|
+
{
|
|
75
|
+
'pl-xs': !!icon && !isUnderlined,
|
|
76
|
+
},
|
|
77
|
+
)}
|
|
78
|
+
disabled={disabled}
|
|
79
|
+
>
|
|
80
|
+
<div className={cx('flex flex-row items-center justify-center gap-2', textSize)}>
|
|
81
|
+
{icon && <span>{icon}</span>}
|
|
82
|
+
<span className="font-inter">{label}</span>
|
|
83
|
+
</div>
|
|
84
|
+
</ButtonUnstyled>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const BACKGROUND_COLORS = 'bg-transparent';
|
|
5
|
+
export const BACKGROUND_COLORS_SELECTED = 'bg-primary-100 dark:bg-neutral-6';
|
|
6
|
+
|
|
7
|
+
const TEXT_COLOR = 'text-neutral-60 dark:text-neutral-40';
|
|
8
|
+
const TEXT_COLOR_HOVER = 'enabled:hover:text-neutral-40 enabled:dark:hover:text-neutral-60';
|
|
9
|
+
const TEXT_COLOR_FOCUSED = 'enabled:focused:text-neutral-40 enabled:dark:focused:text-neutral-60';
|
|
10
|
+
|
|
11
|
+
export const TEXT_COLORS = `${TEXT_COLOR} ${TEXT_COLOR_HOVER} ${TEXT_COLOR_FOCUSED}`;
|
|
12
|
+
export const TEXT_COLORS_SELECTED = 'text-neutral-10 dark:text-neutral-92';
|
|
13
|
+
|
|
14
|
+
export const UNDERLINED_SELECTED = `
|
|
15
|
+
relative
|
|
16
|
+
before:content-['']
|
|
17
|
+
border-b
|
|
18
|
+
border-shader-neutral-light-8
|
|
19
|
+
dark:border-shader-neutral-dark-8
|
|
20
|
+
before:block
|
|
21
|
+
before:w-full
|
|
22
|
+
before:border-b
|
|
23
|
+
before:absolute
|
|
24
|
+
before:bottom-[-0.8px]
|
|
25
|
+
before:left-0
|
|
26
|
+
enabled:before:w-[calc(100%-16px)]
|
|
27
|
+
enabled:before:left-2
|
|
28
|
+
enabled:before:border-primary-30
|
|
29
|
+
enabled:before:dark:border-primary-80`;
|
|
30
|
+
|
|
31
|
+
export const UNDERLINED = `
|
|
32
|
+
relative
|
|
33
|
+
before:content-['']
|
|
34
|
+
before:block
|
|
35
|
+
before:w-full
|
|
36
|
+
before:border-b
|
|
37
|
+
before:border-shader-neutral-light-8
|
|
38
|
+
before:dark:border-shader-neutral-dark-8
|
|
39
|
+
before:absolute
|
|
40
|
+
before:bottom-0
|
|
41
|
+
before:left-0
|
|
42
|
+
hover:before:w-[calc(100%-16px)]
|
|
43
|
+
hover:before:left-2
|
|
44
|
+
hover:before:border-neutral-70
|
|
45
|
+
hover:before:dark:border-neutral-40`;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { Dash, Checkmark } from '@iota/apps-ui-icons';
|
|
7
|
+
|
|
8
|
+
interface CheckboxProps {
|
|
9
|
+
/**
|
|
10
|
+
* The label of the checkbox.
|
|
11
|
+
*/
|
|
12
|
+
label?: string | React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* The state of the checkbox.
|
|
15
|
+
*/
|
|
16
|
+
isChecked?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If true the checkbox will override the styles to show an indeterminate state.
|
|
19
|
+
*/
|
|
20
|
+
isIndeterminate?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the label should be placed before the checkbox.
|
|
23
|
+
*/
|
|
24
|
+
isLabelFirst?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* If true the checkbox will be disabled.
|
|
27
|
+
*/
|
|
28
|
+
isDisabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The callback to call when the checkbox is clicked.
|
|
31
|
+
*/
|
|
32
|
+
onCheckedChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* The name of the checkbox.
|
|
35
|
+
*/
|
|
36
|
+
name?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
isChecked,
|
|
43
|
+
isIndeterminate,
|
|
44
|
+
label,
|
|
45
|
+
isLabelFirst,
|
|
46
|
+
isDisabled,
|
|
47
|
+
onCheckedChange,
|
|
48
|
+
name,
|
|
49
|
+
}: CheckboxProps,
|
|
50
|
+
ref,
|
|
51
|
+
) => {
|
|
52
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (inputRef.current) {
|
|
56
|
+
inputRef.current.indeterminate = isIndeterminate ?? false;
|
|
57
|
+
}
|
|
58
|
+
}, [isIndeterminate, inputRef]);
|
|
59
|
+
|
|
60
|
+
const CheckmarkIcon = isIndeterminate ? Dash : Checkmark;
|
|
61
|
+
|
|
62
|
+
function assignRefs(element: HTMLInputElement) {
|
|
63
|
+
if (ref) {
|
|
64
|
+
if (typeof ref === 'function') {
|
|
65
|
+
ref(element);
|
|
66
|
+
} else {
|
|
67
|
+
ref.current = element;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
inputRef.current = element;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
className={cx('group inline-flex', isLabelFirst ? 'flex-row-reverse' : 'flex-row', {
|
|
76
|
+
disabled: isDisabled,
|
|
77
|
+
'gap-x-2': label,
|
|
78
|
+
})}
|
|
79
|
+
>
|
|
80
|
+
<input
|
|
81
|
+
id={name}
|
|
82
|
+
name={name}
|
|
83
|
+
type="checkbox"
|
|
84
|
+
className="peer hidden appearance-none"
|
|
85
|
+
checked={isChecked}
|
|
86
|
+
ref={assignRefs}
|
|
87
|
+
disabled={isDisabled}
|
|
88
|
+
onChange={(e) => {
|
|
89
|
+
onCheckedChange?.(e);
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
<span
|
|
93
|
+
onClick={() => inputRef.current?.click()}
|
|
94
|
+
className="peer-enabled:state-layer relative inset-0 flex h-5 w-5 items-center justify-center rounded border border-neutral-80 text-neutral-40 group-[.disabled]:cursor-not-allowed peer-disabled:text-neutral-70 peer-disabled:text-opacity-40 peer-disabled:opacity-40 peer-[&:is(:checked,:indeterminate)]:border-primary-30 peer-[&:is(:checked,:indeterminate)]:bg-primary-30 peer-[&:is(:checked,:indeterminate)]:text-white peer-[&:not(:checked,:indeterminate)]:text-opacity-40 disabled:peer-[&:not(:checked,:indeterminate)]:border-neutral-70 dark:border-neutral-20 dark:text-neutral-60 dark:peer-disabled:text-neutral-30 dark:peer-disabled:text-opacity-40 dark:peer-disabled:peer-[&:not(:checked,:indeterminate)]:border-neutral-30 dark:peer-disabled:peer-[&:is(:checked,:indeterminate)]:bg-neutral-40 peer-disabled:[&:is(:checked,:indeterminate)]:border-neutral-60 peer-disabled:[&:is(:checked,:indeterminate)]:bg-neutral-60 dark:peer-disabled:[&:is(:checked,:indeterminate)]:border-neutral-40 [&_svg]:h-4 [&_svg]:w-4 peer-[&:not(:checked,:indeterminate)]:[&_svg]:hidden"
|
|
95
|
+
>
|
|
96
|
+
<CheckmarkIcon />
|
|
97
|
+
</span>
|
|
98
|
+
|
|
99
|
+
<LabelText label={label} name={name} />
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
function LabelText({ label, name }: Pick<CheckboxProps, 'label' | 'name'>) {
|
|
106
|
+
return (
|
|
107
|
+
<label
|
|
108
|
+
htmlFor={name}
|
|
109
|
+
className="text-label-lg text-neutral-40 group-[.disabled]:cursor-not-allowed group-[.disabled]:text-opacity-40 dark:text-neutral-60 group-[.disabled]:dark:text-opacity-40"
|
|
110
|
+
>
|
|
111
|
+
{label}
|
|
112
|
+
</label>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { DividerType } from './divider.enums';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { BACKGROUND_COLORS, DIVIDER_FULL_WIDTH } from './divider.classes';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_LINE_HEIGHT = '1px';
|
|
9
|
+
|
|
10
|
+
interface DividerProps {
|
|
11
|
+
/**
|
|
12
|
+
* The type of the divider
|
|
13
|
+
*/
|
|
14
|
+
type?: DividerType;
|
|
15
|
+
/**
|
|
16
|
+
* The width of the divider.
|
|
17
|
+
*/
|
|
18
|
+
width?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The height of the divider.
|
|
21
|
+
*/
|
|
22
|
+
height?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The line height of the divider.
|
|
25
|
+
*/
|
|
26
|
+
lineHeight?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function Divider({
|
|
30
|
+
type = DividerType.Horizontal,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
lineHeight = DEFAULT_LINE_HEIGHT,
|
|
34
|
+
}: DividerProps): React.JSX.Element {
|
|
35
|
+
// Set height and width of divider line based on type
|
|
36
|
+
const lineStyle = {
|
|
37
|
+
...(type === DividerType.Horizontal ? { height: lineHeight } : { width: lineHeight }),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let dividerSize = DIVIDER_FULL_WIDTH[type];
|
|
41
|
+
if (width && type === DividerType.Horizontal) {
|
|
42
|
+
dividerSize = width;
|
|
43
|
+
} else if (height && type === DividerType.Vertical) {
|
|
44
|
+
dividerSize = height;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return <div className={cx(BACKGROUND_COLORS, dividerSize)} style={lineStyle} />;
|
|
48
|
+
}
|