@newtonschool/grauity 0.1.11 → 1.0.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.
Files changed (159) hide show
  1. package/dist/index.d.ts +227 -227
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/main.cjs +1 -1
  4. package/dist/main.cjs.map +1 -1
  5. package/dist/module.mjs +1 -1
  6. package/dist/module.mjs.map +1 -1
  7. package/dist/stories/elements/Modal/ConfirmationDialog.stories.d.ts +1 -35
  8. package/dist/stories/elements/Modal/ConfirmationDialog.stories.d.ts.map +1 -1
  9. package/dist/stories/elements/Modal/ConfirmationDialogWithTrigger.stories.d.ts +2 -35
  10. package/dist/stories/elements/Modal/ConfirmationDialogWithTrigger.stories.d.ts.map +1 -1
  11. package/dist/stories/elements/Modal/MultiStepModal.stories.d.ts +0 -32
  12. package/dist/stories/elements/Modal/MultiStepModal.stories.d.ts.map +1 -1
  13. package/dist/stories/elements/Table/Manual.stories.d.ts +1 -31
  14. package/dist/stories/elements/Table/Manual.stories.d.ts.map +1 -1
  15. package/dist/stories/elements/Table/ManualColumnNesting.stories.d.ts +1 -31
  16. package/dist/stories/elements/Table/ManualColumnNesting.stories.d.ts.map +1 -1
  17. package/dist/stories/elements/Table/index.stories.d.ts +1 -31
  18. package/dist/stories/elements/Table/index.stories.d.ts.map +1 -1
  19. package/dist/stories/elements/Typography/TypographyGallery.stories.d.ts +1 -21
  20. package/dist/stories/elements/Typography/TypographyGallery.stories.d.ts.map +1 -1
  21. package/dist/stories/elements/Typography/index.stories.d.ts +1 -21
  22. package/dist/stories/elements/Typography/index.stories.d.ts.map +1 -1
  23. package/dist/stories/helper-components/ColorRenderer/index.d.ts +2 -11
  24. package/dist/stories/helper-components/ColorRenderer/index.d.ts.map +1 -1
  25. package/dist/stories/helper-components/DocPageWithPlayground.d.ts +3 -8
  26. package/dist/stories/helper-components/DocPageWithPlayground.d.ts.map +1 -1
  27. package/dist/stories/helper-components/TokenBlock/index.d.ts +2 -14
  28. package/dist/stories/helper-components/TokenBlock/index.d.ts.map +1 -1
  29. package/dist/ui/elements/Alert/Alert.d.ts.map +1 -1
  30. package/dist/ui/elements/Alert/types.d.ts +1 -1
  31. package/dist/ui/elements/Alert/types.d.ts.map +1 -1
  32. package/dist/ui/elements/AlertBanner/AlertBanner.d.ts.map +1 -1
  33. package/dist/ui/elements/Button/Button.d.ts.map +1 -1
  34. package/dist/ui/elements/Button/Button.styles.d.ts.map +1 -1
  35. package/dist/ui/elements/Button/ButtonGroup.d.ts +1 -8
  36. package/dist/ui/elements/Button/ButtonGroup.d.ts.map +1 -1
  37. package/dist/ui/elements/Button/IconButton.d.ts.map +1 -1
  38. package/dist/ui/elements/Button/constants.d.ts +14 -20
  39. package/dist/ui/elements/Button/constants.d.ts.map +1 -1
  40. package/dist/ui/elements/Button/types.d.ts +1 -0
  41. package/dist/ui/elements/Button/types.d.ts.map +1 -1
  42. package/dist/ui/elements/Icon/Icon.d.ts +0 -40
  43. package/dist/ui/elements/Icon/Icon.d.ts.map +1 -1
  44. package/dist/ui/elements/Modal/ConfirmationDialog/index.d.ts +1 -36
  45. package/dist/ui/elements/Modal/ConfirmationDialog/index.d.ts.map +1 -1
  46. package/dist/ui/elements/Modal/Modal.d.ts.map +1 -1
  47. package/dist/ui/elements/Modal/MultiStepModal/index.d.ts +0 -33
  48. package/dist/ui/elements/Modal/MultiStepModal/index.d.ts.map +1 -1
  49. package/dist/ui/elements/Table/Table.d.ts +1 -32
  50. package/dist/ui/elements/Table/Table.d.ts.map +1 -1
  51. package/dist/ui/elements/Typography/Typography.d.ts +1 -22
  52. package/dist/ui/elements/Typography/Typography.d.ts.map +1 -1
  53. package/dist/ui/elements/Typography/types.d.ts +1 -1
  54. package/dist/ui/index.d.ts +5 -3
  55. package/dist/ui/index.d.ts.map +1 -1
  56. package/dist/ui/init/GrauityInit.d.ts +2 -21
  57. package/dist/ui/init/GrauityInit.d.ts.map +1 -1
  58. package/dist/ui/themes/ThemeContext.d.ts +1 -13
  59. package/dist/ui/themes/ThemeContext.d.ts.map +1 -1
  60. package/package.json +2 -4
  61. package/ui/.gitkeep +0 -0
  62. package/ui/README.md +0 -3
  63. package/ui/core/README.md +0 -4
  64. package/ui/core/colors/colorTypes.ts +0 -3
  65. package/ui/core/colors/index.ts +0 -25
  66. package/ui/core/icons/iconTags.ts +0 -1600
  67. package/ui/core/icons/iconTypes.ts +0 -1188
  68. package/ui/core/icons/index.ts +0 -3
  69. package/ui/core/index.ts +0 -14
  70. package/ui/core/miscellaneous-choices/index.ts +0 -24
  71. package/ui/core/miscellaneous-choices/miscellaneousTypes.ts +0 -3
  72. package/ui/core/sizes/index.ts +0 -29
  73. package/ui/core/sizes/sizeTypes.ts +0 -26
  74. package/ui/css/animations.scss +0 -8
  75. package/ui/css/fonts.scss +0 -9
  76. package/ui/css/index.scss +0 -3
  77. package/ui/css/reset.scss +0 -512
  78. package/ui/elements/Alert/Alert.styles.ts +0 -66
  79. package/ui/elements/Alert/Alert.test.tsx +0 -81
  80. package/ui/elements/Alert/Alert.tsx +0 -153
  81. package/ui/elements/Alert/constants.ts +0 -169
  82. package/ui/elements/Alert/index.ts +0 -6
  83. package/ui/elements/Alert/types.ts +0 -150
  84. package/ui/elements/Alert/utils.ts +0 -0
  85. package/ui/elements/AlertBanner/AlertBanner.styles.ts +0 -35
  86. package/ui/elements/AlertBanner/AlertBanner.test.tsx +0 -70
  87. package/ui/elements/AlertBanner/AlertBanner.tsx +0 -137
  88. package/ui/elements/AlertBanner/constants.ts +0 -179
  89. package/ui/elements/AlertBanner/index.ts +0 -6
  90. package/ui/elements/AlertBanner/types.ts +0 -133
  91. package/ui/elements/AlertBanner/utils.ts +0 -52
  92. package/ui/elements/Button/Button.styles.ts +0 -88
  93. package/ui/elements/Button/Button.test.tsx +0 -78
  94. package/ui/elements/Button/Button.tsx +0 -134
  95. package/ui/elements/Button/ButtonGroup.styles.ts +0 -7
  96. package/ui/elements/Button/ButtonGroup.tsx +0 -21
  97. package/ui/elements/Button/IconButton.test.tsx +0 -39
  98. package/ui/elements/Button/IconButton.tsx +0 -118
  99. package/ui/elements/Button/constants.ts +0 -304
  100. package/ui/elements/Button/index.ts +0 -8
  101. package/ui/elements/Button/types.ts +0 -282
  102. package/ui/elements/Button/utils.ts +0 -0
  103. package/ui/elements/Icon/Icon.styles.ts +0 -99
  104. package/ui/elements/Icon/Icon.tsx +0 -139
  105. package/ui/elements/Icon/index.ts +0 -2
  106. package/ui/elements/Icon/types.ts +0 -96
  107. package/ui/elements/Modal/ConfirmationDialog/index.test.tsx +0 -116
  108. package/ui/elements/Modal/ConfirmationDialog/index.tsx +0 -151
  109. package/ui/elements/Modal/Modal.styles.ts +0 -230
  110. package/ui/elements/Modal/Modal.test.tsx +0 -117
  111. package/ui/elements/Modal/Modal.tsx +0 -179
  112. package/ui/elements/Modal/MultiStepModal/index.test.tsx +0 -116
  113. package/ui/elements/Modal/MultiStepModal/index.tsx +0 -184
  114. package/ui/elements/Modal/constants.ts +0 -0
  115. package/ui/elements/Modal/index.ts +0 -4
  116. package/ui/elements/Modal/types.ts +0 -379
  117. package/ui/elements/Modal/utils.tsx +0 -0
  118. package/ui/elements/MultiSelectDropdown/DropdownListItem.tsx +0 -33
  119. package/ui/elements/MultiSelectDropdown/MultiSelectDropdown.styles.ts +0 -127
  120. package/ui/elements/MultiSelectDropdown/MultiSelectDropdown.test.tsx +0 -224
  121. package/ui/elements/MultiSelectDropdown/MultiSelectDropdown.tsx +0 -156
  122. package/ui/elements/MultiSelectDropdown/index.ts +0 -2
  123. package/ui/elements/MultiSelectDropdown/types.ts +0 -87
  124. package/ui/elements/SelectDropdown/SelectDropdown.styles.ts +0 -99
  125. package/ui/elements/SelectDropdown/SelectDropdown.test.tsx +0 -86
  126. package/ui/elements/SelectDropdown/SelectDropdown.tsx +0 -94
  127. package/ui/elements/SelectDropdown/index.tsx +0 -2
  128. package/ui/elements/SelectDropdown/types.ts +0 -73
  129. package/ui/elements/Table/Table.styles.ts +0 -178
  130. package/ui/elements/Table/Table.test.tsx +0 -72
  131. package/ui/elements/Table/Table.tsx +0 -118
  132. package/ui/elements/Table/constants.ts +0 -0
  133. package/ui/elements/Table/index.ts +0 -2
  134. package/ui/elements/Table/types.ts +0 -270
  135. package/ui/elements/Table/utils.ts +0 -0
  136. package/ui/elements/Typography/Typography.styles.ts +0 -29
  137. package/ui/elements/Typography/Typography.tsx +0 -70
  138. package/ui/elements/Typography/constants.ts +0 -292
  139. package/ui/elements/Typography/index.ts +0 -9
  140. package/ui/elements/Typography/types.ts +0 -116
  141. package/ui/elements/Typography/utils.ts +0 -11
  142. package/ui/fonts/Switzer-Variable.ttf +0 -0
  143. package/ui/fonts/grauity-icons.eot +0 -0
  144. package/ui/fonts/grauity-icons.ttf +0 -0
  145. package/ui/fonts/grauity-icons.woff +0 -0
  146. package/ui/fonts/grauity-icons.woff2 +0 -0
  147. package/ui/helpers/README.md +0 -3
  148. package/ui/helpers/classNameBuilders.ts +0 -48
  149. package/ui/helpers/index.ts +0 -7
  150. package/ui/index.ts +0 -48
  151. package/ui/init/GrauityInit.tsx +0 -85
  152. package/ui/init/index.ts +0 -2
  153. package/ui/themes/GlobalStyle.ts +0 -273
  154. package/ui/themes/ThemeContext.tsx +0 -140
  155. package/ui/themes/constants.ts +0 -8
  156. package/ui/themes/darkThemeConstants.ts +0 -73
  157. package/ui/themes/lightThemeConstants.ts +0 -73
  158. package/ui/themes/tokens.ts +0 -0
  159. package/ui/themes/types.ts +0 -77
@@ -1,81 +0,0 @@
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
- });
@@ -1,153 +0,0 @@
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;
@@ -1,169 +0,0 @@
1
- import { grauityIconName } from '../../core';
2
- import { BUTTON_VARIANTS_ENUM } from '../Button';
3
-
4
- export enum ALERT_TYPES_ENUM {
5
- DEFAULT = 'default', // Colorless background, colored icon & text
6
- OUTLINED = 'outlined', // Light colored background with outline, colored icon & text
7
- FILLED = 'filled', // Colored background, white icon & text
8
- }
9
-
10
- export enum ALERT_VARIANTS_ENUM {
11
- PRIMARY = 'primary',
12
- SUCCESS = 'success',
13
- WARNING = 'warning',
14
- ERROR = 'error',
15
- DEFAULT = 'default',
16
- }
17
-
18
- export const ERRONEOUS_ALERT_VARIANTS = [
19
- ALERT_VARIANTS_ENUM.WARNING,
20
- ALERT_VARIANTS_ENUM.ERROR,
21
- ];
22
-
23
- export const ALERT_VARIANTS = [
24
- ALERT_VARIANTS_ENUM.PRIMARY,
25
- ALERT_VARIANTS_ENUM.SUCCESS,
26
- ALERT_VARIANTS_ENUM.WARNING,
27
- ALERT_VARIANTS_ENUM.ERROR,
28
- ALERT_VARIANTS_ENUM.DEFAULT,
29
- ];
30
-
31
- export const ALERT_TYPES = [
32
- ALERT_TYPES_ENUM.DEFAULT,
33
- ALERT_TYPES_ENUM.OUTLINED,
34
- ALERT_TYPES_ENUM.FILLED,
35
- ];
36
-
37
- export const DEFAULT_ALERT_VARIANT_ICON_MAPPING: Record<
38
- ALERT_VARIANTS_ENUM,
39
- grauityIconName
40
- > = {
41
- [ALERT_VARIANTS_ENUM.PRIMARY]: 'info-circle',
42
- [ALERT_VARIANTS_ENUM.SUCCESS]: 'check-circle',
43
- [ALERT_VARIANTS_ENUM.WARNING]: 'exclamation-triangle',
44
- [ALERT_VARIANTS_ENUM.ERROR]: 'exclamation-circle',
45
- [ALERT_VARIANTS_ENUM.DEFAULT]: 'info-circle',
46
- };
47
-
48
- export const ALERT_COLOR_MAPPINGS = {
49
- [ALERT_TYPES_ENUM.DEFAULT]: {
50
- [ALERT_VARIANTS_ENUM.PRIMARY]: {
51
- iconColor: 'var(--text-brand, #0673F9)',
52
- textColor: 'var(--text-primary, #16191D)',
53
- backgroundColor: 'var(--bg-primary, #FFF)',
54
- borderColor: 'var(--border, #E1E5EA)',
55
- },
56
- [ALERT_VARIANTS_ENUM.SUCCESS]: {
57
- iconColor: 'var(--text-success, #007A51)',
58
- textColor: 'var(--text-primary, #16191D)',
59
- backgroundColor: 'var(--bg-primary, #FFF)',
60
- borderColor: 'var(--border, #E1E5EA)',
61
- },
62
- [ALERT_VARIANTS_ENUM.WARNING]: {
63
- iconColor: 'var(--text-warning, #DE5A02)',
64
- textColor: 'var(--text-primary, #16191D)',
65
- backgroundColor: 'var(--bg-primary, #FFF)',
66
- borderColor: 'var(--border, #E1E5EA)',
67
- },
68
- [ALERT_VARIANTS_ENUM.ERROR]: {
69
- iconColor: 'var(--text-error, #D22D3A)',
70
- textColor: 'var(--text-primary, #16191D)',
71
- backgroundColor: 'var(--bg-primary, #FFF)',
72
- borderColor: 'var(--border, #E1E5EA)',
73
- },
74
- [ALERT_VARIANTS_ENUM.DEFAULT]: {
75
- iconColor: 'var(--text-primary, #16191D)',
76
- textColor: 'var(--text-primary, #16191D)',
77
- backgroundColor: 'var(--bg-primary, #FFF)',
78
- borderColor: 'var(--border, #E1E5EA)',
79
- },
80
- },
81
- [ALERT_TYPES_ENUM.OUTLINED]: {
82
- [ALERT_VARIANTS_ENUM.PRIMARY]: {
83
- iconColor: 'var(--text-brand, #0673F9)',
84
- textColor: 'var(--text-brand, #0673F9)',
85
- backgroundColor: 'var(--bg-brand, #E5F1FF)',
86
- borderColor: 'var(--border-brand, #94C4FF)',
87
- },
88
- [ALERT_VARIANTS_ENUM.SUCCESS]: {
89
- iconColor: 'var(--text-success, #007A51)',
90
- textColor: 'var(--text-success, #007A51)',
91
- backgroundColor: 'var(--bg-success, #D9FCED)',
92
- borderColor: 'var(--border-success, #ACF7D3)',
93
- },
94
- [ALERT_VARIANTS_ENUM.WARNING]: {
95
- iconColor: 'var(--text-warning, #DE5A02)',
96
- textColor: 'var(--text-warning, #DE5A02)',
97
- backgroundColor: 'var(--bg-warning, #FFF1E5)',
98
- borderColor: 'var(--border-warning, #FFD2BA)',
99
- },
100
- [ALERT_VARIANTS_ENUM.ERROR]: {
101
- iconColor: 'var(--text-error, #D22D3A)',
102
- textColor: 'var(--text-error, #D22D3A)',
103
- backgroundColor: 'var(--bg-error, #FFE5E7)',
104
- borderColor: 'var(--border-error, #FBBBBF)',
105
- },
106
- [ALERT_VARIANTS_ENUM.DEFAULT]: {
107
- iconColor: 'var(--text-primary, #16191D)',
108
- textColor: 'var(--text-primary, #16191D)',
109
- backgroundColor: 'var(--bg-secondary, #F6F7F9)',
110
- borderColor: 'var(--border, #E1E5EA)',
111
- },
112
- },
113
- [ALERT_TYPES_ENUM.FILLED]: {
114
- [ALERT_VARIANTS_ENUM.PRIMARY]: {
115
- iconColor: 'var(--text-action, #FFF)',
116
- textColor: 'var(--text-action, #FFF)',
117
- backgroundColor: 'var(--bg-action-brand, #0673F9)',
118
- borderColor: 'transparent',
119
- },
120
- [ALERT_VARIANTS_ENUM.SUCCESS]: {
121
- iconColor: 'var(--text-action, #FFF)',
122
- textColor: 'var(--text-action, #FFF)',
123
- backgroundColor: 'var(--bg-action-success, #007A51)',
124
- borderColor: 'transparent',
125
- },
126
- [ALERT_VARIANTS_ENUM.WARNING]: {
127
- iconColor: 'var(--text-action, #FFF)',
128
- textColor: 'var(--text-action, #FFF)',
129
- backgroundColor: 'var(--bg-action-warning, #DE5A02)',
130
- borderColor: 'transparent',
131
- },
132
- [ALERT_VARIANTS_ENUM.ERROR]: {
133
- iconColor: 'var(--text-action, #FFF)',
134
- textColor: 'var(--text-action, #FFF)',
135
- backgroundColor: 'var(--bg-action-error, #D22D3A)',
136
- borderColor: 'transparent',
137
- },
138
- [ALERT_VARIANTS_ENUM.DEFAULT]: {
139
- iconColor: 'var(--text-action, #FFF)',
140
- textColor: 'var(--text-action, #FFF)',
141
- backgroundColor: 'var(--bg-action, #16191D)',
142
- borderColor: 'transparent',
143
- },
144
- },
145
- };
146
-
147
- export const ALERT_TYPE_AND_VARIANT_TO_BUTTON_VARIANT_MAPPING = {
148
- [ALERT_TYPES_ENUM.DEFAULT]: {
149
- [ALERT_VARIANTS_ENUM.PRIMARY]: BUTTON_VARIANTS_ENUM.TERTIARY_OUTLINED,
150
- [ALERT_VARIANTS_ENUM.SUCCESS]: BUTTON_VARIANTS_ENUM.TERTIARY_OUTLINED,
151
- [ALERT_VARIANTS_ENUM.WARNING]: BUTTON_VARIANTS_ENUM.TERTIARY_OUTLINED,
152
- [ALERT_VARIANTS_ENUM.ERROR]: BUTTON_VARIANTS_ENUM.TERTIARY_OUTLINED,
153
- [ALERT_VARIANTS_ENUM.DEFAULT]: BUTTON_VARIANTS_ENUM.TERTIARY_OUTLINED,
154
- },
155
- [ALERT_TYPES_ENUM.OUTLINED]: {
156
- [ALERT_VARIANTS_ENUM.PRIMARY]: BUTTON_VARIANTS_ENUM.PRIMARY_OUTLINED,
157
- [ALERT_VARIANTS_ENUM.SUCCESS]: BUTTON_VARIANTS_ENUM.SUCCESS_OUTLINED,
158
- [ALERT_VARIANTS_ENUM.WARNING]: BUTTON_VARIANTS_ENUM.WARNING_OUTLINED,
159
- [ALERT_VARIANTS_ENUM.ERROR]: BUTTON_VARIANTS_ENUM.DANGER_OUTLINED,
160
- [ALERT_VARIANTS_ENUM.DEFAULT]: BUTTON_VARIANTS_ENUM.TERTIARY_OUTLINED,
161
- },
162
- [ALERT_TYPES_ENUM.FILLED]: {
163
- [ALERT_VARIANTS_ENUM.PRIMARY]: BUTTON_VARIANTS_ENUM.PRIMARY,
164
- [ALERT_VARIANTS_ENUM.SUCCESS]: BUTTON_VARIANTS_ENUM.SUCCESS,
165
- [ALERT_VARIANTS_ENUM.WARNING]: BUTTON_VARIANTS_ENUM.WARNING,
166
- [ALERT_VARIANTS_ENUM.ERROR]: BUTTON_VARIANTS_ENUM.DANGER,
167
- [ALERT_VARIANTS_ENUM.DEFAULT]: BUTTON_VARIANTS_ENUM.SECONDARY,
168
- },
169
- };
@@ -1,6 +0,0 @@
1
- export { default } from './Alert';
2
- export { ALERT_VARIANTS_ENUM } from './constants';
3
- export { ALERT_VARIANTS } from './constants';
4
- export { ALERT_TYPES_ENUM } from './constants';
5
- export { ALERT_TYPES } from './constants';
6
- export type { AlertProps } from './types';
@@ -1,150 +0,0 @@
1
- import React from 'react';
2
-
3
- import { grauityIconName } from '../../core';
4
- import { ButtonProps } from '../Button';
5
-
6
- export type AlertType = 'default' | 'outlined' | 'filled';
7
-
8
- export type AlertVariant =
9
- | 'primary'
10
- | 'success'
11
- | 'warning'
12
- | 'error'
13
- | 'default';
14
-
15
- export interface AlertProps {
16
- /**
17
- * Type of the alert
18
- *
19
- * Available choices: `'default'`, `'outlined'`, `'filled'`
20
- *
21
- * Default: `'default'`
22
- * */
23
- type?: AlertType;
24
-
25
- /**
26
- * Variant of the alert
27
- *
28
- * Available choices: `'primary'`, `'secondary'`, `'tertiary'`, `'success'`, `'danger'`, `'warning'`
29
- *
30
- * Default: `'primary'`
31
- * */
32
- variant?: AlertVariant;
33
-
34
- /**
35
- * Alert icon, used to override the default icons used in the alert
36
- *
37
- * Use value `auto` to automatically select the icon based on the variant (error vs checkmark icon)
38
- *
39
- * Default: `null`
40
- * */
41
- icon?: grauityIconName | 'auto';
42
-
43
- /**
44
- * Alert title
45
- * */
46
- title?: React.ReactNode;
47
-
48
- /**
49
- * Alert description
50
- * */
51
- description?: React.ReactNode;
52
- /**
53
- * Alert top position, useful for fixed positioning
54
- *
55
- * Default: `null`
56
- * */
57
- top?: string;
58
-
59
- /**
60
- * Alert bottom position, useful for fixed positioning
61
- *
62
- * Default: `null`
63
- * */
64
- bottom?: string;
65
-
66
- /**
67
- * Alert left position, useful for fixed positioning
68
- *
69
- * Default: `null`
70
- * */
71
- left?: string;
72
-
73
- /**
74
- * Alert right position, useful for fixed positioning
75
- *
76
- * Default: `null`
77
- * */
78
- right?: string;
79
-
80
- /**
81
- * Alert position, useful for fixed positioning
82
- *
83
- * Default: `'static'`
84
- * */
85
- position?: 'static' | 'fixed' | 'absolute' | 'relative';
86
-
87
- /**
88
- * Alert close button click handler
89
- * */
90
- onClose?: () => void;
91
-
92
- /**
93
- * Show close button
94
- *
95
- * Default: `false`
96
- * */
97
- showCloseButton?: boolean;
98
-
99
- /**
100
- * Alert action buttons.
101
- *
102
- * Type: ButtonProps[]
103
- * */
104
- actionButtons?: ButtonProps[];
105
-
106
- /**
107
- * Show action buttons inline
108
- *
109
- * Default: `false`
110
- * */
111
- inlineButtons?: boolean;
112
-
113
- /**
114
- * Maximum width of the alert
115
- *
116
- * Default: `'440px'`
117
- * */
118
- maxWidth?: string;
119
- }
120
-
121
- export interface AlertContainerProps {
122
- position: string;
123
- top: string;
124
- bottom: string;
125
- left: string;
126
- right: string;
127
- backgroundColor: string;
128
- borderColor: string;
129
- ref: React.Ref<HTMLDivElement>;
130
- role: string;
131
- children: React.ReactNode;
132
- maxWidth: string;
133
- }
134
-
135
- export interface AlertBodyProps {
136
- inlineButtons: boolean;
137
- children: React.ReactNode;
138
- }
139
-
140
- export interface AlertTitleProps {
141
- textColor: string;
142
- children: React.ReactNode;
143
- id: string;
144
- }
145
-
146
- export interface AlertDescriptionProps {
147
- textColor: string;
148
- children: React.ReactNode;
149
- id?: string;
150
- }
File without changes
@@ -1,35 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- import { AlertBannerContainerProps } from './types';
4
-
5
- export const StyledAlertBannerContainer = styled.div<AlertBannerContainerProps>`
6
- display: flex;
7
- gap: var(--spacing-12px, 12px);
8
- width: 100%;
9
- min-height: var(--spacing-40px, 40px);
10
- align-items: center;
11
- flex-shrink: 0;
12
-
13
- position: ${({ position }) => position};
14
- top: ${({ top }) => top};
15
- bottom: ${({ bottom }) => bottom};
16
- left: ${({ left }) => left};
17
- right: ${({ right }) => right};
18
- padding: ${({ padding }) => padding};
19
- justify-content: ${({ justifyContent }) => justifyContent};
20
-
21
- color: ${({ textColor }) => textColor};
22
- background-color: ${({ backgroundColor }) => backgroundColor};
23
- `;
24
-
25
- export const StyledAlertBannerContent = styled.div<any>`
26
- display: flex;
27
- align-items: center;
28
- gap: var(--spacing-8px, 8px);
29
- color: ${({ color }) => color};
30
- font-family: var(--font-family, 'Mona Sans');
31
- font-size: var(--font-size-14px, 14px);
32
- font-weight: var(--font-weight-semibold, 600);
33
- line-height: 120%;
34
- letter-spacing: 0.5px;
35
- `;
@@ -1,70 +0,0 @@
1
- import '@testing-library/jest-dom';
2
-
3
- import { fireEvent, render, screen } from '@testing-library/react';
4
- import React from 'react';
5
-
6
- import AlertBanner from './AlertBanner';
7
-
8
- describe('AlertBanner', () => {
9
- it('renders the alert banner text', () => {
10
- render(<AlertBanner>Test Title</AlertBanner>);
11
- expect(screen.getByText('Test Title')).toBeInTheDocument();
12
- });
13
-
14
- it('renders the alert banner action buttons', () => {
15
- render(
16
- <AlertBanner
17
- actionButtons={[
18
- { children: 'Button 1', variant: 'primary', size: 'small' },
19
- ]}
20
- >
21
- Test Title
22
- </AlertBanner>
23
- );
24
- expect(screen.getByText('Test Title')).toBeInTheDocument();
25
- expect(screen.getByText('Button 1')).toBeInTheDocument();
26
- });
27
-
28
- it('renders the alert banner close button', () => {
29
- const onClose = jest.fn();
30
- render(
31
- <AlertBanner showCloseButton onClose={onClose}>
32
- Test Title
33
- </AlertBanner>
34
- );
35
- expect(screen.getByText('Test Title')).toBeInTheDocument();
36
- expect(screen.getByRole('button')).toBeInTheDocument();
37
- });
38
-
39
- it('renders with different types and variants', () => {
40
- render(
41
- <AlertBanner type="outlined" variant="success">
42
- Success Alert
43
- </AlertBanner>
44
- );
45
- expect(screen.getByText('Success Alert')).toBeInTheDocument();
46
- });
47
-
48
- it('renders with a custom icon', () => {
49
- render(<AlertBanner icon="bell">Alert with Custom Icon</AlertBanner>);
50
- expect(screen.getByText('Alert with Custom Icon')).toBeInTheDocument();
51
- expect(screen.getByTestId('testid-icon')).toBeInTheDocument();
52
- });
53
-
54
- it('renders without icon when stated explicitly', () => {
55
- render(<AlertBanner icon={null}>Alert without Icon</AlertBanner>);
56
- expect(screen.getByText('Alert without Icon')).toBeInTheDocument();
57
- expect(screen.queryByTestId('testid-icon')).not.toBeInTheDocument();
58
- });
59
-
60
- it('calls onClose when close button is clicked', () => {
61
- const onClose = jest.fn();
62
- render(
63
- <AlertBanner showCloseButton onClose={onClose}>
64
- Closable Alert
65
- </AlertBanner>
66
- );
67
- fireEvent.click(screen.getByRole('button'));
68
- expect(onClose).toHaveBeenCalledTimes(1);
69
- });
70
- });