@royaloperahouse/chord 2.2.3-b-chord-development → 2.2.3-c-chord-development
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/dist/chord.cjs.development.js +70 -6
- package/dist/chord.cjs.development.js.map +1 -1
- package/dist/chord.cjs.production.min.js +1 -1
- package/dist/chord.cjs.production.min.js.map +1 -1
- package/dist/chord.esm.js +70 -6
- package/dist/chord.esm.js.map +1 -1
- package/dist/components/organisms/ModalWindow/ModalWindow.d.ts +64 -0
- package/dist/types/modalWindow.d.ts +14 -2
- package/package.json +1 -1
|
@@ -1,4 +1,68 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import { ModalWindowProps } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* A ModalWindow component, leveraging React Modal for rendering modals with enhanced accessibility
|
|
5
|
+
* and styling customization. This component is designed to be flexible for various use cases, with
|
|
6
|
+
* support for mobile responsiveness, custom z-indexes, and a close button.
|
|
7
|
+
*
|
|
8
|
+
* # Usage
|
|
9
|
+
* This component is intended to be used in React applications where modal functionality is required.
|
|
10
|
+
* It supports a range of props for customization, including isOpen, setIsOpen, children, appElementId,
|
|
11
|
+
* and accepts all additional props supported by React Modal for further configuration.
|
|
12
|
+
*
|
|
13
|
+
* ## Basic Example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import React, { useState } from 'react';
|
|
16
|
+
* import ModalWindow from './ModalWindow';
|
|
17
|
+
*
|
|
18
|
+
* const App = () => {
|
|
19
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
20
|
+
*
|
|
21
|
+
* const toggleModal = () => setIsOpen(!isOpen);
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <>
|
|
25
|
+
* <button onClick={toggleModal}>Open Modal</button>
|
|
26
|
+
* <ModalWindow
|
|
27
|
+
* isOpen={isOpen}
|
|
28
|
+
* setIsOpen={setIsOpen}
|
|
29
|
+
* appElementId="root"
|
|
30
|
+
* >
|
|
31
|
+
* <div>Modal Content Here</div>
|
|
32
|
+
* </ModalWindow>
|
|
33
|
+
* </>
|
|
34
|
+
* );
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* ## Advanced Usage
|
|
39
|
+
* You can further customize the modal by directly passing props supported by React Modal.
|
|
40
|
+
* This component adapts its z-index based on the device type (mobile or desktop) and allows for an
|
|
41
|
+
* accessible close functionality.
|
|
42
|
+
*
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <ModalWindow
|
|
45
|
+
* isOpen={isOpen}
|
|
46
|
+
* setIsOpen={setIsOpen}
|
|
47
|
+
* appElementId="root"
|
|
48
|
+
* shouldCloseOnOverlayClick={true}
|
|
49
|
+
* >
|
|
50
|
+
* <YourCustomComponent />
|
|
51
|
+
* </ModalWindow>
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* # Props
|
|
55
|
+
* - `isOpen`: Boolean indicating if the modal is open.
|
|
56
|
+
* - `setIsOpen`: Function to set the open state of the modal.
|
|
57
|
+
* - `children`: Content to be displayed within the modal.
|
|
58
|
+
* - `appElementId`: ID of the app element to assist with accessibility.
|
|
59
|
+
* - All other props are passed directly to the underlying React Modal component, allowing for extensive customization.
|
|
60
|
+
*
|
|
61
|
+
* # Design and Accessibility
|
|
62
|
+
* This component automatically applies a `ScrollLock` when the modal is open to prevent background
|
|
63
|
+
* scrolling and sets appropriate z-index values to ensure the modal is layered correctly on the page.
|
|
64
|
+
* It also configures the modal for accessibility, including support for closing on ESC and setting
|
|
65
|
+
* `aria-modal` to true.
|
|
66
|
+
*/
|
|
3
67
|
declare const ModalWindow: FunctionComponent<ModalWindowProps>;
|
|
4
68
|
export default ModalWindow;
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import Modal from 'react-modal';
|
|
3
3
|
export interface ModalWindowProps extends Modal.Props {
|
|
4
|
+
/**
|
|
5
|
+
* Boolean indicating if the modal is open.
|
|
6
|
+
*/
|
|
4
7
|
isOpen: boolean;
|
|
5
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Function to set the open state of the modal.
|
|
10
|
+
*/
|
|
11
|
+
setIsOpen: (isOpen: boolean) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Content to be displayed within the modal.
|
|
14
|
+
*/
|
|
6
15
|
children: ReactElement;
|
|
16
|
+
/**
|
|
17
|
+
* ID of the app element to assist with accessibility.
|
|
18
|
+
*/
|
|
7
19
|
appElementId: string;
|
|
8
20
|
}
|