@telus-uds/components-web 2.33.2 → 2.34.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/CHANGELOG.md +29 -3
- package/lib/Badge/Badge.js +4 -2
- package/lib/BlockQuote/BlockQuote.js +4 -2
- package/lib/Breadcrumbs/Breadcrumbs.js +7 -5
- package/lib/Breadcrumbs/Item/Item.js +2 -13
- package/lib/Callout/Callout.js +4 -2
- package/lib/Card/Card.js +3 -5
- package/lib/Card/CardContent.js +4 -2
- package/lib/Countdown/Countdown.js +2 -6
- package/lib/Countdown/Segment.js +4 -2
- package/lib/DatePicker/CalendarContainer.js +2 -2
- package/lib/DatePicker/DatePicker.js +21 -35
- package/lib/Disclaimer/Disclaimer.js +4 -2
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +5 -11
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +4 -2
- package/lib/Footnote/Footnote.js +32 -37
- package/lib/Footnote/FootnoteLink.js +9 -6
- package/lib/IconButton/IconButton.js +4 -11
- package/lib/Image/Image.js +5 -3
- package/lib/List/ListItem.js +2 -7
- package/lib/NavigationBar/NavigationBar.js +8 -18
- package/lib/NavigationBar/NavigationItem.js +4 -9
- package/lib/NavigationBar/NavigationSubMenu.js +8 -7
- package/lib/NavigationBar/index.js +2 -0
- package/lib/OptimizeImage/OptimizeImage.js +8 -8
- package/lib/OrderedList/Item.js +3 -9
- package/lib/OrderedList/OrderedList.js +5 -13
- package/lib/OrderedList/OrderedListBase.js +3 -8
- package/lib/Paragraph/Paragraph.js +5 -3
- package/lib/PreviewCard/PreviewCard.js +3 -5
- package/lib/PriceLockup/PriceLockup.js +4 -2
- package/lib/Progress/ProgressBar.js +4 -2
- package/lib/QuantitySelector/QuantitySelector.js +21 -24
- package/lib/QuantitySelector/SideButton.js +12 -20
- package/lib/ResponsiveImage/ResponsiveImage.js +4 -2
- package/lib/Ribbon/Ribbon.js +4 -2
- package/lib/SkeletonProvider/SkeletonImage.js +5 -3
- package/lib/SkeletonProvider/SkeletonProvider.js +3 -5
- package/lib/SkeletonProvider/SkeletonTypography.js +5 -3
- package/lib/Span/Span.js +5 -3
- package/lib/Spinner/Spinner.js +4 -2
- package/lib/Spinner/SpinnerContent.js +4 -2
- package/lib/StoryCard/StoryCard.js +3 -5
- package/lib/Table/Body.js +4 -2
- package/lib/Table/Cell.js +5 -3
- package/lib/Table/Header.js +6 -6
- package/lib/Table/Row.js +6 -6
- package/lib/Table/SubHeading.js +6 -6
- package/lib/Table/Table.js +6 -8
- package/lib/TermsAndConditions/ExpandCollapse.js +2 -7
- package/lib/TermsAndConditions/TermsAndConditions.js +5 -14
- package/lib/Testimonial/Testimonial.js +4 -2
- package/lib/Toast/Toast.js +4 -2
- package/lib/Video/Video.js +19 -55
- package/lib/VideoPicker/VideoPicker.js +38 -9
- package/lib/VideoPicker/VideoPickerPlayer.js +4 -2
- package/lib/VideoPicker/VideoPickerThumbnail.js +4 -2
- package/lib/VideoPicker/VideoSlider.js +7 -7
- package/lib/WaffleGrid/WaffleGrid.js +4 -2
- package/lib/WebVideo/WebVideo.js +51 -13
- package/lib/WebVideo/utils/index.js +58 -0
- package/lib/baseExports.js +6 -0
- package/lib/utils/theming/with-client-theme.js +1 -1
- package/lib/utils/theming/with-server-theme.js +1 -1
- package/lib-module/Badge/Badge.js +4 -2
- package/lib-module/BlockQuote/BlockQuote.js +4 -2
- package/lib-module/Breadcrumbs/Breadcrumbs.js +7 -5
- package/lib-module/Breadcrumbs/Item/Item.js +2 -11
- package/lib-module/Callout/Callout.js +4 -2
- package/lib-module/Card/Card.js +2 -3
- package/lib-module/Card/CardContent.js +4 -2
- package/lib-module/Countdown/Countdown.js +2 -3
- package/lib-module/Countdown/Segment.js +4 -2
- package/lib-module/DatePicker/CalendarContainer.js +2 -2
- package/lib-module/DatePicker/DatePicker.js +21 -33
- package/lib-module/Disclaimer/Disclaimer.js +4 -2
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +5 -9
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +4 -2
- package/lib-module/Footnote/Footnote.js +31 -36
- package/lib-module/Footnote/FootnoteLink.js +9 -7
- package/lib-module/IconButton/IconButton.js +4 -9
- package/lib-module/Image/Image.js +5 -3
- package/lib-module/List/ListItem.js +2 -5
- package/lib-module/NavigationBar/NavigationBar.js +9 -17
- package/lib-module/NavigationBar/NavigationItem.js +5 -8
- package/lib-module/NavigationBar/NavigationSubMenu.js +9 -6
- package/lib-module/NavigationBar/index.js +2 -0
- package/lib-module/OptimizeImage/OptimizeImage.js +8 -6
- package/lib-module/OrderedList/Item.js +3 -7
- package/lib-module/OrderedList/OrderedList.js +6 -12
- package/lib-module/OrderedList/OrderedListBase.js +3 -6
- package/lib-module/Paragraph/Paragraph.js +6 -4
- package/lib-module/PreviewCard/PreviewCard.js +2 -3
- package/lib-module/PriceLockup/PriceLockup.js +4 -2
- package/lib-module/Progress/ProgressBar.js +4 -2
- package/lib-module/QuantitySelector/QuantitySelector.js +22 -23
- package/lib-module/QuantitySelector/SideButton.js +13 -21
- package/lib-module/ResponsiveImage/ResponsiveImage.js +4 -2
- package/lib-module/Ribbon/Ribbon.js +4 -2
- package/lib-module/SkeletonProvider/SkeletonImage.js +5 -3
- package/lib-module/SkeletonProvider/SkeletonProvider.js +3 -3
- package/lib-module/SkeletonProvider/SkeletonTypography.js +5 -3
- package/lib-module/Span/Span.js +6 -4
- package/lib-module/Spinner/Spinner.js +4 -2
- package/lib-module/Spinner/SpinnerContent.js +4 -2
- package/lib-module/StoryCard/StoryCard.js +2 -3
- package/lib-module/Table/Body.js +4 -2
- package/lib-module/Table/Cell.js +5 -3
- package/lib-module/Table/Header.js +6 -4
- package/lib-module/Table/Row.js +6 -4
- package/lib-module/Table/SubHeading.js +6 -4
- package/lib-module/Table/Table.js +6 -6
- package/lib-module/TermsAndConditions/ExpandCollapse.js +2 -5
- package/lib-module/TermsAndConditions/TermsAndConditions.js +5 -12
- package/lib-module/Testimonial/Testimonial.js +4 -2
- package/lib-module/Toast/Toast.js +4 -2
- package/lib-module/Video/Video.js +19 -53
- package/lib-module/VideoPicker/VideoPicker.js +37 -8
- package/lib-module/VideoPicker/VideoPickerPlayer.js +4 -2
- package/lib-module/VideoPicker/VideoPickerThumbnail.js +4 -2
- package/lib-module/VideoPicker/VideoSlider.js +7 -5
- package/lib-module/WaffleGrid/WaffleGrid.js +4 -2
- package/lib-module/WebVideo/WebVideo.js +51 -11
- package/lib-module/WebVideo/utils/index.js +50 -0
- package/lib-module/baseExports.js +1 -1
- package/lib-module/utils/theming/with-client-theme.js +2 -2
- package/lib-module/utils/theming/with-server-theme.js +2 -2
- package/package.json +3 -3
- package/src/Badge/Badge.jsx +5 -2
- package/src/BlockQuote/BlockQuote.jsx +120 -112
- package/src/Breadcrumbs/Breadcrumbs.jsx +84 -77
- package/src/Breadcrumbs/Item/Item.jsx +2 -9
- package/src/Callout/Callout.jsx +37 -40
- package/src/Card/Card.jsx +2 -3
- package/src/Card/CardContent.jsx +19 -14
- package/src/Countdown/Countdown.jsx +72 -71
- package/src/Countdown/Segment.jsx +40 -28
- package/src/DatePicker/CalendarContainer.jsx +2 -2
- package/src/DatePicker/DatePicker.jsx +21 -34
- package/src/Disclaimer/Disclaimer.jsx +5 -3
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +37 -40
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +52 -44
- package/src/Footnote/Footnote.jsx +32 -38
- package/src/Footnote/FootnoteLink.jsx +45 -49
- package/src/IconButton/IconButton.jsx +19 -20
- package/src/Image/Image.jsx +40 -43
- package/src/List/ListItem.jsx +3 -5
- package/src/NavigationBar/NavigationBar.jsx +9 -18
- package/src/NavigationBar/NavigationItem.jsx +6 -5
- package/src/NavigationBar/NavigationSubMenu.jsx +104 -88
- package/src/NavigationBar/index.js +3 -0
- package/src/OptimizeImage/OptimizeImage.jsx +48 -41
- package/src/OrderedList/Item.jsx +34 -35
- package/src/OrderedList/OrderedList.jsx +4 -6
- package/src/OrderedList/OrderedListBase.jsx +2 -3
- package/src/Paragraph/Paragraph.jsx +21 -16
- package/src/PreviewCard/PreviewCard.jsx +2 -3
- package/src/PriceLockup/PriceLockup.jsx +143 -136
- package/src/Progress/ProgressBar.jsx +11 -3
- package/src/QuantitySelector/QuantitySelector.jsx +162 -154
- package/src/QuantitySelector/SideButton.jsx +52 -56
- package/src/ResponsiveImage/ResponsiveImage.jsx +16 -22
- package/src/Ribbon/Ribbon.jsx +85 -83
- package/src/SkeletonProvider/SkeletonImage.jsx +24 -15
- package/src/SkeletonProvider/SkeletonProvider.jsx +3 -3
- package/src/SkeletonProvider/SkeletonTypography.jsx +18 -13
- package/src/Span/Span.jsx +7 -5
- package/src/Spinner/Spinner.jsx +86 -79
- package/src/Spinner/SpinnerContent.jsx +31 -33
- package/src/StoryCard/StoryCard.jsx +2 -3
- package/src/Table/Body.jsx +5 -3
- package/src/Table/Cell.jsx +77 -67
- package/src/Table/Header.jsx +7 -5
- package/src/Table/Row.jsx +7 -5
- package/src/Table/SubHeading.jsx +7 -5
- package/src/Table/Table.jsx +6 -6
- package/src/TermsAndConditions/ExpandCollapse.jsx +2 -6
- package/src/TermsAndConditions/TermsAndConditions.jsx +5 -13
- package/src/Testimonial/Testimonial.jsx +148 -137
- package/src/Toast/Toast.jsx +68 -63
- package/src/Video/Video.jsx +25 -45
- package/src/VideoPicker/VideoPicker.jsx +114 -75
- package/src/VideoPicker/VideoPickerPlayer.jsx +13 -9
- package/src/VideoPicker/VideoPickerThumbnail.jsx +102 -94
- package/src/VideoPicker/VideoSlider.jsx +8 -6
- package/src/WaffleGrid/WaffleGrid.jsx +36 -40
- package/src/WebVideo/WebVideo.jsx +114 -60
- package/src/WebVideo/utils/index.js +56 -0
- package/src/baseExports.js +1 -0
- package/src/utils/theming/with-client-theme.jsx +2 -2
- package/src/utils/theming/with-server-theme.jsx +2 -2
- package/types/WebVideo.d.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import {
|
|
4
4
|
IconButton as IconButtonBase,
|
|
@@ -6,23 +6,25 @@ import {
|
|
|
6
6
|
getTokensPropType
|
|
7
7
|
} from '@telus-uds/components-base'
|
|
8
8
|
|
|
9
|
-
const IconButton = forwardRef(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const IconButton = React.forwardRef(
|
|
10
|
+
({ icon = null, action, tokens = {}, variant = {}, ...iconButtonProps }, ref) => {
|
|
11
|
+
const variantWithAction = action && !variant.action ? { ...variant, action } : variant
|
|
12
|
+
const { icon: themeIcon } = useThemeTokens('IconButton', tokens, variantWithAction)
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
14
|
+
return (
|
|
15
|
+
// If we want the arrow icons to have directional animation instead of scale, we can pass
|
|
16
|
+
// either appropriate iconTransateX/Y here, or define and pass variants like { direction: 'left' }
|
|
17
|
+
// which have theme rules that set `iconTranslateX` tokens in the theme rules and unset `iconScale`.
|
|
18
|
+
<IconButtonBase
|
|
19
|
+
ref={ref}
|
|
20
|
+
{...iconButtonProps}
|
|
21
|
+
tokens={tokens}
|
|
22
|
+
variant={variant}
|
|
23
|
+
icon={icon ?? themeIcon}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
)
|
|
26
28
|
|
|
27
29
|
const multiBrandIconNames = [
|
|
28
30
|
'add',
|
|
@@ -44,7 +46,6 @@ IconButton.propTypes = {
|
|
|
44
46
|
/**
|
|
45
47
|
* To set the icon to a multi-brand compatabile icon
|
|
46
48
|
*/
|
|
47
|
-
// eslint-disable-next-line react/require-default-props
|
|
48
49
|
action: PropTypes.oneOf(multiBrandIconNames),
|
|
49
50
|
/**
|
|
50
51
|
* To set a custom icon
|
|
@@ -52,6 +53,4 @@ IconButton.propTypes = {
|
|
|
52
53
|
icon: PropTypes.func
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
IconButton.defaultProps = { icon: null, tokens: {} }
|
|
56
|
-
|
|
57
56
|
export default IconButton
|
package/src/Image/Image.jsx
CHANGED
|
@@ -5,53 +5,50 @@ import { warn } from '../utils/logger'
|
|
|
5
5
|
|
|
6
6
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
7
7
|
|
|
8
|
-
const Image = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
variant,
|
|
18
|
-
...rest
|
|
19
|
-
}) => {
|
|
20
|
-
let { borderRadius } = theme
|
|
21
|
-
const isCircle = rounded === 'circle'
|
|
22
|
-
const isCorners = rounded === 'corners'
|
|
23
|
-
const isSquare = width === height
|
|
8
|
+
const Image = React.forwardRef(
|
|
9
|
+
(
|
|
10
|
+
{ src, width, height, alt, rounded, loading = 'eager', tokens, theme, variant, ...rest },
|
|
11
|
+
ref
|
|
12
|
+
) => {
|
|
13
|
+
let { borderRadius } = theme
|
|
14
|
+
const isCircle = rounded === 'circle'
|
|
15
|
+
const isCorners = rounded === 'corners'
|
|
16
|
+
const isSquare = width === height
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
if (isCircle && !isSquare) {
|
|
19
|
+
warn(
|
|
20
|
+
'Image',
|
|
21
|
+
'rounded="circle" is not supported for non-square images. Please provide a square image, otherwise the resulting shape will not be a circle.'
|
|
22
|
+
)
|
|
23
|
+
}
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
if (isCircle) {
|
|
26
|
+
borderRadius = '50%'
|
|
27
|
+
} else if (isCorners) {
|
|
28
|
+
borderRadius = '4px'
|
|
29
|
+
}
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
const style = {
|
|
32
|
+
borderRadius,
|
|
33
|
+
height: height ?? 'auto',
|
|
34
|
+
maxWidth: '100%'
|
|
35
|
+
}
|
|
36
|
+
return (
|
|
37
|
+
<img
|
|
38
|
+
{...selectProps(rest)}
|
|
39
|
+
style={style}
|
|
40
|
+
src={src}
|
|
41
|
+
width={width}
|
|
42
|
+
height={height}
|
|
43
|
+
alt={alt}
|
|
44
|
+
loading={loading}
|
|
45
|
+
ref={ref}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
42
48
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
style={style}
|
|
47
|
-
src={src}
|
|
48
|
-
width={width}
|
|
49
|
-
height={height}
|
|
50
|
-
alt={alt}
|
|
51
|
-
loading={loading}
|
|
52
|
-
/>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
Image.displayName = 'Image'
|
|
55
52
|
|
|
56
53
|
Image.propTypes = {
|
|
57
54
|
...selectedSystemPropTypes,
|
package/src/List/ListItem.jsx
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { ListItem as ListItemBase, Typography } from '@telus-uds/components-base'
|
|
4
4
|
|
|
5
|
-
const ListItem = forwardRef(({ children, title, ...rest }, ref) => (
|
|
5
|
+
const ListItem = React.forwardRef(({ children, title, ...rest }, ref) => (
|
|
6
6
|
<ListItemBase ref={ref} {...rest}>
|
|
7
7
|
{Boolean(title) && <Typography variant={{ size: 'h4' }}>{title}</Typography>}
|
|
8
8
|
{children}
|
|
9
9
|
</ListItemBase>
|
|
10
10
|
))
|
|
11
|
+
|
|
11
12
|
ListItem.displayName = 'ListItem'
|
|
12
13
|
|
|
13
14
|
ListItem.propTypes = {
|
|
14
15
|
children: PropTypes.node.isRequired,
|
|
15
16
|
title: PropTypes.string
|
|
16
17
|
}
|
|
17
|
-
ListItem.defaultProps = {
|
|
18
|
-
title: undefined
|
|
19
|
-
}
|
|
20
18
|
|
|
21
19
|
export default ListItem
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import {
|
|
4
4
|
selectSystemProps,
|
|
5
5
|
StackView,
|
|
6
6
|
Typography,
|
|
7
7
|
useResponsiveProp,
|
|
8
|
-
withLinkRouter
|
|
9
|
-
getTokensPropType
|
|
8
|
+
withLinkRouter
|
|
10
9
|
} from '@telus-uds/components-base'
|
|
11
10
|
import styled from 'styled-components'
|
|
12
11
|
import { htmlAttrs } from '../utils'
|
|
@@ -28,7 +27,7 @@ const Heading = styled.div({
|
|
|
28
27
|
* NavigationBar can be used to allow customers to consistently navigate across
|
|
29
28
|
* key pages within a specific product line
|
|
30
29
|
*/
|
|
31
|
-
const NavigationBar = forwardRef(
|
|
30
|
+
const NavigationBar = React.forwardRef(
|
|
32
31
|
(
|
|
33
32
|
{
|
|
34
33
|
accessibilityRole = 'navigation',
|
|
@@ -45,8 +44,8 @@ const NavigationBar = forwardRef(
|
|
|
45
44
|
) => {
|
|
46
45
|
const direction = useResponsiveProp({ xs: 'column', sm: 'row' })
|
|
47
46
|
const itemsForViewport = useResponsiveProp({ xs: collapseItems(items, selectedId), lg: items })
|
|
48
|
-
const openOverlayRef = useRef(null)
|
|
49
|
-
const [openSubMenuId, setOpenSubMenuId] = useState(null)
|
|
47
|
+
const openOverlayRef = React.useRef(null)
|
|
48
|
+
const [openSubMenuId, setOpenSubMenuId] = React.useState(null)
|
|
50
49
|
const handleSubMenuClose = (event) => {
|
|
51
50
|
if (event.type === 'keydown') {
|
|
52
51
|
if (event.key === 'Escape' || event.key === 27) {
|
|
@@ -69,12 +68,12 @@ const NavigationBar = forwardRef(
|
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
const navRefDefault = useRef(null)
|
|
71
|
+
const navRefDefault = React.useRef(null)
|
|
73
72
|
const navRef = ref ?? navRefDefault
|
|
74
|
-
const itemsRef = useRef(null)
|
|
73
|
+
const itemsRef = React.useRef(null)
|
|
75
74
|
|
|
76
75
|
// Close the submenu when the user clicks outside the navigation bar
|
|
77
|
-
const handleMouseDown = useCallback(
|
|
76
|
+
const handleMouseDown = React.useCallback(
|
|
78
77
|
(event) => {
|
|
79
78
|
if (navRef.current && itemsRef.current) {
|
|
80
79
|
// Get the bounding rectangles of the navigation bar and the items container
|
|
@@ -103,7 +102,7 @@ const NavigationBar = forwardRef(
|
|
|
103
102
|
)
|
|
104
103
|
|
|
105
104
|
// TODO: create a custom hook for that and use here and in the Footnote
|
|
106
|
-
useEffect(() => {
|
|
105
|
+
React.useEffect(() => {
|
|
107
106
|
// Add listeners for mouse clicks outside and for key presses
|
|
108
107
|
document.addEventListener('mousedown', handleMouseDown)
|
|
109
108
|
|
|
@@ -202,7 +201,6 @@ NavigationBar.displayName = 'NavigationBar'
|
|
|
202
201
|
|
|
203
202
|
NavigationBar.propTypes = {
|
|
204
203
|
...selectedSystemPropTypes,
|
|
205
|
-
tokens: getTokensPropType('NavigationBar'),
|
|
206
204
|
...withLinkRouter.propTypes,
|
|
207
205
|
/**
|
|
208
206
|
* NavigationBar pages
|
|
@@ -256,12 +254,5 @@ NavigationBar.propTypes = {
|
|
|
256
254
|
*/
|
|
257
255
|
accessibilityRole: PropTypes.string
|
|
258
256
|
}
|
|
259
|
-
NavigationBar.defaultProps = {
|
|
260
|
-
heading: undefined,
|
|
261
|
-
headingLevel: 'h1',
|
|
262
|
-
onChange: () => {},
|
|
263
|
-
accessibilityRole: '',
|
|
264
|
-
tokens: {}
|
|
265
|
-
}
|
|
266
257
|
|
|
267
258
|
export default NavigationBar
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
5
5
|
selectSystemProps,
|
|
6
6
|
useResponsiveProp,
|
|
7
7
|
useViewport,
|
|
8
|
-
useThemeTokensCallback
|
|
8
|
+
useThemeTokensCallback,
|
|
9
|
+
getTokensPropType
|
|
9
10
|
} from '@telus-uds/components-base'
|
|
10
11
|
import styled from 'styled-components'
|
|
11
12
|
import { htmlAttrs } from '../utils'
|
|
@@ -28,14 +29,14 @@ const ItemContainer = styled.div(({ targetWidth }) => ({
|
|
|
28
29
|
*
|
|
29
30
|
* This is rendered automatically by `NavigationBar` and isn't intended be used directly.
|
|
30
31
|
*/
|
|
31
|
-
const NavigationItem = forwardRef(
|
|
32
|
+
const NavigationItem = React.forwardRef(
|
|
32
33
|
(
|
|
33
34
|
{
|
|
34
35
|
accessibilityRole = 'link', // @todo switch to 'button' for dropdowns
|
|
35
36
|
children,
|
|
36
37
|
id,
|
|
37
38
|
onClick: handleClick = () => {},
|
|
38
|
-
selected,
|
|
39
|
+
selected = false,
|
|
39
40
|
accessibilityState = { current: selected ? 'page' : false },
|
|
40
41
|
href,
|
|
41
42
|
tokens,
|
|
@@ -76,10 +77,10 @@ NavigationItem.displayName = 'NavigationItem'
|
|
|
76
77
|
|
|
77
78
|
NavigationItem.propTypes = {
|
|
78
79
|
...selectedSystemPropTypes,
|
|
80
|
+
tokens: getTokensPropType('NavigationBar'),
|
|
79
81
|
onClick: PropTypes.func,
|
|
80
82
|
selected: PropTypes.bool,
|
|
81
83
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired
|
|
82
84
|
}
|
|
83
|
-
NavigationItem.defaultProps = { onClick: () => {}, selected: false }
|
|
84
85
|
|
|
85
86
|
export default NavigationItem
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Icon,
|
|
5
|
+
useResponsiveProp,
|
|
6
|
+
useThemeTokens,
|
|
7
|
+
Listbox,
|
|
8
|
+
getTokensPropType
|
|
9
|
+
} from '@telus-uds/components-base'
|
|
4
10
|
import NavigationItem from './NavigationItem'
|
|
5
11
|
import useOverlaidPosition from '../utils/useOverlaidPosition'
|
|
6
12
|
import resolveItemSelection from './resolveItemSelection'
|
|
@@ -10,103 +16,113 @@ import resolveItemSelection from './resolveItemSelection'
|
|
|
10
16
|
*
|
|
11
17
|
* This is rendered automatically by `NavigationBar` and isn't intended be used directly.
|
|
12
18
|
*/
|
|
13
|
-
const NavigationSubMenu = (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const NavigationSubMenu = React.forwardRef(
|
|
20
|
+
(
|
|
21
|
+
{
|
|
22
|
+
children,
|
|
23
|
+
id,
|
|
24
|
+
isOpen = false,
|
|
25
|
+
tokens = {},
|
|
26
|
+
label,
|
|
27
|
+
onClick,
|
|
28
|
+
selectedId,
|
|
29
|
+
items = [],
|
|
30
|
+
openOverlayRef,
|
|
31
|
+
LinkRouter,
|
|
32
|
+
linkRouterProps,
|
|
33
|
+
itemsContainerRef
|
|
34
|
+
},
|
|
35
|
+
ref
|
|
36
|
+
) => {
|
|
37
|
+
const focusTrapRef = React.useRef()
|
|
27
38
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
const maxWidth = 289 // Slightly over 288 of nav item to account for subpixel rounding
|
|
40
|
+
const defaultOffsets = { offsets: { vertical: 4 } }
|
|
41
|
+
const { align, offsets, minWidth } = useResponsiveProp({
|
|
42
|
+
xs: { ...defaultOffsets, align: { top: 'bottom', left: 'left' }, minWidth: maxWidth },
|
|
43
|
+
sm: { ...defaultOffsets, align: { top: 'bottom', right: 'right' }, minWidth: maxWidth },
|
|
44
|
+
lg: {
|
|
45
|
+
...defaultOffsets,
|
|
46
|
+
align: { top: 'bottom', center: 'center' },
|
|
47
|
+
minWidth: 192
|
|
48
|
+
}
|
|
49
|
+
})
|
|
39
50
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
const { overlaidPosition, sourceRef, targetRef, onTargetLayout, isReady } = useOverlaidPosition(
|
|
52
|
+
{
|
|
53
|
+
isShown: isOpen,
|
|
54
|
+
offsets,
|
|
55
|
+
align
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
const { selected } = resolveItemSelection({ id, label, items }, selectedId)
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
const handleClick = (event) => {
|
|
61
|
+
if (typeof onClick === 'function') onClick(event)
|
|
62
|
+
}
|
|
50
63
|
|
|
51
|
-
|
|
64
|
+
const { icoMenu } = useThemeTokens('NavigationBar', {}, {}, { expanded: isOpen })
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
]}
|
|
72
|
-
</NavigationItem>
|
|
73
|
-
{isOpen && (
|
|
74
|
-
<>
|
|
75
|
-
<Listbox.Overlay
|
|
76
|
-
overlaidPosition={overlaidPosition}
|
|
77
|
-
maxWidth={maxWidth}
|
|
78
|
-
minWidth={minWidth}
|
|
79
|
-
isReady={isReady}
|
|
80
|
-
onLayout={onTargetLayout}
|
|
81
|
-
ref={openOverlayRef}
|
|
82
|
-
>
|
|
83
|
-
<Listbox
|
|
84
|
-
items={items}
|
|
85
|
-
firstItemRef={targetRef}
|
|
86
|
-
parentRef={sourceRef}
|
|
87
|
-
selectedId={selectedId}
|
|
88
|
-
LinkRouter={LinkRouter}
|
|
89
|
-
linkRouterProps={linkRouterProps}
|
|
90
|
-
ref={itemsContainerRef}
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<NavigationItem
|
|
69
|
+
ref={sourceRef}
|
|
70
|
+
accessibilityRole="button"
|
|
71
|
+
id={id}
|
|
72
|
+
selected={selected}
|
|
73
|
+
onClick={handleClick}
|
|
74
|
+
icon={icoMenu}
|
|
75
|
+
tokens={tokens}
|
|
76
|
+
>
|
|
77
|
+
{({ textStyles }) => [
|
|
78
|
+
children,
|
|
79
|
+
<Icon
|
|
80
|
+
key={`${id}_icon`}
|
|
81
|
+
icon={icoMenu}
|
|
82
|
+
variant={{ size: 'micro' }}
|
|
83
|
+
tokens={{ color: textStyles[0]?.color }}
|
|
91
84
|
/>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
85
|
+
]}
|
|
86
|
+
</NavigationItem>
|
|
87
|
+
{isOpen && (
|
|
88
|
+
<>
|
|
89
|
+
<Listbox.Overlay
|
|
90
|
+
overlaidPosition={overlaidPosition}
|
|
91
|
+
maxWidth={maxWidth}
|
|
92
|
+
minWidth={minWidth}
|
|
93
|
+
isReady={isReady}
|
|
94
|
+
onLayout={onTargetLayout}
|
|
95
|
+
ref={openOverlayRef}
|
|
96
|
+
>
|
|
97
|
+
<Listbox
|
|
98
|
+
items={items}
|
|
99
|
+
firstItemRef={targetRef}
|
|
100
|
+
parentRef={sourceRef}
|
|
101
|
+
selectedId={selectedId}
|
|
102
|
+
LinkRouter={LinkRouter}
|
|
103
|
+
linkRouterProps={linkRouterProps}
|
|
104
|
+
ref={itemsContainerRef || ref}
|
|
105
|
+
/>
|
|
106
|
+
</Listbox.Overlay>
|
|
107
|
+
<div
|
|
108
|
+
// This catches and shifts focus to other interactive elements.
|
|
109
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
110
|
+
tabIndex={0}
|
|
111
|
+
ref={focusTrapRef}
|
|
112
|
+
onFocus={() => targetRef.current.focus()}
|
|
113
|
+
/>
|
|
114
|
+
</>
|
|
115
|
+
)}
|
|
116
|
+
</>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
)
|
|
105
120
|
|
|
106
121
|
NavigationSubMenu.displayName = 'NavigationSubMenu'
|
|
107
122
|
|
|
108
123
|
// @TODO - proper prop types and comments
|
|
109
124
|
NavigationSubMenu.propTypes = {
|
|
125
|
+
tokens: getTokensPropType('NavigationBar'),
|
|
110
126
|
children: PropTypes.node,
|
|
111
127
|
id: PropTypes.string,
|
|
112
128
|
isOpen: PropTypes.bool,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { selectSystemProps } from '@telus-uds/components-base'
|
|
4
4
|
import ResponsiveImage from '../ResponsiveImage'
|
|
@@ -7,48 +7,55 @@ import { htmlAttrs } from '../utils'
|
|
|
7
7
|
|
|
8
8
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
9
9
|
|
|
10
|
-
const OptimizeImage = (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
const OptimizeImage = React.forwardRef(
|
|
11
|
+
(
|
|
12
|
+
{
|
|
13
|
+
contentfulAssetUrl,
|
|
14
|
+
alt,
|
|
15
|
+
quality = 80,
|
|
16
|
+
xs = 320,
|
|
17
|
+
sm = 576,
|
|
18
|
+
md = 768,
|
|
19
|
+
lg = 992,
|
|
20
|
+
xl = 1200,
|
|
21
|
+
sizeByHeight = false,
|
|
22
|
+
disableRetina = false,
|
|
23
|
+
...rest
|
|
24
|
+
},
|
|
25
|
+
ref
|
|
26
|
+
) => {
|
|
27
|
+
// `useHeight` is a deprecated TDS prop, replaced by `sizeByHeight`
|
|
28
|
+
const dimension = sizeByHeight || rest.useHeight ? 'h' : 'w'
|
|
29
|
+
// by default assuming webP support for SSR
|
|
30
|
+
const [imgUrls, setImgUrls] = React.useState(
|
|
31
|
+
getImageUrls(contentfulAssetUrl, dimension, xs, sm, md, lg, xl, quality, disableRetina, true)
|
|
32
|
+
)
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
// Checking for webP support for CSR
|
|
36
|
+
hasWebpSupport().then((supportsWebp) => {
|
|
37
|
+
const imageUrls = getImageUrls(
|
|
38
|
+
contentfulAssetUrl,
|
|
39
|
+
dimension,
|
|
40
|
+
xs,
|
|
41
|
+
sm,
|
|
42
|
+
md,
|
|
43
|
+
lg,
|
|
44
|
+
xl,
|
|
45
|
+
quality,
|
|
46
|
+
disableRetina,
|
|
47
|
+
supportsWebp
|
|
48
|
+
)
|
|
49
|
+
setImgUrls(imageUrls)
|
|
50
|
+
})
|
|
51
|
+
}, [contentfulAssetUrl, dimension, disableRetina, lg, md, quality, sm, xl, xs])
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
53
|
+
if (!imgUrls) return null
|
|
54
|
+
return <ResponsiveImage {...imgUrls} alt={alt} {...selectProps(rest)} ref={ref} />
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
OptimizeImage.displayName = 'OptimizeImage'
|
|
52
59
|
|
|
53
60
|
OptimizeImage.propTypes = {
|
|
54
61
|
...selectedSystemPropTypes,
|