@newtonschool/grauity 0.0.13 → 0.1.10
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/README.md +138 -9
- package/dist/fonts/grauity-icons.eot +0 -0
- package/dist/fonts/grauity-icons.ttf +0 -0
- package/dist/fonts/grauity-icons.woff +0 -0
- package/dist/fonts/grauity-icons.woff2 +0 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useClickAway.d.ts +15 -0
- package/dist/hooks/useClickAway.d.ts.map +1 -0
- package/dist/hooks/useDisableBodyScroll.d.ts +7 -0
- package/dist/hooks/useDisableBodyScroll.d.ts.map +1 -0
- package/dist/hooks/useKeyboardEvent.d.ts +17 -0
- package/dist/hooks/useKeyboardEvent.d.ts.map +1 -0
- package/dist/index.d.ts +830 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.css +10 -1
- package/dist/main.css.map +1 -1
- package/dist/module.css +10 -1
- package/dist/module.css.map +1 -1
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/stories/atoms/Colors/FoundationColors.stories.d.ts +7 -0
- package/dist/stories/atoms/Colors/FoundationColors.stories.d.ts.map +1 -0
- package/dist/stories/atoms/Colors/index.stories.d.ts +18 -0
- package/dist/stories/atoms/Colors/index.stories.d.ts.map +1 -0
- package/dist/stories/atoms/CornerRadius/index.stories.d.ts +7 -0
- package/dist/stories/atoms/CornerRadius/index.stories.d.ts.map +1 -0
- package/dist/stories/atoms/Spacing/index.stories.d.ts +7 -0
- package/dist/stories/atoms/Spacing/index.stories.d.ts.map +1 -0
- package/dist/stories/decorators/withEnableBodyScroll.d.ts +8 -0
- package/dist/stories/decorators/withEnableBodyScroll.d.ts.map +1 -0
- package/dist/stories/decorators/withInlineContainer.d.ts +15 -0
- package/dist/stories/decorators/withInlineContainer.d.ts.map +1 -0
- package/dist/stories/elements/Alert/Gallery.stories.d.ts +30 -0
- package/dist/stories/elements/Alert/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/Alert/index.stories.d.ts +30 -0
- package/dist/stories/elements/Alert/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/AlertBanner/Gallery.stories.d.ts +33 -0
- package/dist/stories/elements/AlertBanner/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/AlertBanner/index.stories.d.ts +30 -0
- package/dist/stories/elements/AlertBanner/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Button/Gallery.stories.d.ts +10 -0
- package/dist/stories/elements/Button/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/Button/index.stories.d.ts +9 -0
- package/dist/stories/elements/Button/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Icon/index.stories.d.ts +14 -0
- package/dist/stories/elements/Icon/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/IconButton/Gallery.stories.d.ts +10 -0
- package/dist/stories/elements/IconButton/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/IconButton/index.stories.d.ts +9 -0
- package/dist/stories/elements/IconButton/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.source.d.ts +3 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.source.d.ts.map +1 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.stories.d.ts +43 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/ConfirmationDialogWithTrigger.stories.d.ts +42 -0
- package/dist/stories/elements/Modal/ConfirmationDialogWithTrigger.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/MultiStepModal.stories.d.ts +46 -0
- package/dist/stories/elements/Modal/MultiStepModal.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/index.stories.d.ts +32 -0
- package/dist/stories/elements/Modal/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/multiStepArgs.d.ts +4 -0
- package/dist/stories/elements/Modal/multiStepArgs.d.ts.map +1 -0
- package/dist/stories/elements/Modal/singleStepArgs.d.ts +4 -0
- package/dist/stories/elements/Modal/singleStepArgs.d.ts.map +1 -0
- package/dist/stories/elements/Table/Manual.source.d.ts +3 -0
- package/dist/stories/elements/Table/Manual.source.d.ts.map +1 -0
- package/dist/stories/elements/Table/Manual.stories.d.ts +54 -0
- package/dist/stories/elements/Table/Manual.stories.d.ts.map +1 -0
- package/dist/stories/elements/Table/ManualColumnNesting.source.d.ts +3 -0
- package/dist/stories/elements/Table/ManualColumnNesting.source.d.ts.map +1 -0
- package/dist/stories/elements/Table/ManualColumnNesting.stories.d.ts +53 -0
- package/dist/stories/elements/Table/ManualColumnNesting.stories.d.ts.map +1 -0
- package/dist/stories/elements/Table/index.stories.d.ts +46 -0
- package/dist/stories/elements/Table/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Table/simpleArgs.d.ts +4 -0
- package/dist/stories/elements/Table/simpleArgs.d.ts.map +1 -0
- package/dist/stories/elements/Typography/TypographyGallery.stories.d.ts +29 -0
- package/dist/stories/elements/Typography/TypographyGallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/Typography/index.stories.d.ts +28 -0
- package/dist/stories/elements/Typography/index.stories.d.ts.map +1 -0
- package/dist/stories/helper-components/ColorRenderer/index.d.ts +15 -0
- package/dist/stories/helper-components/ColorRenderer/index.d.ts.map +1 -0
- package/dist/stories/helper-components/DocPageWithPlayground.d.ts +12 -0
- package/dist/stories/helper-components/DocPageWithPlayground.d.ts.map +1 -0
- package/dist/stories/helper-components/TokenBlock/index.d.ts +21 -0
- package/dist/stories/helper-components/TokenBlock/index.d.ts.map +1 -0
- package/dist/stories/helper-components/TokenBlock/index.styles.d.ts +4 -0
- package/dist/stories/helper-components/TokenBlock/index.styles.d.ts.map +1 -0
- package/dist/stories/utils/index.d.ts +82 -0
- package/dist/stories/utils/index.d.ts.map +1 -0
- package/dist/ui/core/colors/colorTypes.d.ts +1 -0
- package/dist/ui/core/colors/colorTypes.d.ts.map +1 -0
- package/dist/ui/core/colors/index.d.ts +1 -0
- package/dist/ui/core/colors/index.d.ts.map +1 -0
- package/dist/ui/core/icons/iconTags.d.ts.map +1 -0
- package/dist/ui/core/icons/iconTypes.d.ts.map +1 -0
- package/dist/{core → ui/core}/icons/index.d.ts +1 -1
- package/dist/ui/core/icons/index.d.ts.map +1 -0
- package/dist/ui/core/index.d.ts +7 -0
- package/dist/ui/core/index.d.ts.map +1 -0
- package/dist/ui/core/miscellaneous-choices/index.d.ts.map +1 -0
- package/dist/ui/core/miscellaneous-choices/miscellaneousTypes.d.ts.map +1 -0
- package/dist/ui/core/sizes/index.d.ts.map +1 -0
- package/dist/ui/core/sizes/sizeTypes.d.ts +3 -0
- package/dist/ui/core/sizes/sizeTypes.d.ts.map +1 -0
- package/dist/ui/elements/Alert/Alert.d.ts +8 -0
- package/dist/ui/elements/Alert/Alert.d.ts.map +1 -0
- package/dist/ui/elements/Alert/Alert.styles.d.ts +7 -0
- package/dist/ui/elements/Alert/Alert.styles.d.ts.map +1 -0
- package/dist/ui/elements/Alert/Alert.test.d.ts +2 -0
- package/dist/ui/elements/Alert/Alert.test.d.ts.map +1 -0
- package/dist/ui/elements/Alert/constants.d.ts +140 -0
- package/dist/ui/elements/Alert/constants.d.ts.map +1 -0
- package/dist/ui/elements/Alert/index.d.ts +7 -0
- package/dist/ui/elements/Alert/index.d.ts.map +1 -0
- package/dist/ui/elements/Alert/types.d.ts +125 -0
- package/dist/ui/elements/Alert/types.d.ts.map +1 -0
- package/dist/ui/elements/Alert/utils.d.ts +1 -0
- package/dist/ui/elements/Alert/utils.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.d.ts +9 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.styles.d.ts +4 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.styles.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.test.d.ts +2 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.test.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/constants.d.ts +140 -0
- package/dist/ui/elements/AlertBanner/constants.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/index.d.ts +7 -0
- package/dist/ui/elements/AlertBanner/index.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/types.d.ts +111 -0
- package/dist/ui/elements/AlertBanner/types.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/utils.d.ts +105 -0
- package/dist/ui/elements/AlertBanner/utils.d.ts.map +1 -0
- package/dist/ui/elements/Button/Button.d.ts +11 -0
- package/dist/ui/elements/Button/Button.d.ts.map +1 -0
- package/dist/ui/elements/Button/Button.styles.d.ts +4 -0
- package/dist/ui/elements/Button/Button.styles.d.ts.map +1 -0
- package/dist/ui/elements/Button/Button.test.d.ts +2 -0
- package/dist/ui/elements/Button/Button.test.d.ts.map +1 -0
- package/dist/ui/elements/Button/ButtonGroup.d.ts +11 -0
- package/dist/ui/elements/Button/ButtonGroup.d.ts.map +1 -0
- package/dist/ui/elements/Button/ButtonGroup.styles.d.ts +2 -0
- package/dist/ui/elements/Button/ButtonGroup.styles.d.ts.map +1 -0
- package/dist/ui/elements/Button/IconButton.d.ts +8 -0
- package/dist/ui/elements/Button/IconButton.d.ts.map +1 -0
- package/dist/ui/elements/Button/IconButton.test.d.ts +2 -0
- package/dist/ui/elements/Button/IconButton.test.d.ts.map +1 -0
- package/dist/ui/elements/Button/constants.d.ts +54 -0
- package/dist/ui/elements/Button/constants.d.ts.map +1 -0
- package/dist/ui/elements/Button/index.d.ts +9 -0
- package/dist/ui/elements/Button/index.d.ts.map +1 -0
- package/dist/ui/elements/Button/types.d.ts +226 -0
- package/dist/ui/elements/Button/types.d.ts.map +1 -0
- package/dist/ui/elements/Button/utils.d.ts +1 -0
- package/dist/ui/elements/Button/utils.d.ts.map +1 -0
- package/dist/ui/elements/Icon/Icon.d.ts +48 -0
- package/dist/ui/elements/Icon/Icon.d.ts.map +1 -0
- package/dist/ui/elements/Icon/Icon.styles.d.ts +5 -0
- package/dist/ui/elements/Icon/Icon.styles.d.ts.map +1 -0
- package/dist/ui/elements/Icon/index.d.ts +3 -0
- package/dist/ui/elements/Icon/index.d.ts.map +1 -0
- package/dist/ui/elements/Icon/types.d.ts +74 -0
- package/dist/ui/elements/Icon/types.d.ts.map +1 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.d.ts +43 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.d.ts.map +1 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.test.d.ts +2 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.test.d.ts.map +1 -0
- package/dist/ui/elements/Modal/Modal.d.ts +21 -0
- package/dist/ui/elements/Modal/Modal.d.ts.map +1 -0
- package/dist/ui/elements/Modal/Modal.styles.d.ts +18 -0
- package/dist/ui/elements/Modal/Modal.styles.d.ts.map +1 -0
- package/dist/ui/elements/Modal/Modal.test.d.ts +2 -0
- package/dist/ui/elements/Modal/Modal.test.d.ts.map +1 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.d.ts +46 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.d.ts.map +1 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.test.d.ts +2 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.test.d.ts.map +1 -0
- package/dist/ui/elements/Modal/constants.d.ts +1 -0
- package/dist/ui/elements/Modal/constants.d.ts.map +1 -0
- package/dist/ui/elements/Modal/index.d.ts +5 -0
- package/dist/ui/elements/Modal/index.d.ts.map +1 -0
- package/dist/ui/elements/Modal/types.d.ts +312 -0
- package/dist/ui/elements/Modal/types.d.ts.map +1 -0
- package/dist/ui/elements/Modal/utils.d.ts +1 -0
- package/dist/ui/elements/Modal/utils.d.ts.map +1 -0
- package/dist/ui/elements/Table/Table.d.ts +47 -0
- package/dist/ui/elements/Table/Table.d.ts.map +1 -0
- package/dist/ui/elements/Table/Table.styles.d.ts +8 -0
- package/dist/ui/elements/Table/Table.styles.d.ts.map +1 -0
- package/dist/ui/elements/Table/Table.test.d.ts +2 -0
- package/dist/ui/elements/Table/Table.test.d.ts.map +1 -0
- package/dist/ui/elements/Table/constants.d.ts +1 -0
- package/dist/ui/elements/Table/constants.d.ts.map +1 -0
- package/dist/ui/elements/Table/index.d.ts +3 -0
- package/dist/ui/elements/Table/index.d.ts.map +1 -0
- package/dist/ui/elements/Table/types.d.ts +223 -0
- package/dist/ui/elements/Table/types.d.ts.map +1 -0
- package/dist/ui/elements/Table/utils.d.ts +1 -0
- package/dist/ui/elements/Table/utils.d.ts.map +1 -0
- package/dist/ui/elements/Typography/Typography.d.ts +36 -0
- package/dist/ui/elements/Typography/Typography.d.ts.map +1 -0
- package/dist/ui/elements/Typography/Typography.styles.d.ts +6 -0
- package/dist/ui/elements/Typography/Typography.styles.d.ts.map +1 -0
- package/dist/ui/elements/Typography/constants.d.ts +22 -0
- package/dist/ui/elements/Typography/constants.d.ts.map +1 -0
- package/dist/ui/elements/Typography/index.d.ts +5 -0
- package/dist/ui/elements/Typography/index.d.ts.map +1 -0
- package/dist/ui/elements/Typography/types.d.ts +50 -0
- package/dist/ui/elements/Typography/types.d.ts.map +1 -0
- package/dist/ui/elements/Typography/utils.d.ts +2 -0
- package/dist/ui/elements/Typography/utils.d.ts.map +1 -0
- package/dist/ui/helpers/classNameBuilders.d.ts.map +1 -0
- package/dist/ui/helpers/index.d.ts +3 -0
- package/dist/ui/helpers/index.d.ts.map +1 -0
- package/dist/ui/index.d.ts +11 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/{init → ui/init}/GrauityInit.d.ts +15 -3
- package/dist/ui/init/GrauityInit.d.ts.map +1 -0
- package/dist/ui/init/index.d.ts.map +1 -0
- package/dist/ui/themes/GlobalStyle.d.ts +5 -0
- package/dist/ui/themes/GlobalStyle.d.ts.map +1 -0
- package/dist/ui/themes/ThemeContext.d.ts +24 -0
- package/dist/ui/themes/ThemeContext.d.ts.map +1 -0
- package/dist/ui/themes/constants.d.ts +6 -0
- package/dist/ui/themes/constants.d.ts.map +1 -0
- package/dist/ui/themes/darkThemeConstants.d.ts +70 -0
- package/dist/ui/themes/darkThemeConstants.d.ts.map +1 -0
- package/dist/ui/themes/lightThemeConstants.d.ts +70 -0
- package/dist/ui/themes/lightThemeConstants.d.ts.map +1 -0
- package/dist/ui/themes/tokens.d.ts +1 -0
- package/dist/ui/themes/tokens.d.ts.map +1 -0
- package/dist/ui/themes/types.d.ts +73 -0
- package/dist/ui/themes/types.d.ts.map +1 -0
- package/package.json +53 -28
- package/ui/core/colors/colorTypes.ts +2 -20
- package/ui/core/colors/index.ts +23 -23
- package/ui/core/icons/index.ts +1 -3
- package/ui/core/index.ts +7 -10
- package/ui/core/sizes/sizeTypes.ts +1 -0
- package/ui/css/fonts.scss +0 -8
- package/ui/css/index.scss +0 -8
- package/ui/css/reset.scss +2 -5
- package/ui/elements/Alert/Alert.styles.ts +66 -0
- package/ui/elements/Alert/Alert.test.tsx +81 -0
- package/ui/elements/Alert/Alert.tsx +153 -0
- package/ui/elements/Alert/constants.ts +169 -0
- package/ui/elements/Alert/index.ts +6 -0
- package/ui/elements/Alert/types.ts +150 -0
- package/ui/elements/AlertBanner/AlertBanner.styles.ts +35 -0
- package/ui/elements/AlertBanner/AlertBanner.test.tsx +70 -0
- package/ui/elements/AlertBanner/AlertBanner.tsx +137 -0
- package/ui/elements/AlertBanner/constants.ts +179 -0
- package/ui/elements/AlertBanner/index.ts +6 -0
- package/ui/elements/AlertBanner/types.ts +133 -0
- package/ui/elements/AlertBanner/utils.ts +52 -0
- package/ui/elements/Button/Button.styles.ts +88 -0
- package/ui/elements/Button/Button.test.tsx +78 -0
- package/ui/elements/Button/Button.tsx +134 -0
- package/ui/elements/Button/ButtonGroup.styles.ts +7 -0
- package/ui/elements/Button/ButtonGroup.tsx +21 -0
- package/ui/elements/Button/IconButton.test.tsx +39 -0
- package/ui/elements/Button/IconButton.tsx +118 -0
- package/ui/elements/Button/constants.ts +304 -0
- package/ui/elements/Button/index.ts +8 -0
- package/ui/elements/Button/types.ts +282 -0
- package/ui/elements/Button/utils.ts +0 -0
- package/ui/elements/Icon/Icon.styles.ts +98 -0
- package/ui/elements/Icon/Icon.tsx +17 -107
- package/ui/elements/Icon/index.ts +1 -2
- package/ui/elements/Icon/types.ts +96 -0
- package/ui/elements/Modal/ConfirmationDialog/index.test.tsx +116 -0
- package/ui/elements/Modal/ConfirmationDialog/index.tsx +151 -0
- package/ui/elements/Modal/Modal.styles.ts +230 -0
- package/ui/elements/Modal/Modal.test.tsx +117 -0
- package/ui/elements/Modal/Modal.tsx +179 -0
- package/ui/elements/Modal/MultiStepModal/index.test.tsx +116 -0
- package/ui/elements/Modal/MultiStepModal/index.tsx +184 -0
- package/ui/elements/Modal/constants.ts +0 -0
- package/ui/elements/Modal/index.ts +4 -0
- package/ui/elements/Modal/types.ts +379 -0
- package/ui/elements/Modal/utils.tsx +0 -0
- package/ui/elements/Table/Table.styles.ts +178 -0
- package/ui/elements/Table/Table.test.tsx +72 -0
- package/ui/elements/Table/Table.tsx +118 -0
- package/ui/elements/Table/constants.ts +0 -0
- package/ui/elements/Table/index.ts +2 -0
- package/ui/elements/Table/types.ts +270 -0
- package/ui/elements/Table/utils.ts +0 -0
- package/ui/elements/Typography/Typography.styles.ts +29 -0
- package/ui/elements/Typography/Typography.tsx +70 -0
- package/ui/elements/Typography/constants.ts +292 -0
- package/ui/elements/Typography/index.ts +9 -0
- package/ui/elements/Typography/types.ts +116 -0
- package/ui/elements/Typography/utils.ts +11 -0
- package/ui/fonts/grauity-icons.eot +0 -0
- package/ui/fonts/grauity-icons.ttf +0 -0
- package/ui/fonts/grauity-icons.woff +0 -0
- package/ui/fonts/grauity-icons.woff2 +0 -0
- package/ui/helpers/index.ts +1 -7
- package/ui/index.ts +42 -3
- package/ui/init/GrauityInit.tsx +30 -7
- package/ui/init/index.ts +0 -1
- package/ui/themes/GlobalStyle.ts +273 -0
- package/ui/themes/ThemeContext.tsx +140 -0
- package/ui/themes/constants.ts +8 -0
- package/ui/themes/darkThemeConstants.ts +73 -0
- package/ui/themes/lightThemeConstants.ts +73 -0
- package/ui/themes/tokens.ts +0 -0
- package/ui/themes/types.ts +77 -0
- package/dist/core/colors/colorTypes.d.ts +0 -3
- package/dist/core/colors/colorTypes.d.ts.map +0 -1
- package/dist/core/colors/index.d.ts +0 -14
- package/dist/core/colors/index.d.ts.map +0 -1
- package/dist/core/icons/iconTags.d.ts.map +0 -1
- package/dist/core/icons/iconTypes.d.ts.map +0 -1
- package/dist/core/icons/index.d.ts.map +0 -1
- package/dist/core/index.d.ts +0 -9
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/miscellaneous-choices/index.d.ts.map +0 -1
- package/dist/core/miscellaneous-choices/miscellaneousTypes.d.ts.map +0 -1
- package/dist/core/sizes/index.d.ts.map +0 -1
- package/dist/core/sizes/sizeTypes.d.ts +0 -3
- package/dist/core/sizes/sizeTypes.d.ts.map +0 -1
- package/dist/elements/Icon/Icon.d.ts +0 -115
- package/dist/elements/Icon/Icon.d.ts.map +0 -1
- package/dist/elements/Icon/index.d.ts +0 -3
- package/dist/elements/Icon/index.d.ts.map +0 -1
- package/dist/elements/index.d.ts +0 -3
- package/dist/elements/index.d.ts.map +0 -1
- package/dist/helpers/classNameBuilders.d.ts.map +0 -1
- package/dist/helpers/getElementTypeFromProps.d.ts +0 -14
- package/dist/helpers/getElementTypeFromProps.d.ts.map +0 -1
- package/dist/helpers/index.d.ts +0 -4
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/init/GrauityInit.d.ts.map +0 -1
- package/dist/init/index.d.ts.map +0 -1
- package/ui/css/colors.scss +0 -131
- package/ui/css/icons.scss +0 -92
- package/ui/elements/index.ts +0 -2
- package/ui/helpers/getElementTypeFromProps.ts +0 -32
- /package/dist/{core → ui/core}/icons/iconTags.d.ts +0 -0
- /package/dist/{core → ui/core}/icons/iconTypes.d.ts +0 -0
- /package/dist/{core → ui/core}/miscellaneous-choices/index.d.ts +0 -0
- /package/dist/{core → ui/core}/miscellaneous-choices/miscellaneousTypes.d.ts +0 -0
- /package/dist/{core → ui/core}/sizes/index.d.ts +0 -0
- /package/dist/{helpers → ui/helpers}/classNameBuilders.d.ts +0 -0
- /package/dist/{init → ui/init}/index.d.ts +0 -0
- /package/ui/{css/sizes.scss → elements/Alert/utils.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newtonschool/grauity",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.1.10",
|
|
4
|
+
"description": "Design System for Newton School",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Newton School",
|
|
7
7
|
"Grauity",
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"name": "Praduman Goyal",
|
|
18
18
|
"email": "goyal.praduman611@gmail.com",
|
|
19
19
|
"homepage": "https://github.com/pradumangoyal"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "Mihir Sachdeva",
|
|
23
|
+
"email": "mihirsachdeva.ms@gmail.com",
|
|
24
|
+
"homepage": "https://github.com/mihirsachdeva"
|
|
20
25
|
}
|
|
21
26
|
],
|
|
22
27
|
"repository": {
|
|
@@ -28,8 +33,8 @@
|
|
|
28
33
|
"url": "https://github.com/Newton-School/grauity/issues"
|
|
29
34
|
},
|
|
30
35
|
"engines": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
36
|
+
"npm": ">=9",
|
|
37
|
+
"node": ">=18.0.0"
|
|
33
38
|
},
|
|
34
39
|
"source": "ui/index.ts",
|
|
35
40
|
"main": "dist/main.cjs",
|
|
@@ -58,7 +63,7 @@
|
|
|
58
63
|
"../node_modules/@types"
|
|
59
64
|
],
|
|
60
65
|
"scripts": {
|
|
61
|
-
"build": "npm run build-icons && npm run build-lib",
|
|
66
|
+
"build": "rm -rf .parcel-cache && npm run build-icons && npm run build-lib",
|
|
62
67
|
"build-lib": "npm run extract-typings && parcel build",
|
|
63
68
|
"build-icons": "npm run build-icons:optimize && npm run build-icons:generate",
|
|
64
69
|
"build-icons:optimize": "rimraf ./iconland/optimised/*.svg & svgo -q -p 8 -f ./iconland/seeds -o ./iconland/optimised",
|
|
@@ -70,8 +75,9 @@
|
|
|
70
75
|
"lint:staged": "lint-staged",
|
|
71
76
|
"prettify": "prettier --write",
|
|
72
77
|
"extract-typings": "tsc --project tsconfig.types.json",
|
|
73
|
-
"storybook": "
|
|
74
|
-
"build-storybook": "
|
|
78
|
+
"storybook": "storybook dev -p 6006",
|
|
79
|
+
"build-storybook": "storybook build -o docs && echo 'grauity.newtonschool.co' > docs/CNAME",
|
|
80
|
+
"test": "jest"
|
|
75
81
|
},
|
|
76
82
|
"pre-commit": "lint:staged",
|
|
77
83
|
"lint-staged": {
|
|
@@ -88,39 +94,53 @@
|
|
|
88
94
|
"devDependencies": {
|
|
89
95
|
"@babel/core": "^7.20.12",
|
|
90
96
|
"@babel/preset-env": "^7.20.2",
|
|
97
|
+
"@babel/preset-flow": "^7.24.7",
|
|
91
98
|
"@babel/preset-react": "^7.18.6",
|
|
92
99
|
"@babel/preset-typescript": "^7.18.6",
|
|
100
|
+
"@chromatic-com/storybook": "^1.8.0",
|
|
93
101
|
"@parcel/packager-ts": "^2.8.2",
|
|
94
102
|
"@parcel/transformer-sass": "^2.8.2",
|
|
95
103
|
"@parcel/transformer-typescript-tsc": "^2.8.2",
|
|
96
104
|
"@parcel/transformer-typescript-types": "^2.8.2",
|
|
97
|
-
"@storybook/addon-
|
|
98
|
-
"@storybook/addon-
|
|
99
|
-
"@storybook/addon-
|
|
100
|
-
"@storybook/addon-
|
|
101
|
-
"@storybook/addon-
|
|
102
|
-
"@storybook/
|
|
103
|
-
"@storybook/
|
|
104
|
-
"@storybook/manager-
|
|
105
|
-
"@storybook/
|
|
106
|
-
"@storybook/
|
|
107
|
-
"@storybook/
|
|
105
|
+
"@storybook/addon-a11y": "^8.2.9",
|
|
106
|
+
"@storybook/addon-actions": "^8.2.9",
|
|
107
|
+
"@storybook/addon-docs": "^8.2.9",
|
|
108
|
+
"@storybook/addon-essentials": "^8.2.9",
|
|
109
|
+
"@storybook/addon-interactions": "^8.2.9",
|
|
110
|
+
"@storybook/addon-links": "^8.2.9",
|
|
111
|
+
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
|
|
112
|
+
"@storybook/manager-api": "^8.2.9",
|
|
113
|
+
"@storybook/preview-api": "^8.2.9",
|
|
114
|
+
"@storybook/react": "^8.2.9",
|
|
115
|
+
"@storybook/react-webpack5": "^8.2.9",
|
|
116
|
+
"@storybook/test": "^8.2.9",
|
|
117
|
+
"@storybook/theming": "^8.2.9",
|
|
118
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
119
|
+
"@testing-library/react": "^16.0.1",
|
|
120
|
+
"@types/jest": "^29.5.12",
|
|
108
121
|
"@types/node": "^18.11.18",
|
|
109
|
-
"@types/react": "
|
|
110
|
-
"@types/react-dom": "
|
|
122
|
+
"@types/react": "18.2.0",
|
|
123
|
+
"@types/react-dom": "18.2.0",
|
|
111
124
|
"@types/styled-components": "^5.1.26",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
125
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
113
126
|
"@typescript-eslint/parser": "^5.48.0",
|
|
127
|
+
"ajv": "^8.17.1",
|
|
114
128
|
"babel-loader": "^9.1.0",
|
|
115
129
|
"css-loader": "^6.7.3",
|
|
116
130
|
"eslint": "^7.32.0",
|
|
117
131
|
"eslint-config-airbnb": "^18.2.1",
|
|
118
132
|
"eslint-config-prettier": "^8.6.0",
|
|
133
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
|
134
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
|
119
135
|
"eslint-plugin-import": "^2.26.0",
|
|
120
136
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
137
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
121
138
|
"eslint-plugin-react": "^7.31.11",
|
|
139
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
122
140
|
"fantasticon": "^2.0.0",
|
|
123
141
|
"http-server": "^14.1.1",
|
|
142
|
+
"jest": "^29.7.0",
|
|
143
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
124
144
|
"lint-staged": "^13.1.0",
|
|
125
145
|
"mini-css-extract-plugin": "^2.7.2",
|
|
126
146
|
"parcel": "^2.8.2",
|
|
@@ -129,14 +149,15 @@
|
|
|
129
149
|
"path": "^0.12.7",
|
|
130
150
|
"pre-commit": "^1.2.2",
|
|
131
151
|
"prettier": "2.8.1",
|
|
132
|
-
"
|
|
133
|
-
"react
|
|
152
|
+
"raw-loader": "^4.0.2",
|
|
153
|
+
"react": "18.2.0",
|
|
154
|
+
"react-dom": "18.2.0",
|
|
134
155
|
"rimraf": "^3.0.2",
|
|
135
156
|
"sass": "^1.57.1",
|
|
136
157
|
"sass-loader": "^13.2.0",
|
|
137
158
|
"scss": "^0.2.4",
|
|
138
|
-
"storybook": "^
|
|
139
|
-
"storybook-addon-code-editor": "^
|
|
159
|
+
"storybook": "^8.2.9",
|
|
160
|
+
"storybook-addon-code-editor": "^3.1.0",
|
|
140
161
|
"style-loader": "^3.3.1",
|
|
141
162
|
"styled-components": "^5.3.6",
|
|
142
163
|
"svgo": "^3.0.2",
|
|
@@ -148,11 +169,15 @@
|
|
|
148
169
|
"prop-types": "^15.8.1"
|
|
149
170
|
},
|
|
150
171
|
"peerDependencies": {
|
|
151
|
-
"react": "
|
|
152
|
-
"react-dom": "
|
|
153
|
-
"styled-components": "
|
|
172
|
+
"react": "18.2.0",
|
|
173
|
+
"react-dom": "18.2.0",
|
|
174
|
+
"styled-components": "4.2.0"
|
|
154
175
|
},
|
|
155
176
|
"resolutions": {
|
|
156
177
|
"@storybook/react/webpack": "^5"
|
|
178
|
+
},
|
|
179
|
+
"optionalDependencies": {
|
|
180
|
+
"@parcel/watcher-linux-x64-glibc": "^2.4.2-alpha.0",
|
|
181
|
+
"@swc/core-linux-x64-gnu": "^1.7.24"
|
|
157
182
|
}
|
|
158
183
|
}
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
export type grauityColorName =
|
|
2
|
-
| 'white'
|
|
3
|
-
| 'black'
|
|
4
|
-
| 'grey'
|
|
5
|
-
| 'blue'
|
|
6
|
-
| 'red'
|
|
7
|
-
| 'green'
|
|
8
|
-
| 'orange'
|
|
9
|
-
| 'yellow'
|
|
10
|
-
| 'purple';
|
|
1
|
+
// export type grauityColorName = string;
|
|
11
2
|
|
|
12
|
-
export type grauityIconColorName =
|
|
13
|
-
| 'white'
|
|
14
|
-
| 'black'
|
|
15
|
-
| 'grey'
|
|
16
|
-
| 'blue'
|
|
17
|
-
| 'red'
|
|
18
|
-
| 'green'
|
|
19
|
-
| 'orange'
|
|
20
|
-
| 'yellow'
|
|
21
|
-
| 'purple';
|
|
3
|
+
// export type grauityIconColorName = string;
|
package/ui/core/colors/index.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export type { grauityColorName, grauityIconColorName } from './colorTypes';
|
|
1
|
+
// export type { grauityColorName, grauityIconColorName } from './colorTypes';
|
|
2
2
|
|
|
3
|
-
export enum GRAUITY_COLOR {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
3
|
+
// export enum GRAUITY_COLOR {
|
|
4
|
+
// WHITE = 'white',
|
|
5
|
+
// BLACK = 'black',
|
|
6
|
+
// GREY = 'grey',
|
|
7
|
+
// BLUE = 'blue',
|
|
8
|
+
// RED = 'red',
|
|
9
|
+
// GREEN = 'green',
|
|
10
|
+
// ORANGE = 'orange',
|
|
11
|
+
// YELLOW = 'yellow',
|
|
12
|
+
// PURPLE = 'purple',
|
|
13
|
+
// }
|
|
14
14
|
|
|
15
|
-
export const GRAUITY_ICON_COLORS = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
];
|
|
15
|
+
// export const GRAUITY_ICON_COLORS = [
|
|
16
|
+
// GRAUITY_COLOR.WHITE,
|
|
17
|
+
// GRAUITY_COLOR.BLACK,
|
|
18
|
+
// GRAUITY_COLOR.GREY,
|
|
19
|
+
// GRAUITY_COLOR.BLUE,
|
|
20
|
+
// GRAUITY_COLOR.RED,
|
|
21
|
+
// GRAUITY_COLOR.GREEN,
|
|
22
|
+
// GRAUITY_COLOR.ORANGE,
|
|
23
|
+
// GRAUITY_COLOR.YELLOW,
|
|
24
|
+
// GRAUITY_COLOR.PURPLE,
|
|
25
|
+
// ];
|
package/ui/core/icons/index.ts
CHANGED
package/ui/core/index.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
export type { grauityIconColorName, grauityColorName } from './colors';
|
|
5
|
-
export { GRAUITY_ICON_COLORS, GRAUITY_COLOR } from './colors';
|
|
6
|
-
|
|
7
|
-
export type { grauityIconName, grauityIconKey } from './icons';
|
|
1
|
+
// export type { grauityColorName, grauityIconColorName } from './colors';
|
|
2
|
+
// export { GRAUITY_COLOR, GRAUITY_ICON_COLORS } from './colors';
|
|
3
|
+
export type { grauityIconKey, grauityIconName } from './icons';
|
|
8
4
|
export { GRAUITY_ICONS, ICON_TAGS, TAG_ICONS } from './icons';
|
|
9
|
-
|
|
10
5
|
export type {
|
|
11
|
-
grauityRotatedChoiceName,
|
|
12
6
|
grauityFlippedChoiceName,
|
|
7
|
+
grauityRotatedChoiceName,
|
|
13
8
|
} from './miscellaneous-choices';
|
|
14
9
|
export {
|
|
15
|
-
GRAUITY_ICON_ROTATED_CHOICES,
|
|
16
10
|
GRAUITY_ICON_FLIPPED_CHOICES,
|
|
11
|
+
GRAUITY_ICON_ROTATED_CHOICES,
|
|
17
12
|
} from './miscellaneous-choices';
|
|
13
|
+
export type { grauityIconSizeName, grauitySizeName } from './sizes';
|
|
14
|
+
export { GRAUITY_ICON_SIZES, GRAUITY_SIZE } from './sizes';
|
package/ui/css/fonts.scss
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
@use "sass:math";
|
|
2
2
|
|
|
3
|
-
@font-face {
|
|
4
|
-
font-family: 'Switzer';
|
|
5
|
-
font-weight: 100 900;
|
|
6
|
-
src: url('fonts/Switzer-Variable.ttf') format("truetype-variations");
|
|
7
|
-
}
|
|
8
|
-
|
|
9
3
|
.grauity-init {
|
|
10
|
-
font-family: 'Switzer', sans-serif;
|
|
11
|
-
|
|
12
4
|
@for $i from 1 through 10 {
|
|
13
5
|
.font-size-#{4 * $i} {
|
|
14
6
|
font-size: calc(var(--multiplier) * #{math.div((4 * $i), 16)}em);
|
package/ui/css/index.scss
CHANGED
package/ui/css/reset.scss
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AlertBodyProps,
|
|
5
|
+
AlertContainerProps,
|
|
6
|
+
AlertDescriptionProps,
|
|
7
|
+
AlertTitleProps,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
export const StyledAlertContainer = styled.div<AlertContainerProps>`
|
|
11
|
+
display: flex;
|
|
12
|
+
width: 100%;
|
|
13
|
+
${({ maxWidth }) => maxWidth && `max-width: ${maxWidth};`}
|
|
14
|
+
min-height: var(--spacing-48px, 48px);
|
|
15
|
+
align-items: flex-start;
|
|
16
|
+
border-radius: var(--spacing-8px, 8px);
|
|
17
|
+
border: var(--spacing-1px, 1px) solid ${({ borderColor }) => borderColor};
|
|
18
|
+
background: ${({ backgroundColor }) => backgroundColor};
|
|
19
|
+
padding: var(--spacing-12px, 12px);
|
|
20
|
+
gap: var(--spacing-20px, 20px);
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const StyledAlertBody = styled.div<AlertBodyProps>`
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: flex-start;
|
|
28
|
+
gap: var(--spacing-4px, 4px);
|
|
29
|
+
margin-right: var(--spacing-4px, 4px);
|
|
30
|
+
flex: 1 0 0;
|
|
31
|
+
|
|
32
|
+
${({ inlineButtons }) =>
|
|
33
|
+
inlineButtons &&
|
|
34
|
+
css`
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
align-items: flex-start;
|
|
37
|
+
`};
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export const StyledAlertContent = styled.div`
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
align-items: flex-start;
|
|
45
|
+
gap: var(--spacing-4px, 4px);
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
export const StyledAlertTitle = styled.h2<AlertTitleProps>`
|
|
49
|
+
align-self: stretch;
|
|
50
|
+
color: ${({ textColor }) => textColor};
|
|
51
|
+
font-size: var(--font-size-14px, 14px);
|
|
52
|
+
font-weight: var(--font-weight-semibold, 600);
|
|
53
|
+
line-height: 160%;
|
|
54
|
+
letter-spacing: 0.014px;
|
|
55
|
+
margin: 0;
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
export const StyledAlertDescription = styled.div<AlertDescriptionProps>`
|
|
59
|
+
align-self: stretch;
|
|
60
|
+
color: ${({ textColor }) => textColor};
|
|
61
|
+
font-size: var(--font-size-14px, 14px);
|
|
62
|
+
font-weight: var(--font-weight-medium, 500);
|
|
63
|
+
line-height: 160%;
|
|
64
|
+
letter-spacing: 0.1px;
|
|
65
|
+
margin-bottom: var(--spacing-4px, 4px);
|
|
66
|
+
`;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import { ButtonProps } from '../Button';
|
|
7
|
+
import Alert from './Alert';
|
|
8
|
+
import { AlertProps } from './types';
|
|
9
|
+
|
|
10
|
+
describe('Alert', () => {
|
|
11
|
+
const defaultProps: AlertProps = {
|
|
12
|
+
type: 'default',
|
|
13
|
+
variant: 'primary',
|
|
14
|
+
title: 'This is an alert',
|
|
15
|
+
description: 'This is a description',
|
|
16
|
+
showCloseButton: true,
|
|
17
|
+
onClose: jest.fn(),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
it('renders the alert title and description', () => {
|
|
21
|
+
render(<Alert {...defaultProps} />);
|
|
22
|
+
expect(screen.getByText('This is an alert')).toBeInTheDocument();
|
|
23
|
+
expect(screen.getByText('This is a description')).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('renders the alert close button', () => {
|
|
27
|
+
render(<Alert {...defaultProps} />);
|
|
28
|
+
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('calls onClose when close button is clicked', () => {
|
|
32
|
+
render(<Alert {...defaultProps} />);
|
|
33
|
+
fireEvent.click(screen.getByRole('button'));
|
|
34
|
+
expect(defaultProps.onClose).toHaveBeenCalledTimes(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders with different types and variants', () => {
|
|
38
|
+
render(<Alert {...defaultProps} type="outlined" variant="success" />);
|
|
39
|
+
expect(screen.getByText('This is an alert')).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders with a custom icon', () => {
|
|
43
|
+
render(<Alert {...defaultProps} icon="bell" />);
|
|
44
|
+
const customIcon = screen.queryAllByTestId('testid-icon');
|
|
45
|
+
const targetIcon = customIcon.filter(
|
|
46
|
+
(icon) => icon.classList.contains('grauity-icon-bell')
|
|
47
|
+
);
|
|
48
|
+
expect(targetIcon.length).toBe(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('renders without icon when stated explicitly', () => {
|
|
52
|
+
render(<Alert {...defaultProps} icon={null} />);
|
|
53
|
+
const icons = screen.queryAllByTestId('testid-icon');
|
|
54
|
+
const nonCloseIcons = icons.filter(
|
|
55
|
+
(icon) => !icon.classList.contains('grauity-icon-close')
|
|
56
|
+
);
|
|
57
|
+
expect(nonCloseIcons.length).toBe(0);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders action buttons', () => {
|
|
61
|
+
const actionButtons: ButtonProps[] = [
|
|
62
|
+
{ children: 'Button 1', variant: 'primary', size: 'small' },
|
|
63
|
+
];
|
|
64
|
+
render(<Alert {...defaultProps} actionButtons={actionButtons} />);
|
|
65
|
+
expect(screen.getByText('Button 1')).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('calls action button onClick', () => {
|
|
69
|
+
const actionButtons: ButtonProps[] = [
|
|
70
|
+
{
|
|
71
|
+
children: 'Button 1',
|
|
72
|
+
variant: 'primary',
|
|
73
|
+
size: 'small',
|
|
74
|
+
onClick: jest.fn(),
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
render(<Alert {...defaultProps} actionButtons={actionButtons} />);
|
|
78
|
+
fireEvent.click(screen.getByText('Button 1'));
|
|
79
|
+
expect(actionButtons[0].onClick).toHaveBeenCalledTimes(1);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { forwardRef, useId } from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
getAlertBannerColors,
|
|
6
|
+
getAlertIconName,
|
|
7
|
+
getButtonVariantFromAlertBannerTypeVariant,
|
|
8
|
+
} from '../AlertBanner/utils';
|
|
9
|
+
import Button from '../Button';
|
|
10
|
+
import ButtonGroup from '../Button/ButtonGroup';
|
|
11
|
+
import IconButton from '../Button/IconButton';
|
|
12
|
+
import { Icon } from '../Icon';
|
|
13
|
+
import {
|
|
14
|
+
StyledAlertBody,
|
|
15
|
+
StyledAlertContainer,
|
|
16
|
+
StyledAlertContent,
|
|
17
|
+
StyledAlertDescription,
|
|
18
|
+
StyledAlertTitle,
|
|
19
|
+
} from './Alert.styles';
|
|
20
|
+
import { ALERT_TYPES, ALERT_VARIANTS } from './constants';
|
|
21
|
+
import { AlertProps } from './types';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An alert component is used to display important messages to the user.
|
|
25
|
+
*/
|
|
26
|
+
const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
27
|
+
const {
|
|
28
|
+
type,
|
|
29
|
+
variant,
|
|
30
|
+
icon,
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
top,
|
|
34
|
+
bottom,
|
|
35
|
+
left,
|
|
36
|
+
right,
|
|
37
|
+
position,
|
|
38
|
+
onClose,
|
|
39
|
+
showCloseButton,
|
|
40
|
+
actionButtons,
|
|
41
|
+
maxWidth,
|
|
42
|
+
inlineButtons,
|
|
43
|
+
} = props;
|
|
44
|
+
const id = useId();
|
|
45
|
+
const iconName = getAlertIconName(icon, variant);
|
|
46
|
+
const { iconColor, textColor, backgroundColor, borderColor } =
|
|
47
|
+
getAlertBannerColors(variant, type);
|
|
48
|
+
|
|
49
|
+
const hasButton = !!actionButtons?.length || showCloseButton;
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<StyledAlertContainer
|
|
53
|
+
position={position}
|
|
54
|
+
top={top}
|
|
55
|
+
bottom={bottom}
|
|
56
|
+
left={left}
|
|
57
|
+
right={right}
|
|
58
|
+
backgroundColor={backgroundColor}
|
|
59
|
+
borderColor={borderColor}
|
|
60
|
+
ref={ref}
|
|
61
|
+
role="alert"
|
|
62
|
+
aria-labelledby={`alert-title-${id}`}
|
|
63
|
+
aria-describedby={`alert-description-${id}`}
|
|
64
|
+
maxWidth={maxWidth}
|
|
65
|
+
>
|
|
66
|
+
{iconName && (
|
|
67
|
+
<Icon
|
|
68
|
+
name={iconName}
|
|
69
|
+
color={iconColor || 'inherit'}
|
|
70
|
+
size="20"
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
<StyledAlertBody inlineButtons={inlineButtons}>
|
|
74
|
+
<StyledAlertContent>
|
|
75
|
+
{title && (
|
|
76
|
+
<StyledAlertTitle
|
|
77
|
+
textColor={textColor}
|
|
78
|
+
id={`alert-title-${id}`}
|
|
79
|
+
>
|
|
80
|
+
{title}
|
|
81
|
+
</StyledAlertTitle>
|
|
82
|
+
)}
|
|
83
|
+
{description && (
|
|
84
|
+
<StyledAlertDescription
|
|
85
|
+
textColor={textColor}
|
|
86
|
+
id={`alert-description-${id}`}
|
|
87
|
+
>
|
|
88
|
+
{description}
|
|
89
|
+
</StyledAlertDescription>
|
|
90
|
+
)}
|
|
91
|
+
</StyledAlertContent>
|
|
92
|
+
{hasButton && (
|
|
93
|
+
<ButtonGroup>
|
|
94
|
+
{actionButtons?.map((button) => (
|
|
95
|
+
<Button {...button} key={button.variant}>
|
|
96
|
+
{button.children}
|
|
97
|
+
</Button>
|
|
98
|
+
))}
|
|
99
|
+
</ButtonGroup>
|
|
100
|
+
)}
|
|
101
|
+
</StyledAlertBody>
|
|
102
|
+
{showCloseButton && (
|
|
103
|
+
<IconButton
|
|
104
|
+
icon="close"
|
|
105
|
+
variant={getButtonVariantFromAlertBannerTypeVariant(
|
|
106
|
+
variant,
|
|
107
|
+
type
|
|
108
|
+
)}
|
|
109
|
+
onClick={onClose}
|
|
110
|
+
size="small"
|
|
111
|
+
/>
|
|
112
|
+
)}
|
|
113
|
+
</StyledAlertContainer>
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
Alert.defaultProps = {
|
|
118
|
+
type: 'default',
|
|
119
|
+
variant: 'primary',
|
|
120
|
+
icon: null,
|
|
121
|
+
title: 'This is an alert',
|
|
122
|
+
description: 'This is a description',
|
|
123
|
+
top: null,
|
|
124
|
+
bottom: null,
|
|
125
|
+
left: null,
|
|
126
|
+
right: null,
|
|
127
|
+
position: 'static',
|
|
128
|
+
onClose: undefined,
|
|
129
|
+
showCloseButton: false,
|
|
130
|
+
actionButtons: [],
|
|
131
|
+
inlineButtons: false,
|
|
132
|
+
maxWidth: '440px',
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
Alert.propTypes = {
|
|
136
|
+
type: PropTypes.oneOf(ALERT_TYPES),
|
|
137
|
+
variant: PropTypes.oneOf(ALERT_VARIANTS),
|
|
138
|
+
icon: PropTypes.any,
|
|
139
|
+
title: PropTypes.string,
|
|
140
|
+
description: PropTypes.string,
|
|
141
|
+
top: PropTypes.string,
|
|
142
|
+
bottom: PropTypes.string,
|
|
143
|
+
left: PropTypes.string,
|
|
144
|
+
right: PropTypes.string,
|
|
145
|
+
position: PropTypes.oneOf(['static', 'fixed', 'absolute', 'relative']),
|
|
146
|
+
onClose: PropTypes.func,
|
|
147
|
+
showCloseButton: PropTypes.bool,
|
|
148
|
+
actionButtons: PropTypes.array,
|
|
149
|
+
inlineButtons: PropTypes.bool,
|
|
150
|
+
maxWidth: PropTypes.string,
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default Alert;
|