@royaloperahouse/chord 2.2.3-chord-development → 2.2.3-d-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.
@@ -0,0 +1,68 @@
1
+ import { FunctionComponent } from 'react';
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
+ */
67
+ declare const ModalWindow: FunctionComponent<ModalWindowProps>;
68
+ export default ModalWindow;
@@ -0,0 +1,4 @@
1
+ export declare const InnerModal: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const CloseButton: import("styled-components").StyledComponent<"button", any, {}, never>;
3
+ export declare const ContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const Overlay: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,2 @@
1
+ import ModalWindow from './ModalWindow';
2
+ export default ModalWindow;
@@ -5,4 +5,5 @@ import TitleWithCTA from './TitleWithCTA';
5
5
  import UpsellSection from './UpsellSection';
6
6
  import { LiveChat } from './LiveChat';
7
7
  import StickyBar from './StickyBar';
8
- export { AnchorTabBar, Footer, LiveChat, Navigation, StickyBar, TitleWithCTA, UpsellSection };
8
+ import ModalWindow from './ModalWindow';
9
+ export { AnchorTabBar, Footer, LiveChat, ModalWindow, Navigation, StickyBar, TitleWithCTA, UpsellSection };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Accordion, Accordions, AnnouncementBanner, AltHeader, AnchorTabBar, BodyText, Card, Cards, CinemaBadge, ContactCard, ContentSummary, ControlledDropdown, CreditListing, Editorial, Footer, GlobalStyles, Grid, GridItem, Header, Icon, ImageAspectRatioWrapper, ImageWithCaption, Information, LiveChat, Navigation, Overline, PageHeadingCinema, PageHeadingCompact, PageHeadingCore, PageHeadingImpact, PageHeadingPanel, PageHeadingStream, Pagination, PeopleListing, PrimaryButton, Progress, PromoWithTags, PromoWithTitle, Radio, RadioGroup, ReadMore, RotatorButtons, SearchBar, SecondaryButton, SecondaryLogo, SectionSplitter, SectionTitle, Select, Sponsorship, Stepper, StickyBar, StreamBadge, Subtitle, TertiaryButton, TextOnly, ThemeProvider, TitleWithCTA, Tab, TabLink, Tabs, TextArea, TextField, TextLink, Tickbox, Timer, TypeTags, UpsellCard, UpsellSection, Quote } from './components';
2
2
  import { devices, breakpoints } from './styles/viewports';
3
3
  import zIndexes from './styles/zIndexes';
4
- import { AspectRatio, ButtonType, CarouselType, Colors, IconNameType, IntegratedTimerProps, ITimerProps, TickboxMode, ThemeType } from './types';
4
+ import { AspectRatio, ButtonType, CarouselType, Colors, IconNameType, IntegratedTimerProps, ITimerProps, TickboxMode, ThemeType, EditorialLink } from './types';
5
5
  import { MiniCard } from './components/molecules';
6
6
  import { BrandingStyle } from './types/impactHeader';
7
- export { Accordion, Accordions, AnnouncementBanner, AltHeader, AnchorTabBar, AspectRatio, BodyText, BrandingStyle, breakpoints, ButtonType, Card, Cards, CarouselType, CinemaBadge, Colors, ContactCard, ContentSummary, ControlledDropdown, CreditListing, devices, Editorial, Footer, GlobalStyles, Grid, GridItem, Header, Icon, IconNameType, ImageAspectRatioWrapper, ImageWithCaption, Information, ITimerProps, IntegratedTimerProps, LiveChat, MiniCard, Navigation, Overline, PageHeadingCinema, PageHeadingCompact, PageHeadingCore, PageHeadingImpact, PageHeadingPanel, PageHeadingStream, Pagination, PeopleListing, PrimaryButton, Progress, PromoWithTags, PromoWithTitle, Radio, RadioGroup, ReadMore, RotatorButtons, SearchBar, SecondaryButton, SecondaryLogo, SectionSplitter, SectionTitle, Select, Sponsorship, Stepper, StickyBar, StreamBadge, Subtitle, Tab, TabLink, Tabs, TertiaryButton, TextArea, TextField, TextLink, TextOnly, ThemeProvider, ThemeType, TitleWithCTA, Tickbox, TickboxMode, Timer, TypeTags, UpsellCard, UpsellSection, Quote, zIndexes, };
7
+ import { ModalWindow } from './components/organisms';
8
+ export { Accordion, Accordions, AnnouncementBanner, AltHeader, AnchorTabBar, AspectRatio, BodyText, BrandingStyle, breakpoints, ButtonType, Card, Cards, CarouselType, CinemaBadge, Colors, ContactCard, ContentSummary, ControlledDropdown, CreditListing, devices, Editorial, EditorialLink, Footer, GlobalStyles, Grid, GridItem, Header, Icon, IconNameType, ImageAspectRatioWrapper, ImageWithCaption, Information, ITimerProps, IntegratedTimerProps, LiveChat, MiniCard, ModalWindow, Navigation, Overline, PageHeadingCinema, PageHeadingCompact, PageHeadingCore, PageHeadingImpact, PageHeadingPanel, PageHeadingStream, Pagination, PeopleListing, PrimaryButton, Progress, PromoWithTags, PromoWithTitle, Radio, RadioGroup, ReadMore, RotatorButtons, SearchBar, SecondaryButton, SecondaryLogo, SectionSplitter, SectionTitle, Select, Sponsorship, Stepper, StickyBar, StreamBadge, Subtitle, Tab, TabLink, Tabs, TertiaryButton, TextArea, TextField, TextLink, TextOnly, ThemeProvider, ThemeType, TitleWithCTA, Tickbox, TickboxMode, Timer, TypeTags, UpsellCard, UpsellSection, Quote, zIndexes, };
@@ -10,4 +10,5 @@ import { EditorialLink } from './editorial';
10
10
  import { IPageHeadingCompactProps } from './impactHeader';
11
11
  import { IntegratedTimerProps, ITimerProps } from './timer';
12
12
  import { ICreditListing } from './creditListing';
13
- export { AspectRatio, ButtonType, CarouselType, Colors, ICreditListing, EditorialLink, FooterData, IconNameType, IPageHeadingCompactProps, INavigationProps, INavTopProps, IntegratedTimerProps, ITimerProps, TickboxMode, ThemeType, };
13
+ import { ModalWindowProps } from './modalWindow';
14
+ export { AspectRatio, ButtonType, CarouselType, Colors, ICreditListing, EditorialLink, FooterData, IconNameType, IPageHeadingCompactProps, INavigationProps, INavTopProps, IntegratedTimerProps, ITimerProps, ModalWindowProps, TickboxMode, ThemeType, };
@@ -0,0 +1,20 @@
1
+ import { ReactElement } from 'react';
2
+ import Modal from 'react-modal';
3
+ export interface ModalWindowProps extends Modal.Props {
4
+ /**
5
+ * Boolean indicating if the modal is open.
6
+ */
7
+ isOpen: boolean;
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
+ */
15
+ children: ReactElement;
16
+ /**
17
+ * ID of the app element to assist with accessibility.
18
+ */
19
+ appElementId?: string;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@royaloperahouse/chord",
3
- "version": "2.2.3-chord-development",
3
+ "version": "2.2.3-d-chord-development",
4
4
  "author": "Royal Opera House",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -91,6 +91,7 @@
91
91
  "@types/jest": "^27.0.2",
92
92
  "@types/react": "^17.0.34",
93
93
  "@types/react-dom": "^17.0.11",
94
+ "@types/react-modal": "^3.16.3",
94
95
  "@types/react-test-renderer": "^17.0.1",
95
96
  "@types/styled-components": "^5.1.15",
96
97
  "@types/testing-library__jest-dom": "^5.14.1",
@@ -110,6 +111,8 @@
110
111
  "typescript": "^4.4.4"
111
112
  },
112
113
  "dependencies": {
113
- "moment": "^2.29.4"
114
+ "moment": "^2.29.4",
115
+ "react-modal": "^3.16.1",
116
+ "react-scrolllock": "^5.0.1"
114
117
  }
115
118
  }