@indico-data/design-system 2.47.0 → 2.47.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "2.47.0",
3
+ "version": "2.47.2",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -14,6 +14,20 @@ The Modal component provides us with a way to display content in a modal window.
14
14
  ## Usage
15
15
  We have designed this modal with the intention for it to be used as a wrapper for content as you will see below. The recommended way to best use this component is to create your own wrapper in your application for specific modal needs. For example, you may create a wrapper component that displays a confirmation modal. You may also wish to create one for a stepper modal. The idea is that you wrap this modal in a component and build the body of your modal in that wrapped component so that you can reuse the modal component for different modal needs.
16
16
 
17
+ ### Parent Selector
18
+ You may have an issue with styling and require the modal to be displayed in a specific part of your application. You can use the `parentSelector` prop to pass in a function that returns the element you want to use as the parent element for the modal. In insights we have the following example.
19
+
20
+ ```tsx
21
+ const parentSelector = () =>
22
+ document.getElementById('theme-root') || document.getElementById('root');
23
+
24
+ return (
25
+ <Modal parentSelector={parentSelector}>
26
+ {children}
27
+ </Modal>
28
+ );
29
+ ```
30
+
17
31
  ### Opening The Modal
18
32
  To open the modal, you can use the following as an example. You create a state variable to control the modal's open/close state and then pass that state variable to the modal component.
19
33
 
@@ -104,8 +118,4 @@ If you are looking for a confirmation modal, you can use the following as an exa
104
118
  </Col>
105
119
  </Row>
106
120
  </Modal>
107
- ```
108
-
109
- ### Title vs Content
110
- The title prop is optional for the modal. If you do not provide a title, the modal will only display the content. If you do provide a title, the modal will display the title and content.
111
-
121
+ ```
@@ -93,6 +93,17 @@ const meta: Meta = {
93
93
  },
94
94
  },
95
95
  },
96
+ parentSelector: {
97
+ control: false,
98
+ description:
99
+ 'The element to use as the parent element for the modal. If you have issues with styling, make sure you pass the correct root element here.',
100
+ table: {
101
+ category: 'Props',
102
+ type: {
103
+ summary: 'HTMLElement',
104
+ },
105
+ },
106
+ },
96
107
  shouldCloseOnEsc: {
97
108
  control: 'boolean',
98
109
  description: 'Whether the modal should close when the escape key is pressed',
@@ -172,8 +183,8 @@ export const Default: Story = {
172
183
  <Row>
173
184
  <Col sm={4}>
174
185
  <Modal {...args} isOpen={isOpen} onRequestClose={handleClose}>
175
- <h2>The Legend of Zelda</h2>
176
- <p>
186
+ <h2 className="mb-4">The Legend of Zelda</h2>
187
+ <p className="mb-4">
177
188
  In the mystical realm of Hyrule, where ancient magic flows through verdant fields
178
189
  and towering mountains, a timeless tale unfolds across countless generations. The
179
190
  legendary hero Link, eternally reborn when darkness threatens the land, stands as
@@ -181,7 +192,7 @@ export const Default: Story = {
181
192
  Through the ages, he has faced the malevolent forces of Ganon, whose insatiable
182
193
  desire for power has brought destruction and chaos to this peaceful kingdom.
183
194
  </p>
184
- <p>
195
+ <p className="mb-4">
185
196
  Princess Zelda, blessed with the wisdom of the goddesses and keeper of the royal
186
197
  bloodline, serves as both ruler and guardian of Hyrule's most sacred treasures.
187
198
  Together with Link, she maintains the delicate balance between light and shadow,
@@ -233,8 +244,8 @@ export const ConfirmationModal: Story = {
233
244
  <Row>
234
245
  <Col sm={4}>
235
246
  <Modal {...args} isOpen={isOpen} onRequestClose={handleClose}>
236
- <h2>Would you like to continue?</h2>
237
- <p>
247
+ <h2 className="mb-4">Would you like to continue?</h2>
248
+ <p className="mb-4">
238
249
  If you would like to proceed, please click the confirm button. Otherwise, click the
239
250
  cancel button.
240
251
  </p>
@@ -18,6 +18,7 @@ export const Modal = ({
18
18
  contentElement,
19
19
  overlayElement,
20
20
  position = 'center',
21
+ parentSelector,
21
22
  ...rest
22
23
  }: ModalProps) => {
23
24
  const modalClasses = classNames('modal', `modal--${position}`, className);
@@ -33,6 +34,7 @@ export const Modal = ({
33
34
  onRequestClose={onRequestClose}
34
35
  portalClassName={portalClassName}
35
36
  appElement={appElement}
37
+ parentSelector={parentSelector}
36
38
  shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
37
39
  shouldCloseOnEsc={shouldCloseOnEsc}
38
40
  contentElement={contentElement}
@@ -72,19 +72,6 @@
72
72
  font-size: var(--pf-font-size-h1);
73
73
  }
74
74
 
75
- h1,
76
- h2,
77
- h3,
78
- h4,
79
- h5,
80
- h6 {
81
- margin-bottom: var(--pf-margin-4);
82
- }
83
-
84
- p {
85
- margin-bottom: var(--pf-margin-4);
86
- }
87
-
88
75
  // We should build a divider component for this
89
76
  hr {
90
77
  margin-top: var(--pf-margin-8);
@@ -12,4 +12,5 @@ export interface ModalProps {
12
12
  contentElement?: (props: any, children: React.ReactNode) => React.ReactElement;
13
13
  overlayElement?: (props: any, contentElement: React.ReactElement) => React.ReactElement;
14
14
  position?: 'top' | 'center';
15
+ parentSelector?: () => HTMLElement;
15
16
  }