@onewelcome/react-lib-components 0.2.1 → 0.2.4
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/dist/Breadcrumbs/Breadcrumbs.d.ts +4 -4
- package/dist/Button/BaseButton.d.ts +4 -4
- package/dist/Button/Button.d.ts +3 -3
- package/dist/Button/IconButton.d.ts +4 -4
- package/dist/ContextMenu/ContextMenu.d.ts +5 -5
- package/dist/ContextMenu/ContextMenuItem.d.ts +2 -2
- package/dist/DataGrid/DataGrid.d.ts +6 -6
- package/dist/DataGrid/DataGridActions/DataGridActions.d.ts +4 -4
- package/dist/DataGrid/DataGridActions/DataGridColumnsToggle.d.ts +3 -3
- package/dist/DataGrid/DataGridBody/DataGridBody.d.ts +3 -3
- package/dist/DataGrid/DataGridBody/DataGridCell.d.ts +2 -2
- package/dist/DataGrid/DataGridBody/DataGridRow.d.ts +3 -3
- package/dist/DataGrid/DataGridHeader/DataGridHeader.d.ts +3 -3
- package/dist/DataGrid/DataGridHeader/DataGridHeaderCell.d.ts +3 -3
- package/dist/DataGrid/datagrid.interfaces.d.ts +1 -1
- package/dist/Form/Checkbox/Checkbox.d.ts +5 -5
- package/dist/Form/Fieldset/Fieldset.d.ts +3 -3
- package/dist/Form/Form.d.ts +1 -1
- package/dist/Form/FormControl/FormControl.d.ts +3 -3
- package/dist/Form/FormGroup/FormGroup.d.ts +5 -5
- package/dist/Form/FormHelperText/FormHelperText.d.ts +3 -3
- package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +6 -6
- package/dist/Form/Input/Input.d.ts +5 -5
- package/dist/Form/Label/Label.d.ts +2 -2
- package/dist/Form/Radio/Radio.d.ts +5 -5
- package/dist/Form/Select/Option.d.ts +2 -2
- package/dist/Form/Select/Select.d.ts +5 -5
- package/dist/Form/Textarea/Textarea.d.ts +6 -6
- package/dist/Form/Toggle/Toggle.d.ts +3 -3
- package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +4 -4
- package/dist/Form/Wrapper/Wrapper/Wrapper.d.ts +6 -6
- package/dist/Form/form.interfaces.d.ts +2 -2
- package/dist/Icon/Icon.d.ts +3 -3
- package/dist/Link/Link.d.ts +7 -7
- package/dist/Notifications/BaseModal/BaseModal.d.ts +4 -4
- package/dist/Notifications/BaseModal/BaseModalActions/BaseModalActions.d.ts +2 -2
- package/dist/Notifications/BaseModal/BaseModalContent/BaseModalContent.d.ts +2 -2
- package/dist/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +2 -2
- package/dist/Notifications/Dialog/Dialog.d.ts +5 -5
- package/dist/Notifications/Dialog/DialogActions/DialogActions.d.ts +3 -3
- package/dist/Notifications/Dialog/DialogTitle/DialogTitle.d.ts +2 -2
- package/dist/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.d.ts +3 -3
- package/dist/Notifications/DiscardChangesModal/DiscardChangesModal.d.ts +7 -7
- package/dist/Notifications/Modal/Modal.d.ts +1 -1
- package/dist/Notifications/Modal/ModalActions/ModalActions.d.ts +1 -1
- package/dist/Notifications/Modal/ModalContent/ModalContent.d.ts +1 -1
- package/dist/Notifications/Modal/ModalHeader/ModalHeader.d.ts +1 -1
- package/dist/Notifications/SlideInModal/SlideInModal.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarItem/SnackbarItem.d.ts +2 -2
- package/dist/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.d.ts +3 -3
- package/dist/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +2 -2
- package/dist/Notifications/Snackbar/interfaces.d.ts +2 -2
- package/dist/Pagination/Pagination.d.ts +3 -3
- package/dist/Popover/Popover.d.ts +3 -3
- package/dist/Skeleton/Skeleton.d.ts +3 -3
- package/dist/StatusIndicator/StatusIndicator.d.ts +5 -5
- package/dist/Tabs/Tab.d.ts +1 -1
- package/dist/Tabs/TabButton.d.ts +2 -2
- package/dist/Tabs/TabPanel.d.ts +2 -2
- package/dist/Tabs/Tabs.d.ts +4 -4
- package/dist/TextEllipsis/TextEllipsis.d.ts +2 -2
- package/dist/Tiles/Tile.d.ts +5 -5
- package/dist/Tiles/Tiles.d.ts +2 -2
- package/dist/Tooltip/Tooltip.d.ts +3 -3
- package/dist/Typography/Typography.d.ts +3 -3
- package/dist/Wizard/BaseWizardSteps/BaseWizardSteps.d.ts +2 -2
- package/dist/Wizard/Wizard.d.ts +3 -3
- package/dist/Wizard/WizardActions/WizardActions.d.ts +2 -2
- package/dist/Wizard/WizardStateProvider.d.ts +2 -2
- package/dist/Wizard/WizardSteps/WizardSteps.d.ts +2 -2
- package/dist/Wizard/wizardStateReducer.d.ts +5 -5
- package/dist/_BaseStyling_/BaseStyling.d.ts +1 -1
- package/dist/hooks/usePosition.d.ts +5 -5
- package/dist/hooks/useRepeater.d.ts +1 -1
- package/dist/hooks/useScroll.d.ts +1 -1
- package/dist/hooks/useSpacing.d.ts +1 -1
- package/dist/hooks/useWrapper.d.ts +1 -1
- package/dist/index.d.ts +55 -55
- package/dist/interfaces.d.ts +1 -1
- package/dist/react-lib-components.cjs.development.js +683 -581
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +683 -581
- package/dist/react-lib-components.esm.js.map +1 -1
- package/package.json +27 -16
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +15 -15
- package/src/Breadcrumbs/Breadcrumbs.tsx +11 -11
- package/src/Button/BaseButton.module.scss +1 -1
- package/src/Button/BaseButton.test.tsx +27 -27
- package/src/Button/BaseButton.tsx +8 -8
- package/src/Button/Button.module.scss +5 -5
- package/src/Button/Button.test.tsx +39 -39
- package/src/Button/Button.tsx +10 -10
- package/src/Button/IconButton.module.scss +5 -5
- package/src/Button/IconButton.test.tsx +29 -29
- package/src/Button/IconButton.tsx +11 -11
- package/src/ContextMenu/ContextMenu.test.tsx +97 -76
- package/src/ContextMenu/ContextMenu.tsx +48 -42
- package/src/ContextMenu/ContextMenuItem.module.scss +1 -1
- package/src/ContextMenu/ContextMenuItem.tsx +8 -5
- package/src/DataGrid/DataGrid.test.tsx +193 -193
- package/src/DataGrid/DataGrid.tsx +26 -26
- package/src/DataGrid/DataGridActions/DataGridActions.test.tsx +63 -63
- package/src/DataGrid/DataGridActions/DataGridActions.tsx +15 -15
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss +1 -1
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.test.tsx +21 -21
- package/src/DataGrid/DataGridActions/DataGridColumnsToggle.tsx +20 -20
- package/src/DataGrid/DataGridBody/DataGridBody.test.tsx +40 -40
- package/src/DataGrid/DataGridBody/DataGridBody.tsx +10 -10
- package/src/DataGrid/DataGridBody/DataGridCell.module.scss +1 -1
- package/src/DataGrid/DataGridBody/DataGridCell.test.tsx +25 -25
- package/src/DataGrid/DataGridBody/DataGridCell.tsx +6 -6
- package/src/DataGrid/DataGridBody/DataGridRow.test.tsx +38 -38
- package/src/DataGrid/DataGridBody/DataGridRow.tsx +9 -9
- package/src/DataGrid/DataGridHeader/DataGridHeader.module.scss +1 -2
- package/src/DataGrid/DataGridHeader/DataGridHeader.test.tsx +119 -119
- package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +13 -13
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss +2 -0
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.test.tsx +51 -51
- package/src/DataGrid/DataGridHeader/DataGridHeaderCell.tsx +14 -14
- package/src/DataGrid/datagrid.interfaces.ts +1 -1
- package/src/Form/Checkbox/Checkbox.test.tsx +74 -74
- package/src/Form/Checkbox/Checkbox.tsx +27 -27
- package/src/Form/Fieldset/Fieldset.module.scss +1 -1
- package/src/Form/Fieldset/Fieldset.test.tsx +35 -35
- package/src/Form/Fieldset/Fieldset.tsx +27 -27
- package/src/Form/Form.test.tsx +18 -18
- package/src/Form/Form.tsx +3 -3
- package/src/Form/FormControl/FormControl.test.tsx +22 -22
- package/src/Form/FormControl/FormControl.tsx +10 -10
- package/src/Form/FormGroup/FormGroup.test.tsx +37 -37
- package/src/Form/FormGroup/FormGroup.tsx +16 -16
- package/src/Form/FormHelperText/FormHelperText.test.tsx +18 -18
- package/src/Form/FormHelperText/FormHelperText.tsx +7 -7
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.test.tsx +15 -15
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +14 -14
- package/src/Form/Input/Input.module.scss +20 -44
- package/src/Form/Input/Input.test.tsx +121 -73
- package/src/Form/Input/Input.tsx +96 -35
- package/src/Form/Label/Label.test.tsx +13 -13
- package/src/Form/Label/Label.tsx +6 -6
- package/src/Form/Radio/Radio.test.tsx +35 -35
- package/src/Form/Radio/Radio.tsx +17 -17
- package/src/Form/Select/Option.test.tsx +10 -10
- package/src/Form/Select/Option.tsx +8 -8
- package/src/Form/Select/Select.module.scss +7 -9
- package/src/Form/Select/Select.test.tsx +144 -141
- package/src/Form/Select/Select.tsx +79 -78
- package/src/Form/Textarea/Textarea.module.scss +8 -18
- package/src/Form/Textarea/Textarea.test.tsx +27 -27
- package/src/Form/Textarea/Textarea.tsx +33 -13
- package/src/Form/Toggle/Toggle.module.scss +1 -1
- package/src/Form/Toggle/Toggle.test.tsx +22 -22
- package/src/Form/Toggle/Toggle.tsx +10 -10
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +39 -39
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +12 -12
- package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +2 -8
- package/src/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +55 -55
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +30 -35
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +35 -35
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +12 -12
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +55 -55
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +12 -12
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +2 -11
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +50 -50
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +22 -22
- package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +2 -2
- package/src/Form/Wrapper/Wrapper/Wrapper.test.tsx +11 -11
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +17 -17
- package/src/Form/form.interfaces.ts +2 -2
- package/src/Icon/Icon.module.scss +71 -71
- package/src/Icon/Icon.test.tsx +18 -18
- package/src/Icon/Icon.tsx +70 -70
- package/src/Link/Link.module.scss +5 -5
- package/src/Link/Link.test.tsx +76 -76
- package/src/Link/Link.tsx +27 -27
- package/src/Link/types.d.ts +2 -2
- package/src/Notifications/BaseModal/BaseModal.module.scss +1 -1
- package/src/Notifications/BaseModal/BaseModal.test.tsx +53 -53
- package/src/Notifications/BaseModal/BaseModal.tsx +16 -16
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.test.tsx +13 -13
- package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +5 -5
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.test.tsx +16 -16
- package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +5 -5
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.test.tsx +19 -19
- package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +10 -10
- package/src/Notifications/Dialog/Dialog.test.tsx +35 -35
- package/src/Notifications/Dialog/Dialog.tsx +19 -19
- package/src/Notifications/Dialog/DialogActions/DialogActions.test.tsx +14 -14
- package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +6 -6
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.test.tsx +12 -12
- package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +6 -6
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx +20 -20
- package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +7 -7
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.test.tsx +36 -36
- package/src/Notifications/DiscardChangesModal/DiscardChangesModal.tsx +8 -8
- package/src/Notifications/Modal/Modal.test.tsx +6 -6
- package/src/Notifications/Modal/Modal.tsx +1 -1
- package/src/Notifications/Modal/ModalActions/ModalActions.tsx +2 -2
- package/src/Notifications/Modal/ModalContent/ModalContent.tsx +2 -2
- package/src/Notifications/Modal/ModalHeader/ModalHeader.tsx +2 -2
- package/src/Notifications/SlideInModal/SlideInModal.test.tsx +16 -16
- package/src/Notifications/SlideInModal/SlideInModal.tsx +16 -11
- package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.test.tsx +16 -16
- package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.tsx +6 -6
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +2 -2
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.test.tsx +17 -17
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +23 -23
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +32 -32
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarProvider.tsx +18 -18
- package/src/Notifications/Snackbar/SnackbarProvider/SnackbarStateProvider.tsx +3 -3
- package/src/Notifications/Snackbar/interfaces.ts +2 -2
- package/src/Notifications/Snackbar/useSnackbar.ts +2 -2
- package/src/Pagination/Pagination.module.scss +2 -0
- package/src/Pagination/Pagination.test.tsx +47 -47
- package/src/Pagination/Pagination.tsx +35 -35
- package/src/Popover/Popover.test.tsx +19 -19
- package/src/Popover/Popover.tsx +7 -7
- package/src/Skeleton/Skeleton.module.scss +2 -2
- package/src/Skeleton/Skeleton.test.tsx +29 -29
- package/src/Skeleton/Skeleton.tsx +10 -10
- package/src/StatusIndicator/StatusIndicator.test.tsx +38 -38
- package/src/StatusIndicator/StatusIndicator.tsx +9 -9
- package/src/Tabs/Tab.test.tsx +13 -13
- package/src/Tabs/Tab.tsx +1 -1
- package/src/Tabs/TabButton.test.tsx +28 -28
- package/src/Tabs/TabButton.tsx +7 -7
- package/src/Tabs/TabPanel.test.tsx +30 -30
- package/src/Tabs/TabPanel.tsx +4 -4
- package/src/Tabs/Tabs.test.tsx +93 -93
- package/src/Tabs/Tabs.tsx +25 -25
- package/src/TextEllipsis/TextEllipsis.test.tsx +22 -22
- package/src/TextEllipsis/TextEllipsis.tsx +6 -6
- package/src/Tiles/Tile.module.scss +1 -1
- package/src/Tiles/Tile.test.tsx +42 -42
- package/src/Tiles/Tile.tsx +22 -22
- package/src/Tiles/Tiles.test.tsx +30 -30
- package/src/Tiles/Tiles.tsx +9 -9
- package/src/Tooltip/Tooltip.test.tsx +35 -35
- package/src/Tooltip/Tooltip.tsx +21 -21
- package/src/Typography/Typography.module.scss +1 -1
- package/src/Typography/Typography.test.tsx +49 -49
- package/src/Typography/Typography.tsx +42 -42
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.module.scss +1 -1
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.test.tsx +26 -26
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +24 -24
- package/src/Wizard/Wizard.test.tsx +56 -56
- package/src/Wizard/Wizard.tsx +6 -6
- package/src/Wizard/WizardActions/WizardActions.test.tsx +34 -34
- package/src/Wizard/WizardActions/WizardActions.tsx +14 -14
- package/src/Wizard/WizardStateProvider.tsx +3 -3
- package/src/Wizard/WizardSteps/WizardSteps.test.tsx +27 -27
- package/src/Wizard/WizardSteps/WizardSteps.tsx +7 -7
- package/src/Wizard/wizardStateReducer.ts +9 -9
- package/src/_BaseStyling_/BaseStyling.test.tsx +14 -14
- package/src/_BaseStyling_/BaseStyling.tsx +50 -50
- package/src/hooks/useAnimation.test.tsx +12 -12
- package/src/hooks/useAnimation.ts +4 -4
- package/src/hooks/useBodyClick.test.tsx +8 -8
- package/src/hooks/useBodyClick.ts +3 -3
- package/src/hooks/useFormSelector.test.ts +17 -17
- package/src/hooks/useFormSelector.ts +4 -4
- package/src/hooks/usePosition.test.tsx +215 -215
- package/src/hooks/usePosition.ts +73 -72
- package/src/hooks/useRepeater.test.tsx +26 -26
- package/src/hooks/useRepeater.ts +5 -5
- package/src/hooks/useScroll.test.tsx +5 -5
- package/src/hooks/useScroll.ts +3 -3
- package/src/hooks/useSpacing.test.ts +40 -40
- package/src/hooks/useSpacing.ts +3 -3
- package/src/hooks/useWrapper.test.ts +12 -12
- package/src/hooks/useWrapper.ts +10 -10
- package/src/index.ts +67 -67
- package/src/interfaces.ts +1 -1
- package/src/mixins.module.scss +76 -27
- package/src/types.d.ts +1 -1
- package/src/util/helper.test.tsx +25 -25
- package/src/util/helper.tsx +64 -64
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onewelcome/react-lib-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": "OneWelcome B.V.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build": "dts build",
|
|
19
19
|
"build-storybook": "build-storybook",
|
|
20
20
|
"dev": "npm-run-all -p start test:watch storybook",
|
|
21
|
-
"lint": "
|
|
21
|
+
"lint": "eslint --fix '**/*.{ts,tsx}'",
|
|
22
22
|
"prepare": "husky install && dts build",
|
|
23
23
|
"size": "size-limit",
|
|
24
24
|
"start": "dts watch",
|
|
@@ -47,20 +47,21 @@
|
|
|
47
47
|
}
|
|
48
48
|
],
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@babel/core": "^7.18.
|
|
50
|
+
"@babel/core": "^7.18.10",
|
|
51
|
+
"@onewelcome/eslint-config-shared-codestyle": "^9.0.3",
|
|
51
52
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
52
|
-
"@storybook/addon-a11y": "^6.5.
|
|
53
|
-
"@storybook/addon-docs": "^6.5.
|
|
54
|
-
"@storybook/addon-essentials": "^6.5.
|
|
55
|
-
"@storybook/addon-links": "^6.5.
|
|
56
|
-
"@storybook/addons": "^6.5.
|
|
57
|
-
"@storybook/builder-webpack5": "^6.5.
|
|
58
|
-
"@storybook/manager-webpack5": "^6.5.
|
|
53
|
+
"@storybook/addon-a11y": "^6.5.10",
|
|
54
|
+
"@storybook/addon-docs": "^6.5.10",
|
|
55
|
+
"@storybook/addon-essentials": "^6.5.10",
|
|
56
|
+
"@storybook/addon-links": "^6.5.10",
|
|
57
|
+
"@storybook/addons": "^6.5.10",
|
|
58
|
+
"@storybook/builder-webpack5": "^6.5.10",
|
|
59
|
+
"@storybook/manager-webpack5": "^6.5.10",
|
|
59
60
|
"@storybook/preset-scss": "^1.0.3",
|
|
60
|
-
"@storybook/react": "^6.5.
|
|
61
|
-
"@storybook/theming": "^6.5.
|
|
62
|
-
"@testing-library/dom": "^8.16.
|
|
63
|
-
"@testing-library/jest-dom": "^5.16.
|
|
61
|
+
"@storybook/react": "^6.5.10",
|
|
62
|
+
"@storybook/theming": "^6.5.10",
|
|
63
|
+
"@testing-library/dom": "^8.16.1",
|
|
64
|
+
"@testing-library/jest-dom": "^5.16.5",
|
|
64
65
|
"@testing-library/react": "^12.1.5",
|
|
65
66
|
"@testing-library/react-hooks": "^7.0.2",
|
|
66
67
|
"@testing-library/user-event": "^13.5.0",
|
|
@@ -68,23 +69,33 @@
|
|
|
68
69
|
"@tsconfig/recommended": "^1.0.1",
|
|
69
70
|
"@types/color-convert": "^2.0.0",
|
|
70
71
|
"@types/mdx": "^2.0.2",
|
|
71
|
-
"@types/react": "^17.0.
|
|
72
|
+
"@types/react": "^17.0.48",
|
|
72
73
|
"@types/react-dom": "^17.0.17",
|
|
74
|
+
"@types/react-router": "^5.1.18",
|
|
75
|
+
"@types/react-router-dom": "^5.3.3",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
|
77
|
+
"@typescript-eslint/parser": "^5.33.1",
|
|
73
78
|
"babel-loader": "^8.2.5",
|
|
74
79
|
"dts-cli": "^1.5.2",
|
|
80
|
+
"eslint": "^8.22.0",
|
|
81
|
+
"eslint-config-prettier": "^8.5.0",
|
|
82
|
+
"eslint-plugin-cypress": "^2.12.1",
|
|
83
|
+
"eslint-plugin-jest": "^26.8.3",
|
|
84
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
75
85
|
"html-webpack-plugin": "^5.5.0",
|
|
76
86
|
"husky": "^7.0.4",
|
|
77
87
|
"identity-obj-proxy": "^3.0.0",
|
|
78
88
|
"jest-junit": "^13.2.0",
|
|
79
89
|
"lint-staged": "^13.0.3",
|
|
80
90
|
"npm-run-all": "^4.1.5",
|
|
91
|
+
"prettier": "^2.7.1",
|
|
81
92
|
"react": "^17.0.2",
|
|
82
93
|
"react-dom": "^17.0.2",
|
|
83
94
|
"react-is": "^17.0.2",
|
|
84
95
|
"react-router": "^6.3.0",
|
|
85
96
|
"react-router-dom": "^6.3.0",
|
|
86
97
|
"rollup-plugin-styles": "^4.0.0",
|
|
87
|
-
"sass": "^1.
|
|
98
|
+
"sass": "^1.54.3",
|
|
88
99
|
"size-limit": "^7.0.8",
|
|
89
100
|
"tslib": "^2.4.0",
|
|
90
101
|
"typescript": "^4.7.4"
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Breadcrumbs, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { Link } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Breadcrumbs, Props } from "./Breadcrumbs";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { Link } from "../Link/Link";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {
|
|
7
|
-
|
|
7
|
+
"aria-label": "Breadcrumbs",
|
|
8
8
|
children: [
|
|
9
9
|
<Link key="0" to="#1" data-testid="link">
|
|
10
10
|
Test1
|
|
11
11
|
</Link>,
|
|
12
12
|
<Link key="1" to="#2" data-testid="link">
|
|
13
13
|
Test2
|
|
14
|
-
</Link
|
|
15
|
-
]
|
|
14
|
+
</Link>
|
|
15
|
+
]
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const createBreadcrumbs = (params?: (defaultParams: Props) => Props) => {
|
|
@@ -21,22 +21,22 @@ const createBreadcrumbs = (params?: (defaultParams: Props) => Props) => {
|
|
|
21
21
|
parameters = params(defaultParams);
|
|
22
22
|
}
|
|
23
23
|
const queries = render(<Breadcrumbs {...parameters} data-testid="breadcrumbs"></Breadcrumbs>);
|
|
24
|
-
const breadcrumbs = queries.getByTestId(
|
|
24
|
+
const breadcrumbs = queries.getByTestId("breadcrumbs");
|
|
25
25
|
|
|
26
26
|
return {
|
|
27
27
|
...queries,
|
|
28
|
-
breadcrumbs
|
|
28
|
+
breadcrumbs
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
describe(
|
|
33
|
-
it(
|
|
32
|
+
describe("Breadcrumbs should render", () => {
|
|
33
|
+
it("renders without crashing", () => {
|
|
34
34
|
const { breadcrumbs } = createBreadcrumbs();
|
|
35
35
|
|
|
36
36
|
expect(breadcrumbs).toBeDefined();
|
|
37
|
-
expect(breadcrumbs.firstChild).not.toHaveAttribute(
|
|
38
|
-
expect((breadcrumbs.firstChild as HTMLElement).tagName).toEqual(
|
|
39
|
-
expect(breadcrumbs.lastChild).toHaveAttribute(
|
|
40
|
-
expect((breadcrumbs.lastChild as HTMLElement).tagName).toEqual(
|
|
37
|
+
expect(breadcrumbs.firstChild).not.toHaveAttribute("aria-current");
|
|
38
|
+
expect((breadcrumbs.firstChild as HTMLElement).tagName).toEqual("A");
|
|
39
|
+
expect(breadcrumbs.lastChild).toHaveAttribute("aria-current", "page");
|
|
40
|
+
expect((breadcrumbs.lastChild as HTMLElement).tagName).toEqual("SPAN");
|
|
41
41
|
});
|
|
42
42
|
});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef, Fragment, ReactElement } from
|
|
2
|
-
import { Icon, Icons } from
|
|
3
|
-
import { Link, Props as LinkProps } from
|
|
4
|
-
import { Typography } from
|
|
5
|
-
import classes from
|
|
1
|
+
import React, { ComponentPropsWithRef, Fragment, ReactElement } from "react";
|
|
2
|
+
import { Icon, Icons } from "../Icon/Icon";
|
|
3
|
+
import { Link, Props as LinkProps } from "../Link/Link";
|
|
4
|
+
import { Typography } from "../Typography/Typography";
|
|
5
|
+
import classes from "./Breadcrumbs.module.scss";
|
|
6
6
|
|
|
7
7
|
type ChildrenType = ReactElement<LinkProps, typeof Link>;
|
|
8
8
|
|
|
9
|
-
export interface Props extends ComponentPropsWithRef<
|
|
9
|
+
export interface Props extends ComponentPropsWithRef<"div"> {
|
|
10
10
|
children: ChildrenType | ChildrenType[];
|
|
11
|
-
|
|
11
|
+
"aria-label": string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const Breadcrumbs = React.forwardRef<HTMLDivElement, Props>(
|
|
15
|
-
({ children,
|
|
15
|
+
({ children, "aria-label": ariaLabel, className = "", ...rest }: Props, ref) => {
|
|
16
16
|
const items = React.Children.map(children, (child, index) => {
|
|
17
17
|
const isLastElement = Array.isArray(children) ? index === children.length - 1 : true;
|
|
18
18
|
if (isLastElement) {
|
|
@@ -21,7 +21,7 @@ export const Breadcrumbs = React.forwardRef<HTMLDivElement, Props>(
|
|
|
21
21
|
key={child.key}
|
|
22
22
|
variant="body"
|
|
23
23
|
tag="span"
|
|
24
|
-
className={classes[
|
|
24
|
+
className={classes["last"]}
|
|
25
25
|
aria-current="page"
|
|
26
26
|
>
|
|
27
27
|
{child.props.children}
|
|
@@ -31,7 +31,7 @@ export const Breadcrumbs = React.forwardRef<HTMLDivElement, Props>(
|
|
|
31
31
|
return (
|
|
32
32
|
<Fragment key={child.key}>
|
|
33
33
|
{React.cloneElement(child)}
|
|
34
|
-
<Icon icon={Icons.ChevronRight} className={classes[
|
|
34
|
+
<Icon icon={Icons.ChevronRight} className={classes["icon"]} />
|
|
35
35
|
</Fragment>
|
|
36
36
|
);
|
|
37
37
|
}
|
|
@@ -41,7 +41,7 @@ export const Breadcrumbs = React.forwardRef<HTMLDivElement, Props>(
|
|
|
41
41
|
{...rest}
|
|
42
42
|
ref={ref}
|
|
43
43
|
aria-label={ariaLabel}
|
|
44
|
-
className={`${classes[
|
|
44
|
+
className={`${classes["breadcrumbs"]} ${className}`}
|
|
45
45
|
>
|
|
46
46
|
{items}
|
|
47
47
|
</nav>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from
|
|
2
|
-
import { BaseButton, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import userEvent from
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { BaseButton, Props } from "./BaseButton";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {};
|
|
7
7
|
|
|
@@ -15,29 +15,29 @@ const createBaseButton = (params?: (defaultParams: Props) => Props) => {
|
|
|
15
15
|
baseButton content
|
|
16
16
|
</BaseButton>
|
|
17
17
|
);
|
|
18
|
-
const baseButton = queries.getByTestId(
|
|
18
|
+
const baseButton = queries.getByTestId("baseButton");
|
|
19
19
|
|
|
20
20
|
return {
|
|
21
21
|
...queries,
|
|
22
|
-
baseButton
|
|
22
|
+
baseButton
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
describe(
|
|
27
|
-
it(
|
|
26
|
+
describe("BaseButton should render", () => {
|
|
27
|
+
it("renders without crashing", () => {
|
|
28
28
|
const { baseButton } = createBaseButton();
|
|
29
29
|
|
|
30
30
|
expect(baseButton).toBeDefined();
|
|
31
|
-
expect(baseButton).toHaveTextContent(
|
|
31
|
+
expect(baseButton).toHaveTextContent("baseButton content");
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
describe(
|
|
36
|
-
it(
|
|
35
|
+
describe("On click handler", () => {
|
|
36
|
+
it("executes the onclick handler", async () => {
|
|
37
37
|
const onClickHandler = jest.fn();
|
|
38
|
-
const { baseButton } = createBaseButton(
|
|
38
|
+
const { baseButton } = createBaseButton(defaultParams => ({
|
|
39
39
|
...defaultParams,
|
|
40
|
-
onClick: onClickHandler
|
|
40
|
+
onClick: onClickHandler
|
|
41
41
|
}));
|
|
42
42
|
|
|
43
43
|
userEvent.click(baseButton);
|
|
@@ -46,13 +46,13 @@ describe('On click handler', () => {
|
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
describe(
|
|
50
|
-
it(
|
|
49
|
+
describe("Properties of the button", () => {
|
|
50
|
+
it("should be disabled, function should not have been called", () => {
|
|
51
51
|
const onClickHandler = jest.fn();
|
|
52
|
-
const { baseButton } = createBaseButton(
|
|
52
|
+
const { baseButton } = createBaseButton(defaultParams => ({
|
|
53
53
|
...defaultParams,
|
|
54
54
|
disabled: true,
|
|
55
|
-
onClick: onClickHandler
|
|
55
|
+
onClick: onClickHandler
|
|
56
56
|
}));
|
|
57
57
|
|
|
58
58
|
userEvent.click(baseButton);
|
|
@@ -60,28 +60,28 @@ describe('Properties of the button', () => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('should have the class "TESTING"', () => {
|
|
63
|
-
const { baseButton } = createBaseButton(
|
|
63
|
+
const { baseButton } = createBaseButton(defaultParams => ({
|
|
64
64
|
...defaultParams,
|
|
65
|
-
className:
|
|
65
|
+
className: "TESTING"
|
|
66
66
|
}));
|
|
67
67
|
|
|
68
|
-
expect(baseButton).toHaveClass(
|
|
68
|
+
expect(baseButton).toHaveClass("TESTING");
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
it('should have a "name" property with the value "button"', () => {
|
|
72
|
-
const { baseButton } = createBaseButton(
|
|
72
|
+
const { baseButton } = createBaseButton(defaultParams => ({
|
|
73
73
|
...defaultParams,
|
|
74
|
-
name:
|
|
74
|
+
name: "button"
|
|
75
75
|
}));
|
|
76
76
|
|
|
77
|
-
expect(baseButton).toHaveAttribute(
|
|
77
|
+
expect(baseButton).toHaveAttribute("name", "button");
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
describe(
|
|
82
|
-
it(
|
|
81
|
+
describe("ref should work", () => {
|
|
82
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
83
83
|
const ExampleComponent = ({
|
|
84
|
-
propagateRef
|
|
84
|
+
propagateRef
|
|
85
85
|
}: {
|
|
86
86
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
87
87
|
}) => {
|
|
@@ -97,7 +97,7 @@ describe('ref should work', () => {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
100
|
-
expect(ref.current).toHaveAttribute(
|
|
100
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from
|
|
2
|
-
import classes from
|
|
1
|
+
import React, { ComponentPropsWithRef } from "react";
|
|
2
|
+
import classes from "./BaseButton.module.scss";
|
|
3
3
|
|
|
4
|
-
export interface Props extends ComponentPropsWithRef<
|
|
5
|
-
type?:
|
|
4
|
+
export interface Props extends ComponentPropsWithRef<"button"> {
|
|
5
|
+
type?: "submit" | "button" | "reset";
|
|
6
6
|
disabled?: boolean;
|
|
7
|
-
color?:
|
|
7
|
+
color?: "primary" | "secondary" | "tertiary" | "default";
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const BaseButton = React.forwardRef<HTMLButtonElement, Props>(
|
|
11
|
-
({ children, type =
|
|
12
|
-
const validTypes = [
|
|
11
|
+
({ children, type = "button", className, ...rest }, ref) => {
|
|
12
|
+
const validTypes = ["submit", "button", "reset"];
|
|
13
13
|
|
|
14
14
|
if (!validTypes.includes(type))
|
|
15
15
|
throw new Error(
|
|
@@ -21,7 +21,7 @@ export const BaseButton = React.forwardRef<HTMLButtonElement, Props>(
|
|
|
21
21
|
{...rest}
|
|
22
22
|
ref={ref}
|
|
23
23
|
type={type}
|
|
24
|
-
className={`${classes.button} ${className ? className :
|
|
24
|
+
className={`${classes.button} ${className ? className : ""}`}
|
|
25
25
|
>
|
|
26
26
|
{children}
|
|
27
27
|
</button>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
@import
|
|
2
|
-
@import
|
|
1
|
+
@import "../readyclasses.module.scss";
|
|
2
|
+
@import "../mixins.module.scss";
|
|
3
3
|
|
|
4
4
|
.fill {
|
|
5
|
-
@include button(
|
|
5
|
+
@include button("fill");
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.outline {
|
|
9
|
-
@include button(
|
|
9
|
+
@include button("outline");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.text {
|
|
13
|
-
@include button(
|
|
13
|
+
@include button("text");
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
.has-icon {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from
|
|
2
|
-
import { Button, Props } from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { Icon, Icons } from
|
|
1
|
+
import React, { useRef, useEffect } from "react";
|
|
2
|
+
import { Button, Props } from "./Button";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { Icon, Icons } from "../Icon/Icon";
|
|
5
5
|
|
|
6
6
|
const defaultParams: Props = {};
|
|
7
7
|
|
|
@@ -15,26 +15,26 @@ const createButton = (params?: (defaultParams: Props) => Props) => {
|
|
|
15
15
|
button content
|
|
16
16
|
</Button>
|
|
17
17
|
);
|
|
18
|
-
const button = queries.getByTestId(
|
|
18
|
+
const button = queries.getByTestId("button");
|
|
19
19
|
|
|
20
20
|
return {
|
|
21
21
|
...queries,
|
|
22
|
-
button
|
|
22
|
+
button
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
describe(
|
|
27
|
-
it(
|
|
26
|
+
describe("Button should render", () => {
|
|
27
|
+
it("renders without crashing", () => {
|
|
28
28
|
const { button } = createButton();
|
|
29
29
|
|
|
30
30
|
expect(button).toBeDefined();
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
describe(
|
|
35
|
-
it(
|
|
34
|
+
describe("ref should work", () => {
|
|
35
|
+
it("should give back the proper data prop, this also checks if the component propagates ...rest properly", () => {
|
|
36
36
|
const ExampleComponent = ({
|
|
37
|
-
propagateRef
|
|
37
|
+
propagateRef
|
|
38
38
|
}: {
|
|
39
39
|
propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
|
|
40
40
|
}) => {
|
|
@@ -50,73 +50,73 @@ describe('ref should work', () => {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const refCheck = (ref: React.RefObject<HTMLElement>) => {
|
|
53
|
-
expect(ref.current).toHaveAttribute(
|
|
53
|
+
expect(ref.current).toHaveAttribute("data-ref", "testing");
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
render(<ExampleComponent propagateRef={refCheck} />);
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
describe(
|
|
61
|
-
it(
|
|
60
|
+
describe("Button should render", () => {
|
|
61
|
+
it("renders without crashing", () => {
|
|
62
62
|
const { button } = createButton();
|
|
63
63
|
|
|
64
64
|
expect(button).toBeDefined();
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
describe(
|
|
68
|
+
describe("Different variants of the button", () => {
|
|
69
69
|
it('should have a class of "primary"', () => {
|
|
70
70
|
const { button } = createButton();
|
|
71
|
-
expect(button.classList.contains(
|
|
71
|
+
expect(button.classList.contains("primary")).toBe(true);
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
it('should have a class of "secondary"', () => {
|
|
75
|
-
const { button } = createButton(
|
|
76
|
-
expect(button.classList.contains(
|
|
75
|
+
const { button } = createButton(defaultParams => ({ ...defaultParams, color: "secondary" }));
|
|
76
|
+
expect(button.classList.contains("secondary")).toBe(true);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
it('should have a class of "tertiary"', () => {
|
|
80
|
-
const { button } = createButton(
|
|
81
|
-
expect(button.classList.contains(
|
|
80
|
+
const { button } = createButton(defaultParams => ({ ...defaultParams, color: "tertiary" }));
|
|
81
|
+
expect(button.classList.contains("tertiary")).toBe(true);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it('should have a class of "fill"', () => {
|
|
85
|
-
const { button } = createButton(
|
|
86
|
-
expect(button.classList.contains(
|
|
85
|
+
const { button } = createButton(defaultParams => ({ ...defaultParams, variant: "fill" }));
|
|
86
|
+
expect(button.classList.contains("fill")).toBe(true);
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
it('should have a class of "outline"', () => {
|
|
90
|
-
const { button } = createButton(
|
|
91
|
-
expect(button.classList.contains(
|
|
90
|
+
const { button } = createButton(defaultParams => ({ ...defaultParams, variant: "outline" }));
|
|
91
|
+
expect(button.classList.contains("outline")).toBe(true);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
it('should have a class of "text"', () => {
|
|
95
|
-
const { button } = createButton(
|
|
96
|
-
expect(button.classList.contains(
|
|
95
|
+
const { button } = createButton(defaultParams => ({ ...defaultParams, variant: "text" }));
|
|
96
|
+
expect(button.classList.contains("text")).toBe(true);
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
describe(
|
|
101
|
-
it(
|
|
102
|
-
const { button } = createButton(
|
|
100
|
+
describe("Button contains an icon", () => {
|
|
101
|
+
it("Contains an icon at the start", () => {
|
|
102
|
+
const { button } = createButton(defaultParams => ({
|
|
103
103
|
...defaultParams,
|
|
104
|
-
startIcon: <Icon icon={Icons.Calendar}
|
|
104
|
+
startIcon: <Icon icon={Icons.Calendar} />
|
|
105
105
|
}));
|
|
106
106
|
|
|
107
|
-
expect(button.classList.contains(
|
|
108
|
-
expect(button.firstElementChild?.nodeName).toBe(
|
|
109
|
-
expect(button.querySelector(
|
|
107
|
+
expect(button.classList.contains("has-icon")).toBe(true);
|
|
108
|
+
expect(button.firstElementChild?.nodeName).toBe("I");
|
|
109
|
+
expect(button.querySelector("i + span")!.innerHTML).toBe("button content");
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
it(
|
|
113
|
-
const { button } = createButton(
|
|
112
|
+
it("Contains an icon at the end", () => {
|
|
113
|
+
const { button } = createButton(defaultParams => ({
|
|
114
114
|
...defaultParams,
|
|
115
|
-
endIcon: <Icon icon={Icons.Calendar}
|
|
115
|
+
endIcon: <Icon icon={Icons.Calendar} />
|
|
116
116
|
}));
|
|
117
117
|
|
|
118
|
-
expect(button.classList.contains(
|
|
119
|
-
expect(button.lastElementChild?.nodeName).toBe(
|
|
120
|
-
expect(button.querySelector(
|
|
118
|
+
expect(button.classList.contains("has-icon")).toBe(true);
|
|
119
|
+
expect(button.lastElementChild?.nodeName).toBe("I");
|
|
120
|
+
expect(button.querySelector("span")!.innerHTML).toBe("button content");
|
|
121
121
|
});
|
|
122
122
|
});
|
package/src/Button/Button.tsx
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { BaseButton, Props as BaseButtonProps } from
|
|
3
|
-
import classes from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseButton, Props as BaseButtonProps } from "./BaseButton";
|
|
3
|
+
import classes from "./Button.module.scss";
|
|
4
4
|
|
|
5
5
|
export interface Props extends BaseButtonProps {
|
|
6
6
|
startIcon?: React.ReactNode | false;
|
|
7
7
|
endIcon?: React.ReactNode | false;
|
|
8
8
|
children?: React.ReactNode;
|
|
9
|
-
variant?:
|
|
9
|
+
variant?: "text" | "fill" | "outline";
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const Button = React.forwardRef<HTMLButtonElement, Props>(
|
|
13
13
|
(
|
|
14
14
|
{
|
|
15
15
|
children,
|
|
16
|
-
variant =
|
|
17
|
-
color =
|
|
16
|
+
variant = "fill",
|
|
17
|
+
color = "primary",
|
|
18
18
|
startIcon = false,
|
|
19
19
|
endIcon = false,
|
|
20
20
|
className,
|
|
@@ -25,15 +25,15 @@ export const Button = React.forwardRef<HTMLButtonElement, Props>(
|
|
|
25
25
|
const additionalClasses = [];
|
|
26
26
|
|
|
27
27
|
if (startIcon || endIcon) {
|
|
28
|
-
additionalClasses.push(classes[
|
|
28
|
+
additionalClasses.push(classes["has-icon"]);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (startIcon) {
|
|
32
|
-
additionalClasses.push(classes[
|
|
32
|
+
additionalClasses.push(classes["start-icon"]);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (endIcon) {
|
|
36
|
-
additionalClasses.push(classes[
|
|
36
|
+
additionalClasses.push(classes["end-icon"]);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (className) {
|
|
@@ -44,7 +44,7 @@ export const Button = React.forwardRef<HTMLButtonElement, Props>(
|
|
|
44
44
|
<BaseButton
|
|
45
45
|
{...rest}
|
|
46
46
|
ref={ref}
|
|
47
|
-
className={`${classes[color]} ${classes[variant]} ${additionalClasses.join(
|
|
47
|
+
className={`${classes[color]} ${classes[variant]} ${additionalClasses.join(" ")}`}
|
|
48
48
|
>
|
|
49
49
|
{startIcon && <i>{startIcon} </i>}
|
|
50
50
|
<span>{children}</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@import
|
|
2
|
-
@import
|
|
1
|
+
@import "../readyclasses.module.scss";
|
|
2
|
+
@import "../mixins.module.scss";
|
|
3
3
|
|
|
4
4
|
.icon-button {
|
|
5
5
|
border: var(--button-border-width) var(--button-border-style) transparent;
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
&.fill {
|
|
44
|
-
@include button(
|
|
44
|
+
@include button("fill", "icon");
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
&.text {
|
|
48
|
-
@include button(
|
|
48
|
+
@include button("text", "icon");
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
&.outline {
|
|
52
|
-
@include button(
|
|
52
|
+
@include button("outline", "icon");
|
|
53
53
|
}
|
|
54
54
|
}
|