@telus-uds/components-web 2.21.1 → 2.22.0
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/CHANGELOG.md +22 -2
- package/lib/Badge/Badge.js +2 -14
- package/lib/Badge/index.js +0 -3
- package/lib/BlockQuote/BlockQuote.js +4 -25
- package/lib/BlockQuote/index.js +0 -3
- package/lib/Breadcrumbs/Breadcrumbs.js +9 -36
- package/lib/Breadcrumbs/Item/Item.js +15 -25
- package/lib/Breadcrumbs/index.js +0 -2
- package/lib/Callout/Callout.js +2 -24
- package/lib/Callout/index.js +0 -3
- package/lib/Card/Card.js +15 -29
- package/lib/Card/CardContent.js +5 -18
- package/lib/Card/CardFooter.js +7 -19
- package/lib/Card/index.js +0 -3
- package/lib/Countdown/Countdown.js +5 -24
- package/lib/Countdown/Segment.js +3 -15
- package/lib/Countdown/index.js +0 -3
- package/lib/Countdown/types.js +2 -7
- package/lib/Countdown/useCountdown.js +0 -7
- package/lib/DatePicker/CalendarContainer.js +0 -5
- package/lib/DatePicker/DatePicker.js +9 -61
- package/lib/DatePicker/dictionary.js +0 -8
- package/lib/DatePicker/index.js +0 -3
- package/lib/DatePicker/reactDatesCss.js +0 -2
- package/lib/Disclaimer/Disclaimer.js +5 -14
- package/lib/Disclaimer/index.js +0 -2
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +6 -17
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +12 -25
- package/lib/ExpandCollapseMini/index.js +0 -3
- package/lib/Footnote/Footnote.js +17 -63
- package/lib/Footnote/FootnoteLink.js +3 -24
- package/lib/Footnote/index.js +0 -4
- package/lib/IconButton/IconButton.js +4 -14
- package/lib/IconButton/index.js +0 -3
- package/lib/Image/Image.js +5 -24
- package/lib/Image/index.js +0 -3
- package/lib/List/List.js +0 -2
- package/lib/List/ListItem.js +0 -8
- package/lib/List/index.js +0 -4
- package/lib/NavigationBar/NavigationBar.js +10 -35
- package/lib/NavigationBar/NavigationItem.js +5 -17
- package/lib/NavigationBar/NavigationSubMenu.js +3 -19
- package/lib/NavigationBar/collapseItems.js +6 -9
- package/lib/NavigationBar/index.js +0 -3
- package/lib/NavigationBar/resolveItemSelection.js +2 -3
- package/lib/OptimizeImage/OptimizeImage.js +6 -27
- package/lib/OptimizeImage/index.js +0 -3
- package/lib/OptimizeImage/utils/getFallbackUrl.js +0 -4
- package/lib/OptimizeImage/utils/getOptimizedUrl.js +0 -8
- package/lib/OptimizeImage/utils/hasWebpSupport.js +1 -5
- package/lib/OptimizeImage/utils/index.js +0 -4
- package/lib/OptimizeImage/utils/isSvgUrl.js +0 -1
- package/lib/OrderedList/Item.js +4 -21
- package/lib/OrderedList/ItemBase.js +2 -9
- package/lib/OrderedList/OrderedList.js +11 -22
- package/lib/OrderedList/OrderedListBase.js +3 -13
- package/lib/OrderedList/index.js +0 -4
- package/lib/Paragraph/Paragraph.js +3 -18
- package/lib/Paragraph/index.js +0 -3
- package/lib/PreviewCard/AuthorDate.js +1 -10
- package/lib/PreviewCard/PreviewCard.js +15 -35
- package/lib/PreviewCard/index.js +0 -3
- package/lib/PriceLockup/PriceLockup.js +78 -75
- package/lib/PriceLockup/index.js +0 -3
- package/lib/PriceLockup/tokens.js +0 -2
- package/lib/Progress/ProgressBar.js +5 -16
- package/lib/Progress/index.js +0 -4
- package/lib/QuantitySelector/QuantitySelector.js +8 -42
- package/lib/QuantitySelector/SideButton.js +4 -11
- package/lib/QuantitySelector/index.js +0 -3
- package/lib/QuantitySelector/styles.js +0 -6
- package/lib/ResponsiveImage/ResponsiveImage.js +5 -20
- package/lib/ResponsiveImage/index.js +0 -3
- package/lib/Ribbon/Ribbon.js +4 -20
- package/lib/Ribbon/index.js +0 -3
- package/lib/SkeletonProvider/SkeletonImage.js +0 -10
- package/lib/SkeletonProvider/SkeletonProvider.js +4 -22
- package/lib/SkeletonProvider/SkeletonTypography.js +0 -10
- package/lib/SkeletonProvider/index.js +0 -3
- package/lib/Span/Span.js +3 -17
- package/lib/Span/index.js +0 -3
- package/lib/Spinner/Spinner.js +11 -39
- package/lib/Spinner/SpinnerContent.js +2 -18
- package/lib/Spinner/index.js +0 -3
- package/lib/StoryCard/StoryCard.js +11 -31
- package/lib/StoryCard/index.js +0 -3
- package/lib/Table/Body.js +0 -6
- package/lib/Table/Cell.js +4 -24
- package/lib/Table/Header.js +0 -9
- package/lib/Table/Row.js +0 -8
- package/lib/Table/SubHeading.js +0 -9
- package/lib/Table/Table.js +5 -23
- package/lib/Table/index.js +0 -8
- package/lib/TermsAndConditions/ExpandCollapse.js +4 -14
- package/lib/TermsAndConditions/TermsAndConditions.js +7 -29
- package/lib/TermsAndConditions/index.js +0 -2
- package/lib/Testimonial/Testimonial.js +2 -26
- package/lib/Testimonial/index.js +0 -3
- package/lib/Toast/Toast.js +4 -25
- package/lib/Toast/index.js +0 -3
- package/lib/Video/ControlBar/ControlBar.js +2 -25
- package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +4 -17
- package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +4 -20
- package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +12 -26
- package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +8 -23
- package/lib/Video/MiddleControlButton/MiddleControlButton.js +2 -12
- package/lib/Video/Video.js +122 -194
- package/lib/Video/index.js +0 -3
- package/lib/VideoPicker/VideoPicker.js +6 -32
- package/lib/VideoPicker/VideoPickerPlayer.js +2 -10
- package/lib/VideoPicker/VideoPickerThumbnail.js +7 -28
- package/lib/VideoPicker/VideoSlider.js +7 -17
- package/lib/VideoPicker/index.js +0 -3
- package/lib/VideoPicker/videoPropType.js +2 -8
- package/lib/WaffleGrid/WaffleGrid.js +11 -28
- package/lib/WaffleGrid/index.js +0 -3
- package/lib/WebPortal/WebPortal.js +1 -5
- package/lib/WebPortal/index.js +0 -3
- package/lib/WebVideo/WebVideo.js +4 -30
- package/lib/WebVideo/index.js +0 -3
- package/lib/baseExports.js +6 -1
- package/lib/index.js +0 -49
- package/lib/shared/FullBleedContent/FullBleedContent.js +5 -17
- package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +0 -11
- package/lib/shared/FullBleedContent/index.js +0 -5
- package/lib/shared/FullBleedContent/useFullBleedContentProps.js +1 -12
- package/lib/shared/VideoSplash/SplashButton/SplashButton.js +2 -12
- package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +7 -23
- package/lib/shared/VideoSplash/VideoSplash.js +4 -17
- package/lib/shared/VideoSplash/helpers.js +0 -6
- package/lib/utils/index.js +0 -9
- package/lib/utils/logger.js +0 -6
- package/lib/utils/media.js +2 -11
- package/lib/utils/renderStructuredContent.js +14 -31
- package/lib/utils/ssr.js +0 -6
- package/lib/utils/transforms.js +0 -2
- package/lib/utils/useOverlaidPosition.js +6 -28
- package/lib/utils/useTypographyTheme.js +4 -5
- package/lib-module/Badge/Badge.js +2 -5
- package/lib-module/BlockQuote/BlockQuote.js +4 -15
- package/lib-module/Breadcrumbs/Breadcrumbs.js +9 -25
- package/lib-module/Breadcrumbs/Item/Item.js +15 -12
- package/lib-module/Callout/Callout.js +2 -16
- package/lib-module/Card/Card.js +14 -17
- package/lib-module/Card/CardContent.js +5 -8
- package/lib-module/Card/CardFooter.js +7 -9
- package/lib-module/Countdown/Countdown.js +6 -11
- package/lib-module/Countdown/Segment.js +6 -8
- package/lib-module/Countdown/types.js +2 -1
- package/lib-module/Countdown/useCountdown.js +0 -6
- package/lib-module/DatePicker/CalendarContainer.js +3 -1
- package/lib-module/DatePicker/DatePicker.js +9 -39
- package/lib-module/DatePicker/dictionary.js +0 -8
- package/lib-module/Disclaimer/Disclaimer.js +5 -4
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +6 -8
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +13 -19
- package/lib-module/Footnote/Footnote.js +17 -41
- package/lib-module/Footnote/FootnoteLink.js +3 -12
- package/lib-module/IconButton/IconButton.js +4 -6
- package/lib-module/Image/Image.js +5 -14
- package/lib-module/NavigationBar/NavigationBar.js +10 -20
- package/lib-module/NavigationBar/NavigationItem.js +5 -5
- package/lib-module/NavigationBar/NavigationSubMenu.js +3 -8
- package/lib-module/NavigationBar/collapseItems.js +6 -8
- package/lib-module/NavigationBar/resolveItemSelection.js +2 -2
- package/lib-module/OptimizeImage/OptimizeImage.js +6 -16
- package/lib-module/OptimizeImage/utils/getFallbackUrl.js +0 -1
- package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +0 -5
- package/lib-module/OptimizeImage/utils/hasWebpSupport.js +1 -5
- package/lib-module/OrderedList/Item.js +4 -7
- package/lib-module/OrderedList/ItemBase.js +2 -3
- package/lib-module/OrderedList/OrderedList.js +11 -9
- package/lib-module/OrderedList/OrderedListBase.js +3 -3
- package/lib-module/Paragraph/Paragraph.js +3 -8
- package/lib-module/PreviewCard/AuthorDate.js +1 -4
- package/lib-module/PreviewCard/PreviewCard.js +16 -19
- package/lib-module/PriceLockup/PriceLockup.js +78 -57
- package/lib-module/Progress/ProgressBar.js +7 -8
- package/lib-module/QuantitySelector/QuantitySelector.js +8 -30
- package/lib-module/QuantitySelector/SideButton.js +4 -6
- package/lib-module/ResponsiveImage/ResponsiveImage.js +5 -12
- package/lib-module/Ribbon/Ribbon.js +4 -9
- package/lib-module/SkeletonProvider/SkeletonImage.js +0 -5
- package/lib-module/SkeletonProvider/SkeletonProvider.js +4 -12
- package/lib-module/SkeletonProvider/SkeletonTypography.js +0 -5
- package/lib-module/Span/Span.js +3 -7
- package/lib-module/Spinner/Spinner.js +11 -24
- package/lib-module/Spinner/SpinnerContent.js +2 -8
- package/lib-module/StoryCard/StoryCard.js +12 -17
- package/lib-module/Table/Body.js +0 -2
- package/lib-module/Table/Cell.js +4 -14
- package/lib-module/Table/Header.js +0 -2
- package/lib-module/Table/Row.js +0 -2
- package/lib-module/Table/SubHeading.js +0 -2
- package/lib-module/Table/Table.js +5 -6
- package/lib-module/TermsAndConditions/ExpandCollapse.js +4 -2
- package/lib-module/TermsAndConditions/TermsAndConditions.js +7 -9
- package/lib-module/Testimonial/Testimonial.js +2 -11
- package/lib-module/Toast/Toast.js +4 -15
- package/lib-module/Video/ControlBar/ControlBar.js +2 -9
- package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +4 -8
- package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +4 -8
- package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +12 -13
- package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +8 -10
- package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +2 -3
- package/lib-module/Video/Video.js +122 -173
- package/lib-module/VideoPicker/VideoPicker.js +6 -15
- package/lib-module/VideoPicker/VideoPickerPlayer.js +2 -3
- package/lib-module/VideoPicker/VideoPickerThumbnail.js +7 -13
- package/lib-module/VideoPicker/VideoSlider.js +6 -9
- package/lib-module/VideoPicker/videoPropType.js +2 -1
- package/lib-module/WaffleGrid/WaffleGrid.js +11 -15
- package/lib-module/WebPortal/WebPortal.js +1 -1
- package/lib-module/WebVideo/WebVideo.js +4 -15
- package/lib-module/baseExports.js +3 -2
- package/lib-module/index.js +0 -1
- package/lib-module/shared/FullBleedContent/FullBleedContent.js +5 -10
- package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +0 -10
- package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +1 -11
- package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +2 -3
- package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +7 -12
- package/lib-module/shared/VideoSplash/VideoSplash.js +4 -4
- package/lib-module/utils/logger.js +2 -2
- package/lib-module/utils/media.js +2 -9
- package/lib-module/utils/renderStructuredContent.js +14 -25
- package/lib-module/utils/ssr.js +0 -4
- package/lib-module/utils/useOverlaidPosition.js +8 -27
- package/lib-module/utils/useTypographyTheme.js +4 -4
- package/package.json +3 -3
- package/src/PriceLockup/PriceLockup.jsx +36 -11
- package/src/baseExports.js +1 -0
- package/src/index.js +0 -1
- package/lib/Modal/Modal.js +0 -146
- package/lib/Modal/ModalContent.js +0 -203
- package/lib/Modal/index.js +0 -13
- package/lib-module/Modal/Modal.js +0 -132
- package/lib-module/Modal/ModalContent.js +0 -181
- package/lib-module/Modal/index.js +0 -2
- package/src/Modal/Modal.jsx +0 -121
- package/src/Modal/ModalContent.jsx +0 -167
- package/src/Modal/index.js +0 -3
package/src/Modal/Modal.jsx
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Modal as BaseModal } from '@telus-uds/components-base'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
import ModalContent from './ModalContent'
|
|
5
|
-
|
|
6
|
-
const Modal = ({
|
|
7
|
-
children,
|
|
8
|
-
isOpen,
|
|
9
|
-
onClose,
|
|
10
|
-
maxWidth,
|
|
11
|
-
onCancel = onClose,
|
|
12
|
-
onConfirm,
|
|
13
|
-
heading,
|
|
14
|
-
headingLevel,
|
|
15
|
-
subHeading,
|
|
16
|
-
subHeadingSize,
|
|
17
|
-
bodyText,
|
|
18
|
-
tokens,
|
|
19
|
-
variant = {},
|
|
20
|
-
confirmButtonText,
|
|
21
|
-
confirmButtonVariant,
|
|
22
|
-
cancelButtonText,
|
|
23
|
-
cancelButtonType,
|
|
24
|
-
...nonContentProps
|
|
25
|
-
}) => {
|
|
26
|
-
return (
|
|
27
|
-
<BaseModal
|
|
28
|
-
isOpen={isOpen}
|
|
29
|
-
onClose={onClose}
|
|
30
|
-
variant={variant}
|
|
31
|
-
maxWidth={maxWidth}
|
|
32
|
-
{...nonContentProps}
|
|
33
|
-
>
|
|
34
|
-
<ModalContent
|
|
35
|
-
tokens={tokens}
|
|
36
|
-
variant={variant}
|
|
37
|
-
onCancel={onCancel}
|
|
38
|
-
onConfirm={onConfirm}
|
|
39
|
-
heading={heading}
|
|
40
|
-
headingLevel={headingLevel}
|
|
41
|
-
subHeading={subHeading}
|
|
42
|
-
subHeadingSize={subHeadingSize}
|
|
43
|
-
bodyText={bodyText}
|
|
44
|
-
confirmButtonText={confirmButtonText}
|
|
45
|
-
confirmButtonVariant={confirmButtonVariant}
|
|
46
|
-
cancelButtonText={cancelButtonText}
|
|
47
|
-
cancelButtonType={cancelButtonType}
|
|
48
|
-
>
|
|
49
|
-
{children}
|
|
50
|
-
</ModalContent>
|
|
51
|
-
</BaseModal>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
Modal.propTypes = {
|
|
56
|
-
children: PropTypes.node,
|
|
57
|
-
tokens: PropTypes.object,
|
|
58
|
-
variant: PropTypes.object,
|
|
59
|
-
/**
|
|
60
|
-
* If true, the modal overlay covers the page and the modal content is shown
|
|
61
|
-
*/
|
|
62
|
-
isOpen: PropTypes.bool,
|
|
63
|
-
/**
|
|
64
|
-
* Function called on pressing the Modal close "x" button
|
|
65
|
-
*/
|
|
66
|
-
onClose: PropTypes.func,
|
|
67
|
-
/**
|
|
68
|
-
* If true, Modal is rendered with the 'maxWidth' appearance applied.
|
|
69
|
-
* Use this for wider content, such as content with long headers.
|
|
70
|
-
*/
|
|
71
|
-
maxWidth: PropTypes.bool,
|
|
72
|
-
/**
|
|
73
|
-
* Heading text shown prominently with heading semantic tags.
|
|
74
|
-
*/
|
|
75
|
-
heading: PropTypes.string,
|
|
76
|
-
/**
|
|
77
|
-
* Stylistic size and semantic level of the modal heading
|
|
78
|
-
*/
|
|
79
|
-
headingLevel: PropTypes.oneOf(['h3', 'h4']),
|
|
80
|
-
/**
|
|
81
|
-
* Short content rendered below the heading. If there is long body content that is scrollable,
|
|
82
|
-
* the subHeading sits above the scrollable area.
|
|
83
|
-
*/
|
|
84
|
-
subHeading: PropTypes.string,
|
|
85
|
-
/**
|
|
86
|
-
* Short content rendered below the heading. If there is long body content that is scrollable,
|
|
87
|
-
* the subHeading sits above the scrollable area.
|
|
88
|
-
*/
|
|
89
|
-
subHeadingSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
90
|
-
/**
|
|
91
|
-
* If the modal requires longer text, include it here. This text will become scrollable if it
|
|
92
|
-
* is too long for the allowed height of the modal.
|
|
93
|
-
*/
|
|
94
|
-
bodyText: PropTypes.string,
|
|
95
|
-
/**
|
|
96
|
-
* Text for the button controlling the primary action of the modal.
|
|
97
|
-
*/
|
|
98
|
-
confirmButtonText: PropTypes.string,
|
|
99
|
-
/**
|
|
100
|
-
* Button variant object to be passed through to Button to choose its visual style.
|
|
101
|
-
*/
|
|
102
|
-
confirmButtonVariant: PropTypes.object,
|
|
103
|
-
/**
|
|
104
|
-
* Action on pressing the confirm button.
|
|
105
|
-
*/
|
|
106
|
-
onConfirm: PropTypes.func,
|
|
107
|
-
/**
|
|
108
|
-
* Text for the optional cancel button provided if the user does not want to do the confirm action.
|
|
109
|
-
*/
|
|
110
|
-
cancelButtonText: PropTypes.string,
|
|
111
|
-
/**
|
|
112
|
-
* Component to use for the cancel button (default: `TextButton`). Should accept similar props to `TextButton`.
|
|
113
|
-
*/
|
|
114
|
-
cancelButtonType: PropTypes.elementType,
|
|
115
|
-
/**
|
|
116
|
-
* Action to perform on pressing the cancel button. Defaults to `onClose` action if undefined.
|
|
117
|
-
*/
|
|
118
|
-
onCancel: PropTypes.func
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export default Modal
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Box,
|
|
4
|
-
Button,
|
|
5
|
-
Spacer,
|
|
6
|
-
TextButton,
|
|
7
|
-
Typography,
|
|
8
|
-
useThemeTokens,
|
|
9
|
-
useViewport
|
|
10
|
-
} from '@telus-uds/components-base'
|
|
11
|
-
import styled from 'styled-components'
|
|
12
|
-
import PropTypes from 'prop-types'
|
|
13
|
-
|
|
14
|
-
const StyledModalContent = styled.div`
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
min-height: 100%;
|
|
18
|
-
`
|
|
19
|
-
|
|
20
|
-
const StyledHeading = styled.header`
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
padding-right: ${({ paddingRight }) => paddingRight}px;
|
|
24
|
-
`
|
|
25
|
-
|
|
26
|
-
const StyledSubHeading = styled.div`
|
|
27
|
-
margin-top: ${({ marginTop }) => marginTop}px;
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
const StyledTextButtonContainer = styled.div({
|
|
31
|
-
display: 'flex'
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const StyledFooter = styled.footer(
|
|
35
|
-
({
|
|
36
|
-
hasBorder,
|
|
37
|
-
viewport,
|
|
38
|
-
paddingLeft,
|
|
39
|
-
paddingRight,
|
|
40
|
-
paddingTop,
|
|
41
|
-
marginLeft,
|
|
42
|
-
marginRight,
|
|
43
|
-
borderColor,
|
|
44
|
-
gap
|
|
45
|
-
}) => ({
|
|
46
|
-
display: 'flex',
|
|
47
|
-
flexDirection: viewport === 'xs' || viewport === 'sm' ? 'column' : 'row',
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
gap: `${gap}px`,
|
|
50
|
-
marginLeft: `calc(-1 * ${marginLeft}px)`,
|
|
51
|
-
marginRight: `calc(-1 * ${marginRight}px)`,
|
|
52
|
-
paddingLeft: `${paddingLeft}px`,
|
|
53
|
-
paddingRight: `${paddingRight}px`,
|
|
54
|
-
paddingTop: `${paddingTop}px`,
|
|
55
|
-
borderTop: hasBorder ? `1px solid ${borderColor}` : 'none'
|
|
56
|
-
})
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
const ModalContent = ({
|
|
60
|
-
heading,
|
|
61
|
-
headingLevel = 'h3',
|
|
62
|
-
subHeading,
|
|
63
|
-
subHeadingSize = 'medium',
|
|
64
|
-
bodyText,
|
|
65
|
-
confirmButtonText,
|
|
66
|
-
confirmButtonVariant = { priority: 'high' },
|
|
67
|
-
onConfirm,
|
|
68
|
-
tokens,
|
|
69
|
-
variant,
|
|
70
|
-
cancelButtonText,
|
|
71
|
-
cancelButtonType: CancelButton = TextButton,
|
|
72
|
-
children,
|
|
73
|
-
onCancel
|
|
74
|
-
}) => {
|
|
75
|
-
const { headingColor, cancelButtonColor, ...themeTokens } = useThemeTokens(
|
|
76
|
-
'Modal',
|
|
77
|
-
tokens,
|
|
78
|
-
variant
|
|
79
|
-
)
|
|
80
|
-
const [scrollContainerHeight, setScrollContainerHeight] = useState(0)
|
|
81
|
-
const [scrollContentHeight, setScrollContentHeight] = useState(0)
|
|
82
|
-
const viewport = useViewport()
|
|
83
|
-
|
|
84
|
-
const handleContainerLayout = ({
|
|
85
|
-
nativeEvent: {
|
|
86
|
-
layout: { height }
|
|
87
|
-
}
|
|
88
|
-
}) => setScrollContainerHeight(height)
|
|
89
|
-
const onContentSizeChange = (_, height) => setScrollContentHeight(height)
|
|
90
|
-
const isContentOverflowing = scrollContentHeight > scrollContainerHeight
|
|
91
|
-
|
|
92
|
-
const hasConfirmButton = confirmButtonText !== undefined && onConfirm !== undefined
|
|
93
|
-
const hasCancelButton = cancelButtonText !== undefined && onCancel !== undefined
|
|
94
|
-
const hasHeadingSection = Boolean(heading || subHeading)
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<StyledModalContent>
|
|
98
|
-
{hasHeadingSection && (
|
|
99
|
-
<StyledHeading paddingRight={themeTokens.headingPaddingRight}>
|
|
100
|
-
{heading && (
|
|
101
|
-
<Typography
|
|
102
|
-
variant={{ size: headingLevel }}
|
|
103
|
-
tokens={{ color: headingColor }}
|
|
104
|
-
heading={headingLevel}
|
|
105
|
-
>
|
|
106
|
-
{heading}
|
|
107
|
-
</Typography>
|
|
108
|
-
)}
|
|
109
|
-
{subHeading && (
|
|
110
|
-
<StyledSubHeading marginTop={themeTokens.subHeadingMarginTop}>
|
|
111
|
-
<Typography variant={{ size: subHeadingSize }}>{subHeading}</Typography>
|
|
112
|
-
</StyledSubHeading>
|
|
113
|
-
)}
|
|
114
|
-
{Boolean(bodyText && hasHeadingSection) && <Spacer space={3} />}
|
|
115
|
-
</StyledHeading>
|
|
116
|
-
)}
|
|
117
|
-
{bodyText && (
|
|
118
|
-
<Box
|
|
119
|
-
scroll={{ onContentSizeChange, showsVerticalScrollIndicator: true }}
|
|
120
|
-
onLayout={handleContainerLayout}
|
|
121
|
-
>
|
|
122
|
-
<Typography>{bodyText}</Typography>
|
|
123
|
-
</Box>
|
|
124
|
-
)}
|
|
125
|
-
{children}
|
|
126
|
-
{(hasConfirmButton || hasCancelButton) && (
|
|
127
|
-
<StyledFooter {...themeTokens} hasBorder={isContentOverflowing} viewport={viewport}>
|
|
128
|
-
{hasConfirmButton && (
|
|
129
|
-
<Button
|
|
130
|
-
variant={confirmButtonVariant}
|
|
131
|
-
tokens={{ width: viewport === 'xs' || viewport === 'sm' ? '100%' : undefined }}
|
|
132
|
-
onPress={onConfirm}
|
|
133
|
-
>
|
|
134
|
-
{confirmButtonText}
|
|
135
|
-
</Button>
|
|
136
|
-
)}
|
|
137
|
-
{hasCancelButton ? (
|
|
138
|
-
<StyledTextButtonContainer>
|
|
139
|
-
<CancelButton tokens={{ color: cancelButtonColor }} onPress={onCancel}>
|
|
140
|
-
{cancelButtonText}
|
|
141
|
-
</CancelButton>
|
|
142
|
-
</StyledTextButtonContainer>
|
|
143
|
-
) : null}
|
|
144
|
-
</StyledFooter>
|
|
145
|
-
)}
|
|
146
|
-
</StyledModalContent>
|
|
147
|
-
)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
ModalContent.propTypes = {
|
|
151
|
-
tokens: PropTypes.object,
|
|
152
|
-
variant: PropTypes.object,
|
|
153
|
-
heading: PropTypes.string,
|
|
154
|
-
headingLevel: PropTypes.oneOf(['h3', 'h4']),
|
|
155
|
-
subHeading: PropTypes.string,
|
|
156
|
-
subHeadingSize: PropTypes.oneOf(['small', 'medium', 'large']),
|
|
157
|
-
bodyText: PropTypes.string,
|
|
158
|
-
confirmButtonText: PropTypes.string,
|
|
159
|
-
confirmButtonVariant: PropTypes.object,
|
|
160
|
-
onConfirm: PropTypes.func,
|
|
161
|
-
cancelButtonText: PropTypes.string,
|
|
162
|
-
cancelButtonType: PropTypes.elementType, // TODO: figure out a way of passing an icon to the TextButton
|
|
163
|
-
children: PropTypes.node,
|
|
164
|
-
onCancel: PropTypes.func
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export default ModalContent
|
package/src/Modal/index.js
DELETED