@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,116 +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 ConfirmationDialog, { ConfirmationDialogProps } from '.';
7
-
8
- describe('ConfirmationDialog', () => {
9
- const defaultProps: ConfirmationDialogProps = {
10
- onConfirm: jest.fn(),
11
- onCancel: jest.fn(),
12
- title: 'Modal title',
13
- description: 'Modal description',
14
- confirmText: 'Modal confirmText',
15
- cancelText: 'Modal cancelText',
16
- };
17
-
18
- it('renders the confirmation dialog title, description and buttons', () => {
19
- render(<ConfirmationDialog {...defaultProps} />);
20
- expect(screen.getByText('Modal title')).toBeInTheDocument();
21
- expect(screen.getByText('Modal description')).toBeInTheDocument();
22
- expect(screen.getByText('Modal confirmText')).toBeInTheDocument();
23
- expect(screen.getByText('Modal cancelText')).toBeInTheDocument();
24
- });
25
-
26
- it('calls onConfirm when confirm button is clicked', () => {
27
- render(<ConfirmationDialog {...defaultProps} />);
28
- fireEvent.click(screen.getByText('Modal confirmText'));
29
- expect(defaultProps.onConfirm).toHaveBeenCalledTimes(1);
30
- });
31
-
32
- it('calls onCancel when cancel button is clicked', () => {
33
- render(<ConfirmationDialog {...defaultProps} />);
34
- fireEvent.click(screen.getByText('Modal cancelText'));
35
- expect(defaultProps.onCancel).toHaveBeenCalledTimes(1);
36
- });
37
-
38
- it('renders the close button when showCloseButton is not falsy', () => {
39
- render(<ConfirmationDialog {...defaultProps} showCloseButton />);
40
- expect(screen.getByTestId('testid-iconbutton')).toBeInTheDocument();
41
- });
42
-
43
- it('does not render the close button when showCloseButton is false', () => {
44
- render(
45
- <ConfirmationDialog {...defaultProps} showCloseButton={false} />
46
- );
47
- expect(
48
- screen.queryByTestId('testid-iconbutton')
49
- ).not.toBeInTheDocument();
50
- });
51
-
52
- it('calls onCancel when close button is present and clicked', () => {
53
- const onCancelFn = jest.fn();
54
- render(
55
- <ConfirmationDialog
56
- {...defaultProps}
57
- showCloseButton
58
- onCancel={onCancelFn}
59
- />
60
- );
61
- fireEvent.click(screen.getByTestId('testid-iconbutton'));
62
- expect(onCancelFn).toHaveBeenCalledTimes(1);
63
- });
64
-
65
- it('calls onCancel when hideOnClickAway is true and Escape button is pressed', () => {
66
- const onCancelFn = jest.fn();
67
- render(
68
- <ConfirmationDialog
69
- {...defaultProps}
70
- hideOnClickAway
71
- onCancel={onCancelFn}
72
- />
73
- );
74
- fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
75
- expect(onCancelFn).toHaveBeenCalledTimes(1);
76
- });
77
-
78
- it('does not call onCancel when hideOnClickAway is false and Escape button is pressed', () => {
79
- const onCancelFn = jest.fn();
80
- render(
81
- <ConfirmationDialog
82
- {...defaultProps}
83
- hideOnClickAway={false}
84
- onCancel={onCancelFn}
85
- />
86
- );
87
- fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
88
- expect(onCancelFn).toHaveBeenCalledTimes(0);
89
- });
90
-
91
- it('calls onCancel when hideOnClickAway is true and clicked outside the modal', () => {
92
- const onCancelFn = jest.fn();
93
- render(
94
- <ConfirmationDialog
95
- {...defaultProps}
96
- hideOnClickAway
97
- onCancel={onCancelFn}
98
- />
99
- );
100
- fireEvent.mouseDown(document);
101
- expect(onCancelFn).toHaveBeenCalledTimes(1);
102
- });
103
-
104
- it('does not call onCancel when hideOnClickAway is false and clicked outside the modal', () => {
105
- const onCancelFn = jest.fn();
106
- render(
107
- <ConfirmationDialog
108
- {...defaultProps}
109
- hideOnClickAway={false}
110
- onCancel={onCancelFn}
111
- />
112
- );
113
- fireEvent.mouseDown(document);
114
- expect(onCancelFn).toHaveBeenCalledTimes(0);
115
- });
116
- });
@@ -1,151 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React, { useId } from 'react';
3
-
4
- import { useKeyboardEvent } from '../../../../hooks';
5
- import useClickAway from '../../../../hooks/useClickAway';
6
- import useDisableBodyScroll from '../../../../hooks/useDisableBodyScroll';
7
- import Button, { BUTTON_VARIANTS_ENUM, IconButton } from '../../Button';
8
- import Modal from '../Modal';
9
- import { ConfirmationDialogProps } from '../types';
10
-
11
- /**
12
- * A confirmation dialog is a dialog box that asks the user to confirm an action.
13
- */
14
- const ConfirmationDialog = ({
15
- cancelText,
16
- confirmText,
17
- onCancel,
18
- onConfirm,
19
- banner,
20
- title,
21
- description,
22
- body,
23
- cancelButtonVariant,
24
- confirmButtonVariant,
25
- showCloseButton,
26
- hideOnClickAway,
27
- blurBackground,
28
- mobileBottomFullWidth,
29
- }: ConfirmationDialogProps) => {
30
- const modalRef = React.useRef(null);
31
-
32
- useDisableBodyScroll();
33
-
34
- useKeyboardEvent(() => {
35
- if (hideOnClickAway) {
36
- onCancel();
37
- }
38
- }, ['Escape']);
39
-
40
- useClickAway(modalRef, () => {
41
- if (hideOnClickAway) {
42
- onCancel();
43
- }
44
- });
45
-
46
- const id = useId();
47
-
48
- return (
49
- <Modal.Wrapper blurBackground={blurBackground}>
50
- <Modal.Modal
51
- onClick={(e: Event) => e.stopPropagation()}
52
- width="auto"
53
- height="auto"
54
- ref={modalRef}
55
- aria-labelledby={`modal-title-${id}`}
56
- aria-describedby={`modal-description-${id}`}
57
- aria-modal="true"
58
- role="dialog"
59
- mobileBottomFullWidth={mobileBottomFullWidth}
60
- >
61
- <Modal.Main>
62
- {showCloseButton && (
63
- <Modal.Action justifyContent="end">
64
- <IconButton
65
- onClick={onCancel}
66
- variant="secondary-outlined"
67
- icon="close"
68
- ariaLabel="Close"
69
- />
70
- </Modal.Action>
71
- )}
72
-
73
- {banner && <Modal.Banner>{banner}</Modal.Banner>}
74
-
75
- {title && (
76
- <Modal.Title id={`modal-title-${id}`}>
77
- {title}
78
- </Modal.Title>
79
- )}
80
-
81
- {description && (
82
- <Modal.Description id={`modal-description-${id}`}>
83
- {description}
84
- </Modal.Description>
85
- )}
86
-
87
- {body && <Modal.Body>{body}</Modal.Body>}
88
- </Modal.Main>
89
-
90
- <Modal.Action>
91
- <Button
92
- variant={
93
- cancelButtonVariant || BUTTON_VARIANTS_ENUM.DANGER
94
- }
95
- fullWidth
96
- onClick={onCancel}
97
- >
98
- {cancelText}
99
- </Button>
100
- <Button
101
- variant={
102
- confirmButtonVariant || BUTTON_VARIANTS_ENUM.SUCCESS
103
- }
104
- fullWidth
105
- onClick={onConfirm}
106
- >
107
- {confirmText}
108
- </Button>
109
- </Modal.Action>
110
- </Modal.Modal>
111
- </Modal.Wrapper>
112
- );
113
- };
114
-
115
- ConfirmationDialog.propTypes = {
116
- cancelText: PropTypes.string,
117
- confirmText: PropTypes.string,
118
- onCancel: PropTypes.func,
119
- onConfirm: PropTypes.func,
120
- banner: PropTypes.string || PropTypes.node,
121
- title: PropTypes.string || PropTypes.node,
122
- description: PropTypes.string,
123
- body: PropTypes.string || PropTypes.node,
124
- cancelButtonVariant: PropTypes.string,
125
- confirmButtonVariant: PropTypes.string,
126
- showCloseButton: PropTypes.bool,
127
- hideOnClickAway: PropTypes.bool,
128
- blurBackground: PropTypes.bool,
129
- mobileBottomFullWidth: PropTypes.bool,
130
- };
131
-
132
- ConfirmationDialog.defaultProps = {
133
- cancelText: 'Cancel',
134
- confirmText: 'Confirm',
135
- banner: null,
136
- title: 'Are you sure?',
137
- description: 'Please confirm your action.',
138
- body: null,
139
- onCancel: () => {},
140
- onConfirm: () => {},
141
- cancelButtonVariant: 'danger',
142
- confirmButtonVariant: 'success',
143
- showCloseButton: false,
144
- hideOnClickAway: false,
145
- blurBackground: false,
146
- mobileBottomFullWidth: false,
147
- };
148
-
149
- export { ConfirmationDialogProps };
150
-
151
- export default ConfirmationDialog;
@@ -1,230 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import styled, { css } from 'styled-components';
3
-
4
- import {
5
- ModalBodyMainProps,
6
- ModalBodyProps,
7
- ModalContainerProps,
8
- ModalDescriptionProps,
9
- ModalPaginationItemProps,
10
- ModalTitleProps,
11
- ModalWrapperProps,
12
- } from './types';
13
-
14
- export const StyledModalWrapper = styled.div<ModalWrapperProps>`
15
- position: fixed;
16
- top: 0;
17
- left: 0;
18
- right: 0;
19
- bottom: 0;
20
- background-color: var(--alpha-overlay, rgba(22, 25, 29, 0.8));
21
- z-index: 1000;
22
- padding: var(--spacing-16px, 16px);
23
- display: flex;
24
- justify-content: center;
25
- align-items: center;
26
- font-family: var(--font-family, 'Mona Sans');
27
-
28
- ${({ blurBackground }) =>
29
- blurBackground &&
30
- css`
31
- backdrop-filter: var(--backdrop-blur-8px);
32
- `}
33
- `;
34
-
35
- export const StyledModal = styled.div<ModalContainerProps>`
36
- border: var(--spacing-1px, 1px) solid var(--border, #e1e5ea);
37
- background: var(--bg-primary, #fff);
38
- z-index: 1000;
39
- box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.25);
40
- border-radius: var(--corner-radius-12px, 12px);
41
- width: 500px;
42
- min-width: 400px;
43
- height: 525px;
44
- padding: var(--spacing-20px, 20px);
45
- display: flex;
46
- flex-direction: column;
47
- align-items: center;
48
- justify-content: space-between;
49
- gap: var(--spacing-16px, 16px);
50
-
51
- @media only screen and (max-width: 600px) {
52
- padding: var(--spacing-18px, 18px);
53
- }
54
-
55
- ${({ width }) =>
56
- width
57
- ? css`
58
- width: ${width};
59
- `
60
- : ''}
61
- ${({ height }) =>
62
- height
63
- ? css`
64
- height: ${height};
65
- `
66
- : ''}
67
- ${({ minHeight }) =>
68
- minHeight
69
- ? css`
70
- min-height: ${minHeight};
71
- `
72
- : ''}
73
- ${({ mobileBottomFullWidth }) =>
74
- mobileBottomFullWidth
75
- ? css`
76
- @media only screen and (max-width: 600px) {
77
- position: fixed;
78
- bottom: 0;
79
- border-bottom-left-radius: 0;
80
- border-bottom-right-radius: 0;
81
- max-width: unset;
82
- width: 100%;
83
- padding: var(--spacing-16px, 16px);
84
- }
85
- `
86
- : ''}
87
-
88
- ${({ modalPadding }) =>
89
- css`
90
- padding: ${modalPadding};
91
- `}
92
- `;
93
-
94
- export const StyledModalMain = styled.div<ModalBodyMainProps>`
95
- display: flex;
96
- flex-direction: column;
97
- align-items: center;
98
- width: 100%;
99
- flex: 1;
100
- gap: var(--spacing-12px, 12px);
101
-
102
- @media only screen and (max-width: 600px) {
103
- padding: 0;
104
- }
105
- `;
106
-
107
- export const StyledModalDivider = styled.div`
108
- width: 100%;
109
- height: var(--spacing-1px, 1px);
110
- background: var(--border, #e1e5ea);
111
- `;
112
-
113
- export const StyledModalTitle = styled.h2<ModalTitleProps>`
114
- color: var(--text-primary, #16191d);
115
- font-weight: var(--font-weight-semibold, 600);
116
- font-size: var(--font-size-24px, 24px);
117
- line-height: var(--spacing-32px, 32px);
118
- margin: var(--spacing-0px, 0px) auto;
119
- text-align: center;
120
-
121
- img {
122
- width: 100%;
123
- border-radius: var(--corner-radius-8px, 8px);
124
- }
125
-
126
- @media only screen and (max-width: 600px) {
127
- font-size: var(--font-size-16px, 16px);
128
- line-height: var(--spacing-24px, 24px);
129
- }
130
- `;
131
-
132
- export const StyledModalDescription = styled.div<ModalDescriptionProps>`
133
- font-weight: var(--font-weight-450, 450);
134
- font-size: var(--font-size-16px, 16px);
135
- line-height: var(--spacing-28px, 28px);
136
- text-align: center;
137
- letter-spacing: 0.2px;
138
- color: var(--text-secondary, #5b6271);
139
- white-space: pre-line;
140
-
141
- @media only screen and (max-width: 600px) {
142
- font-size: var(--font-size-14px, 14px);
143
- line-height: var(--spacing-24px, 24px);
144
- }
145
- `;
146
-
147
- export const StyledModalBody = styled.div<ModalBodyProps>`
148
- font-weight: var(--font-weight-450, 450);
149
- font-size: var(--font-size-16px, 16px);
150
- line-height: var(--spacing-28px, 28px);
151
- text-align: center;
152
- letter-spacing: 0.2px;
153
- color: var(--text-secondary, #5b6271);
154
- margin: ${({ modalBodyMargin }) => modalBodyMargin && modalBodyMargin};
155
- white-space: pre-line;
156
- width: 100%;
157
- flex: 1;
158
-
159
- img {
160
- width: 100%;
161
- border-radius: var(--corner-radius-8px, 8px);
162
- }
163
-
164
- @media only screen and (max-width: 600px) {
165
- font-size: var(--font-size-14px, 14px);
166
- line-height: var(--spacing-24px, 24px);
167
- }
168
- `;
169
-
170
- export const StyledModalPaginatedActions = styled.div`
171
- display: flex;
172
- flex-direction: column;
173
- width: 100%;
174
- justify-content: center;
175
- gap: var(--spacing-12px, 12px);
176
- `;
177
-
178
- export const StyledModalPagination = styled.div`
179
- display: flex;
180
- justify-content: center;
181
- align-items: center;
182
- gap: var(--spacing-4px, 4px);
183
- margin-top: auto;
184
- `;
185
-
186
- export const StyledModalPaginationItem = styled.div<ModalPaginationItemProps>`
187
- width: 6px;
188
- height: 6px;
189
- border-radius: var(--corner-radius-50percent, 50%);
190
- background: var(--border, #e1e5ea);
191
- cursor: pointer;
192
- transition: all 0.1s ease-in-out;
193
-
194
- ${({ active }) =>
195
- active
196
- ? 'background: var(--text-secondary, #5b6271);'
197
- : '&:hover {background: var(--text-disabled, #8C95A6);}'}
198
- `;
199
-
200
- export const StyledModalAction = styled.div<{
201
- justifyContent?: string;
202
- children: ReactNode;
203
- }>`
204
- display: flex;
205
- align-items: center;
206
- justify-content: center;
207
- width: 100%;
208
- gap: var(--spacing-8px, 8px);
209
-
210
- ${({ justifyContent }) =>
211
- justifyContent &&
212
- css`
213
- justify-content: ${justifyContent};
214
- `}
215
-
216
- img {
217
- width: 100%;
218
- border-radius: var(--corner-radius-8px, 8px);
219
- }
220
- `;
221
-
222
- export const StyledModalBanner = styled.div`
223
- width: 100%;
224
- position: relative;
225
-
226
- img {
227
- width: 100%;
228
- border-radius: var(--corner-radius-8px, 8px);
229
- }
230
- `;
@@ -1,117 +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 Button from '../Button';
7
- import Modal from './Modal';
8
- import { ModalProps } from './types';
9
-
10
- describe('Modal', () => {
11
- const defaultProps: ModalProps = {
12
- banner: 'Modal banner',
13
- title: 'Modal title',
14
- description: 'Modal description',
15
- body: 'Modal body',
16
- action: (
17
- <>
18
- <Button variant="primary" onClick={() => {}} fullWidth>
19
- Primary Button
20
- </Button>
21
- <Button variant="secondary" onClick={() => {}} fullWidth>
22
- Secondary Button
23
- </Button>
24
- </>
25
- ),
26
- hideOnClickAway: true,
27
- blurBackground: false,
28
- onHide: () => {},
29
- mobileBottomFullWidth: false,
30
- modalPadding: '20px',
31
- modalBodyMargin: '',
32
- width: '500px',
33
- height: 'auto',
34
- minHeight: 'auto',
35
- showCloseButton: true,
36
- };
37
-
38
- it('renders the modal banner, title, description and body', () => {
39
- render(<Modal {...defaultProps} />);
40
- expect(screen.getByText('Modal banner')).toBeInTheDocument();
41
- expect(screen.getByText('Modal title')).toBeInTheDocument();
42
- expect(screen.getByText('Modal description')).toBeInTheDocument();
43
- expect(screen.getByText('Modal body')).toBeInTheDocument();
44
- });
45
-
46
- it('renders the modal action buttons', () => {
47
- render(<Modal {...defaultProps} />);
48
- expect(screen.getByText('Primary Button')).toBeInTheDocument();
49
- expect(screen.getByText('Secondary Button')).toBeInTheDocument();
50
- });
51
-
52
- it('renders the close button', () => {
53
- render(<Modal {...defaultProps} />);
54
- expect(screen.getByTestId('testid-iconbutton')).toBeInTheDocument();
55
- });
56
-
57
- it('does not render the close button when showCloseButton is false', () => {
58
- render(<Modal {...defaultProps} showCloseButton={false} />);
59
- expect(
60
- screen.queryByTestId('testid-iconbutton')
61
- ).not.toBeInTheDocument();
62
- });
63
-
64
- it('calls onHide when close button is clicked', () => {
65
- const onHideFn = jest.fn();
66
- render(<Modal {...defaultProps} onHide={onHideFn} />);
67
- fireEvent.click(screen.getByTestId('testid-iconbutton'));
68
- expect(onHideFn).toHaveBeenCalledTimes(1);
69
- });
70
-
71
- it('calls onHide when Escape button is pressed', () => {
72
- const onHideFn = jest.fn();
73
- render(<Modal {...defaultProps} onHide={onHideFn} />);
74
- fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
75
- expect(onHideFn).toHaveBeenCalledTimes(1);
76
- });
77
-
78
- it('calls onHide when clicked outside the modal', () => {
79
- const onHideFn = jest.fn();
80
- render(<Modal {...defaultProps} onHide={onHideFn} />);
81
- fireEvent.mouseDown(document);
82
- expect(onHideFn).toHaveBeenCalledTimes(1);
83
- });
84
-
85
- it('does not call onHide when clicked inside the modal', () => {
86
- const onHideFn = jest.fn();
87
- render(<Modal {...defaultProps} onHide={onHideFn} />);
88
- fireEvent.click(screen.getByTestId('testid-modal'));
89
- expect(onHideFn).toHaveBeenCalledTimes(0);
90
- });
91
-
92
- it('does not call onHide on outside click when hideOnClickAway is false', () => {
93
- const onHideFn = jest.fn();
94
- render(
95
- <Modal
96
- {...defaultProps}
97
- onHide={onHideFn}
98
- hideOnClickAway={false}
99
- />
100
- );
101
- fireEvent.click(screen.getByTestId('testid-modalwrapper'));
102
- expect(onHideFn).toHaveBeenCalledTimes(0);
103
- });
104
-
105
- it('does not call onHide on Escape key press when hideOnClickAway is false', () => {
106
- const onHideFn = jest.fn();
107
- render(
108
- <Modal
109
- {...defaultProps}
110
- onHide={onHideFn}
111
- hideOnClickAway={false}
112
- />
113
- );
114
- fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
115
- expect(onHideFn).toHaveBeenCalledTimes(0);
116
- });
117
- });