@indico-data/design-system 2.47.0 → 2.47.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.
- package/lib/components/modal/Modal.d.ts +1 -1
- package/lib/components/modal/types.d.ts +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.esm.js +2 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/modal/Modal.mdx +15 -5
- package/src/components/modal/Modal.stories.tsx +11 -0
- package/src/components/modal/Modal.tsx +2 -0
- package/src/components/modal/types.ts +1 -0
package/package.json
CHANGED
|
@@ -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',
|
|
@@ -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}
|
|
@@ -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
|
}
|