@telus-uds/components-web 1.7.0 → 1.9.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/.eslintignore +2 -0
- package/.vscode/settings.json +7 -0
- package/CHANGELOG.md +39 -2
- package/lib/Autocomplete/Autocomplete.js +393 -0
- package/lib/Autocomplete/Loading.js +51 -0
- package/lib/Autocomplete/Suggestions.js +81 -0
- package/lib/Autocomplete/constants.js +19 -0
- package/lib/Autocomplete/dictionary.js +19 -0
- package/lib/Autocomplete/index.js +13 -0
- package/lib/BlockQuote/BlockQuote.js +173 -0
- package/lib/BlockQuote/index.js +13 -0
- package/lib/Callout/Callout.js +3 -0
- package/lib/Card/Card.js +180 -0
- package/lib/Card/CardContent.js +110 -0
- package/lib/Card/CardFooter.js +98 -0
- package/lib/Card/index.js +13 -0
- package/lib/Countdown/Countdown.js +189 -0
- package/lib/Countdown/Segment.js +111 -0
- package/lib/Countdown/constants.js +14 -0
- package/lib/Countdown/dictionary.js +29 -0
- package/lib/Countdown/index.js +13 -0
- package/lib/Countdown/types.js +39 -0
- package/lib/Countdown/useCountdown.js +40 -0
- package/lib/IconButton/IconButton.js +70 -0
- package/lib/IconButton/index.js +13 -0
- package/lib/Listbox/GroupControl.js +94 -0
- package/lib/Listbox/Listbox.js +164 -0
- package/lib/Listbox/ListboxGroup.js +129 -0
- package/lib/Listbox/ListboxItem.js +137 -0
- package/lib/Listbox/ListboxOverlay.js +89 -0
- package/lib/Listbox/PressableItem.js +149 -0
- package/lib/Listbox/index.js +13 -0
- package/lib/Modal/ModalContent.js +11 -4
- package/lib/NavigationBar/resolveItemSelection.js +24 -0
- package/lib/OptimizeImage/OptimizeImage.js +127 -0
- package/lib/OptimizeImage/index.js +13 -0
- package/lib/OptimizeImage/utils/getFallbackUrl.js +18 -0
- package/lib/OptimizeImage/utils/getOptimizedUrl.js +32 -0
- package/lib/OptimizeImage/utils/hasWebpSupport.js +38 -0
- package/lib/OptimizeImage/utils/index.js +31 -0
- package/lib/OptimizeImage/utils/isSvgUrl.js +10 -0
- package/lib/QuantitySelector/QuantitySelector.js +253 -0
- package/lib/QuantitySelector/dictionary.js +33 -0
- package/lib/QuantitySelector/index.js +13 -0
- package/lib/QuantitySelector/styles.js +40 -0
- package/lib/StoryCard/StoryCard.js +244 -0
- package/lib/StoryCard/index.js +13 -0
- package/lib/TermsAndConditions/ExpandCollapse.js +141 -0
- package/lib/TermsAndConditions/TermsAndConditions.js +221 -0
- package/lib/TermsAndConditions/dictionary.js +19 -0
- package/lib/TermsAndConditions/index.js +15 -0
- package/lib/Testimonial/Testimonial.js +226 -0
- package/lib/Testimonial/index.js +13 -0
- package/lib/Video/ControlBar/ControlBar.js +315 -0
- package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +91 -0
- package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +186 -0
- package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +221 -0
- package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +213 -0
- package/lib/Video/MiddleControlButton/MiddleControlButton.js +89 -0
- package/lib/Video/Video.js +1072 -0
- package/lib/Video/index.js +13 -0
- package/lib/Video/videoText.js +62 -0
- package/lib/WebVideo/WebVideo.js +170 -0
- package/lib/WebVideo/index.js +13 -0
- package/lib/baseExports.js +0 -12
- package/lib/index.js +118 -1
- package/lib/shared/VideoSplash/SplashButton/SplashButton.js +102 -0
- package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +234 -0
- package/lib/shared/VideoSplash/VideoSplash.js +86 -0
- package/lib/shared/VideoSplash/helpers.js +38 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/useOverlaidPosition.js +246 -0
- package/lib-module/Autocomplete/Autocomplete.js +369 -0
- package/lib-module/Autocomplete/Loading.js +38 -0
- package/lib-module/Autocomplete/Suggestions.js +64 -0
- package/lib-module/Autocomplete/constants.js +5 -0
- package/lib-module/Autocomplete/dictionary.js +12 -0
- package/lib-module/Autocomplete/index.js +2 -0
- package/lib-module/BlockQuote/BlockQuote.js +156 -0
- package/lib-module/BlockQuote/index.js +2 -0
- package/lib-module/Callout/Callout.js +3 -0
- package/lib-module/Card/Card.js +158 -0
- package/lib-module/Card/CardContent.js +92 -0
- package/lib-module/Card/CardFooter.js +80 -0
- package/lib-module/Card/index.js +2 -0
- package/lib-module/Countdown/Countdown.js +165 -0
- package/lib-module/Countdown/Segment.js +94 -0
- package/lib-module/Countdown/constants.js +4 -0
- package/lib-module/Countdown/dictionary.js +22 -0
- package/lib-module/Countdown/index.js +2 -0
- package/lib-module/Countdown/types.js +23 -0
- package/lib-module/Countdown/useCountdown.js +32 -0
- package/lib-module/IconButton/IconButton.js +52 -0
- package/lib-module/IconButton/index.js +2 -0
- package/lib-module/Listbox/GroupControl.js +80 -0
- package/lib-module/Listbox/Listbox.js +142 -0
- package/lib-module/Listbox/ListboxGroup.js +106 -0
- package/lib-module/Listbox/ListboxItem.js +112 -0
- package/lib-module/Listbox/ListboxOverlay.js +68 -0
- package/lib-module/Listbox/PressableItem.js +128 -0
- package/lib-module/Listbox/index.js +2 -0
- package/lib-module/Modal/ModalContent.js +10 -4
- package/lib-module/NavigationBar/resolveItemSelection.js +16 -0
- package/lib-module/OptimizeImage/OptimizeImage.js +106 -0
- package/lib-module/OptimizeImage/index.js +2 -0
- package/lib-module/OptimizeImage/utils/getFallbackUrl.js +8 -0
- package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +22 -0
- package/lib-module/OptimizeImage/utils/hasWebpSupport.js +32 -0
- package/lib-module/OptimizeImage/utils/index.js +4 -0
- package/lib-module/OptimizeImage/utils/isSvgUrl.js +3 -0
- package/lib-module/QuantitySelector/QuantitySelector.js +232 -0
- package/lib-module/QuantitySelector/dictionary.js +26 -0
- package/lib-module/QuantitySelector/index.js +2 -0
- package/lib-module/QuantitySelector/styles.js +21 -0
- package/lib-module/StoryCard/StoryCard.js +220 -0
- package/lib-module/StoryCard/index.js +2 -0
- package/lib-module/TermsAndConditions/ExpandCollapse.js +120 -0
- package/lib-module/TermsAndConditions/TermsAndConditions.js +193 -0
- package/lib-module/TermsAndConditions/dictionary.js +12 -0
- package/lib-module/TermsAndConditions/index.js +1 -0
- package/lib-module/Testimonial/Testimonial.js +204 -0
- package/lib-module/Testimonial/index.js +2 -0
- package/lib-module/Video/ControlBar/ControlBar.js +292 -0
- package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +74 -0
- package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +167 -0
- package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +201 -0
- package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +193 -0
- package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +72 -0
- package/lib-module/Video/Video.js +1042 -0
- package/lib-module/Video/index.js +2 -0
- package/lib-module/Video/videoText.js +55 -0
- package/lib-module/WebVideo/WebVideo.js +144 -0
- package/lib-module/WebVideo/index.js +2 -0
- package/lib-module/baseExports.js +1 -1
- package/lib-module/index.js +13 -0
- package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +85 -0
- package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +216 -0
- package/lib-module/shared/VideoSplash/VideoSplash.js +65 -0
- package/lib-module/shared/VideoSplash/helpers.js +23 -0
- package/lib-module/utils/index.js +2 -1
- package/lib-module/utils/useOverlaidPosition.js +235 -0
- package/package.json +7 -5
- package/src/Autocomplete/Autocomplete.jsx +354 -0
- package/src/Autocomplete/Loading.jsx +18 -0
- package/src/Autocomplete/Suggestions.jsx +52 -0
- package/src/Autocomplete/constants.js +6 -0
- package/src/Autocomplete/dictionary.js +12 -0
- package/src/Autocomplete/index.js +3 -0
- package/src/BlockQuote/BlockQuote.jsx +130 -0
- package/src/BlockQuote/index.js +3 -0
- package/src/Callout/Callout.jsx +1 -1
- package/src/Card/Card.jsx +170 -0
- package/src/Card/CardContent.jsx +88 -0
- package/src/Card/CardFooter.jsx +70 -0
- package/src/Card/index.js +3 -0
- package/src/Countdown/Countdown.jsx +144 -0
- package/src/Countdown/Segment.jsx +69 -0
- package/src/Countdown/constants.js +4 -0
- package/src/Countdown/dictionary.js +22 -0
- package/src/Countdown/index.js +3 -0
- package/src/Countdown/types.js +23 -0
- package/src/Countdown/useCountdown.js +34 -0
- package/src/IconButton/IconButton.jsx +46 -0
- package/src/IconButton/index.js +3 -0
- package/src/Listbox/GroupControl.jsx +65 -0
- package/src/Listbox/Listbox.jsx +148 -0
- package/src/Listbox/ListboxGroup.jsx +110 -0
- package/src/Listbox/ListboxItem.jsx +101 -0
- package/src/Listbox/ListboxOverlay.jsx +71 -0
- package/src/Listbox/PressableItem.jsx +121 -0
- package/src/Listbox/index.js +3 -0
- package/src/Modal/ModalContent.jsx +8 -4
- package/src/NavigationBar/resolveItemSelection.js +11 -0
- package/src/OptimizeImage/OptimizeImage.jsx +131 -0
- package/src/OptimizeImage/index.js +3 -0
- package/src/OptimizeImage/utils/getFallbackUrl.js +9 -0
- package/src/OptimizeImage/utils/getOptimizedUrl.js +30 -0
- package/src/OptimizeImage/utils/hasWebpSupport.js +33 -0
- package/src/OptimizeImage/utils/index.js +5 -0
- package/src/OptimizeImage/utils/isSvgUrl.js +3 -0
- package/src/QuantitySelector/QuantitySelector.jsx +245 -0
- package/src/QuantitySelector/dictionary.js +27 -0
- package/src/QuantitySelector/index.js +3 -0
- package/src/QuantitySelector/styles.js +83 -0
- package/src/StoryCard/StoryCard.jsx +198 -0
- package/src/StoryCard/index.js +3 -0
- package/src/TermsAndConditions/ExpandCollapse.jsx +106 -0
- package/src/TermsAndConditions/TermsAndConditions.jsx +161 -0
- package/src/TermsAndConditions/dictionary.js +12 -0
- package/src/TermsAndConditions/index.js +1 -0
- package/src/Testimonial/Testimonial.jsx +169 -0
- package/src/Testimonial/index.js +3 -0
- package/src/Video/ControlBar/ControlBar.jsx +261 -0
- package/src/Video/ControlBar/Controls/VideoButton/VideoButton.jsx +61 -0
- package/src/Video/ControlBar/Controls/VideoMenu/VideoMenu.jsx +159 -0
- package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +185 -0
- package/src/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.jsx +184 -0
- package/src/Video/MiddleControlButton/MiddleControlButton.jsx +64 -0
- package/src/Video/Video.jsx +988 -0
- package/src/Video/index.js +3 -0
- package/src/Video/videoText.js +58 -0
- package/src/WebVideo/WebVideo.jsx +131 -0
- package/src/WebVideo/index.js +3 -0
- package/src/baseExports.js +0 -2
- package/src/index.js +13 -0
- package/src/shared/VideoSplash/SplashButton/SplashButton.jsx +64 -0
- package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +128 -0
- package/src/shared/VideoSplash/VideoSplash.jsx +50 -0
- package/src/shared/VideoSplash/helpers.js +27 -0
- package/src/utils/index.js +10 -1
- package/src/utils/useOverlaidPosition.js +226 -0
- package/types/Autocomplete.d.ts +32 -0
- package/types/Card.d.ts +45 -0
- package/types/ControlBar.d.ts +59 -0
- package/types/MiddleControlButton.d.ts +15 -0
- package/types/Video.d.ts +39 -0
- package/types/VideoButton.d.ts +14 -0
- package/types/VideoMenu.d.ts +16 -0
- package/types/VideoProgressBar.d.ts +17 -0
- package/types/VolumeSlider.d.ts +20 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
StackView,
|
|
7
|
+
Typography,
|
|
8
|
+
useThemeTokens,
|
|
9
|
+
selectSystemProps,
|
|
10
|
+
Icon
|
|
11
|
+
} from '@telus-uds/components-base'
|
|
12
|
+
|
|
13
|
+
import videoText from '../../../videoText'
|
|
14
|
+
import { htmlAttrs } from '../../../../utils'
|
|
15
|
+
|
|
16
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
17
|
+
|
|
18
|
+
const MenuContainer = styled.div(({ padding, background }) => ({
|
|
19
|
+
width: 114,
|
|
20
|
+
padding,
|
|
21
|
+
backgroundColor: background,
|
|
22
|
+
borderRadius: 5
|
|
23
|
+
}))
|
|
24
|
+
|
|
25
|
+
const MenuButton = styled.button({
|
|
26
|
+
background: 'none',
|
|
27
|
+
border: 'none',
|
|
28
|
+
padding: 0,
|
|
29
|
+
|
|
30
|
+
width: '100%',
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
display: 'flex',
|
|
33
|
+
justifyContent: 'space-between',
|
|
34
|
+
verticalAlign: 'middle'
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const CheckmarkContainer = styled.div(
|
|
38
|
+
({
|
|
39
|
+
isSelectedItem,
|
|
40
|
+
checkMarkWidth,
|
|
41
|
+
checkMarkHeight,
|
|
42
|
+
checkMarkSelectedColor,
|
|
43
|
+
checkMarkHoverColor,
|
|
44
|
+
checkMarkFocusColor,
|
|
45
|
+
checkMarkUnselectedColor
|
|
46
|
+
}) => ({
|
|
47
|
+
width: checkMarkWidth,
|
|
48
|
+
height: checkMarkHeight,
|
|
49
|
+
marginTop: 2,
|
|
50
|
+
outline: 'none',
|
|
51
|
+
|
|
52
|
+
[`${MenuButton} && svg`]: {
|
|
53
|
+
fill: isSelectedItem ? checkMarkSelectedColor : checkMarkUnselectedColor
|
|
54
|
+
},
|
|
55
|
+
[`${MenuButton}:hover && svg`]: {
|
|
56
|
+
fill: isSelectedItem ? checkMarkSelectedColor : checkMarkHoverColor
|
|
57
|
+
},
|
|
58
|
+
[`${MenuButton}:focus && svg`]: {
|
|
59
|
+
fill: isSelectedItem ? checkMarkSelectedColor : checkMarkFocusColor
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const VideoMenu = ({
|
|
65
|
+
menuLabel,
|
|
66
|
+
menuOptions,
|
|
67
|
+
setSelection,
|
|
68
|
+
selectedItem,
|
|
69
|
+
copy,
|
|
70
|
+
tokens,
|
|
71
|
+
variant,
|
|
72
|
+
...rest
|
|
73
|
+
}) => {
|
|
74
|
+
const {
|
|
75
|
+
padding,
|
|
76
|
+
background,
|
|
77
|
+
checkMarkWidth,
|
|
78
|
+
checkMarkHeight,
|
|
79
|
+
checkMarkSelectedColor,
|
|
80
|
+
checkMarkHoverColor,
|
|
81
|
+
checkMarkFocusColor,
|
|
82
|
+
checkMarkUnselectedColor,
|
|
83
|
+
checkMarkIcon
|
|
84
|
+
} = useThemeTokens('VideoMenu', tokens, variant)
|
|
85
|
+
|
|
86
|
+
const getMenuItems = () => {
|
|
87
|
+
return menuOptions.map((option) => {
|
|
88
|
+
if (option.name) {
|
|
89
|
+
return (
|
|
90
|
+
<MenuButton
|
|
91
|
+
aria-haspopup="true"
|
|
92
|
+
role="menuitem"
|
|
93
|
+
aria-label={`${option.name} ${menuLabel}. ${
|
|
94
|
+
selectedItem === option.value
|
|
95
|
+
? videoText[copy].itemSelected
|
|
96
|
+
: videoText[copy].itemUnselected
|
|
97
|
+
}`}
|
|
98
|
+
selectedItem={selectedItem}
|
|
99
|
+
itemValue={option.value}
|
|
100
|
+
onClick={() => {
|
|
101
|
+
if (selectedItem !== option.value) {
|
|
102
|
+
setSelection(option.value)
|
|
103
|
+
}
|
|
104
|
+
}}
|
|
105
|
+
key={option.value}
|
|
106
|
+
>
|
|
107
|
+
<Typography variant={{ bold: true, inverse: true }}>{option.name}</Typography>
|
|
108
|
+
<CheckmarkContainer
|
|
109
|
+
isSelectedItem={option.value === selectedItem}
|
|
110
|
+
checkMarkWidth={checkMarkWidth}
|
|
111
|
+
checkMarkHeight={checkMarkHeight}
|
|
112
|
+
checkMarkSelectedColor={checkMarkSelectedColor}
|
|
113
|
+
checkMarkHoverColor={checkMarkHoverColor}
|
|
114
|
+
checkMarkFocusColor={checkMarkFocusColor}
|
|
115
|
+
checkMarkUnselectedColor={checkMarkUnselectedColor}
|
|
116
|
+
>
|
|
117
|
+
<Icon icon={checkMarkIcon} />
|
|
118
|
+
</CheckmarkContainer>
|
|
119
|
+
</MenuButton>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
return null
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const handleOnKeyDown = (event) => {
|
|
127
|
+
const key = event.key || event.keyCode
|
|
128
|
+
|
|
129
|
+
// Disables playing by space bar, as that can be used to click a button
|
|
130
|
+
if (key === ' ' || key === 32) {
|
|
131
|
+
event.stopPropagation()
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<MenuContainer
|
|
137
|
+
onKeyDown={handleOnKeyDown}
|
|
138
|
+
padding={padding}
|
|
139
|
+
background={background}
|
|
140
|
+
{...selectProps(rest)}
|
|
141
|
+
>
|
|
142
|
+
<StackView space={2} divider>
|
|
143
|
+
<Typography variant={{ bold: true, inverse: true }}>{menuLabel}</Typography>
|
|
144
|
+
<div role="menu">{getMenuItems()}</div>
|
|
145
|
+
</StackView>
|
|
146
|
+
</MenuContainer>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
VideoMenu.propTypes = {
|
|
151
|
+
...selectedSystemPropTypes,
|
|
152
|
+
menuLabel: PropTypes.string.isRequired,
|
|
153
|
+
menuOptions: PropTypes.array.isRequired,
|
|
154
|
+
setSelection: PropTypes.func.isRequired,
|
|
155
|
+
selectedItem: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
156
|
+
copy: PropTypes.oneOf(['en', 'fr']).isRequired
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export default VideoMenu
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import { Typography, useThemeTokens, selectSystemProps } from '@telus-uds/components-base'
|
|
6
|
+
|
|
7
|
+
import videoText from '../../../videoText'
|
|
8
|
+
import { htmlAttrs } from '../../../../utils'
|
|
9
|
+
|
|
10
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
11
|
+
|
|
12
|
+
const ProgressBarContainer = styled.div({
|
|
13
|
+
display: 'flex',
|
|
14
|
+
width: '100%',
|
|
15
|
+
alignItems: 'center'
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const sharedStyles = ({
|
|
19
|
+
thumbHeight,
|
|
20
|
+
thumbWidth,
|
|
21
|
+
thumbBackground,
|
|
22
|
+
trackGradientStart,
|
|
23
|
+
trackGradientEnd
|
|
24
|
+
}) => ({
|
|
25
|
+
thumb: {
|
|
26
|
+
appearance: 'none',
|
|
27
|
+
height: thumbHeight,
|
|
28
|
+
width: thumbWidth,
|
|
29
|
+
borderRadius: '50%',
|
|
30
|
+
background: thumbBackground,
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
marginTop: -3,
|
|
33
|
+
|
|
34
|
+
'&:hover': {
|
|
35
|
+
transform: 'scale(1.5)'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
track: (videoBufferDisplay) => ({
|
|
39
|
+
width: '100%',
|
|
40
|
+
height: 2,
|
|
41
|
+
cursor: 'pointer',
|
|
42
|
+
borderRadius: 1.3,
|
|
43
|
+
background: `linear-gradient(to right, ${trackGradientStart} 0%,${trackGradientEnd} ${
|
|
44
|
+
videoBufferDisplay - 0.01
|
|
45
|
+
}% ,rgba(255,255,255,0.5) ${videoBufferDisplay}%)` // TODO: replace with opaque white from palette
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const StyledProgressBar = styled.input.attrs(({ videoCurrentTime }) => ({
|
|
50
|
+
value: videoCurrentTime
|
|
51
|
+
}))(({ videoBufferDisplay, rangeBackground, ...sharedProps }) => ({
|
|
52
|
+
width: '100%',
|
|
53
|
+
cursor: 'pointer',
|
|
54
|
+
padding: '5px 0',
|
|
55
|
+
'input[type=range]&': {
|
|
56
|
+
appearance: 'none',
|
|
57
|
+
width: '100%',
|
|
58
|
+
background: rangeBackground
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
'input[type=range]&:focus': {
|
|
62
|
+
outline: 'none'
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
'input[type=range]&::-webkit-slider-thumb': sharedStyles(sharedProps).thumb,
|
|
66
|
+
'input[type=range]&::-moz-range-thumb': {
|
|
67
|
+
...sharedStyles(sharedProps).thumb,
|
|
68
|
+
border: 'none'
|
|
69
|
+
},
|
|
70
|
+
'input[type=range]&::-ms-thumb': {
|
|
71
|
+
...sharedStyles(sharedProps).thumb,
|
|
72
|
+
margin: 0,
|
|
73
|
+
border: 'none'
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
'input[type=range]&::-webkit-slider-runnable-track':
|
|
77
|
+
sharedStyles(sharedProps).track(videoBufferDisplay),
|
|
78
|
+
'input[type=range]&::-moz-range-track': sharedStyles(sharedProps).track(videoBufferDisplay),
|
|
79
|
+
'input[type=range]&::-ms-track': {
|
|
80
|
+
...sharedStyles(sharedProps).track(videoBufferDisplay),
|
|
81
|
+
margin: '6px 0',
|
|
82
|
+
border: 'none'
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
'input[type=range]&::-ms-fill-lower': {
|
|
86
|
+
background: rangeBackground
|
|
87
|
+
},
|
|
88
|
+
'input[type=range]&::-ms-tooltip': {
|
|
89
|
+
display: 'none'
|
|
90
|
+
}
|
|
91
|
+
}))
|
|
92
|
+
|
|
93
|
+
const StyledTimestamp = styled.span(({ margin }) => ({
|
|
94
|
+
margin
|
|
95
|
+
}))
|
|
96
|
+
// TODO: unify with the helper from `VideoSplash`
|
|
97
|
+
function getTimestamp(duration) {
|
|
98
|
+
const minutes = Math.floor(duration / 60)
|
|
99
|
+
const seconds = Math.floor(duration - 60 * minutes)
|
|
100
|
+
|
|
101
|
+
return `${minutes}:${seconds < 10 ? 0 : ''}${seconds}`
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const VideoProgressBar = ({
|
|
105
|
+
copy = 'en',
|
|
106
|
+
videoLength,
|
|
107
|
+
videoCurrentTime,
|
|
108
|
+
videoBufferEnd,
|
|
109
|
+
setSeek,
|
|
110
|
+
resetInactivityTimer,
|
|
111
|
+
tokens,
|
|
112
|
+
variant,
|
|
113
|
+
...rest
|
|
114
|
+
}) => {
|
|
115
|
+
const {
|
|
116
|
+
thumbHeight,
|
|
117
|
+
thumbWidth,
|
|
118
|
+
thumbBackground,
|
|
119
|
+
timestampMarginLeft,
|
|
120
|
+
timestampMarginRight,
|
|
121
|
+
trackGradientStart,
|
|
122
|
+
trackGradientEnd,
|
|
123
|
+
rangeBackground
|
|
124
|
+
} = useThemeTokens('VideoProgressBar', tokens, variant)
|
|
125
|
+
|
|
126
|
+
const videoProgressBar = React.createRef()
|
|
127
|
+
|
|
128
|
+
const handleVideoSkip = () => {
|
|
129
|
+
setSeek(videoProgressBar.current.value)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const videoBufferDisplay = (videoBufferEnd / videoLength) * 100
|
|
133
|
+
|
|
134
|
+
const isVideoUnplayed = videoCurrentTime === -1
|
|
135
|
+
const currentTime = isVideoUnplayed ? 0 : videoCurrentTime
|
|
136
|
+
const remainingTime = isVideoUnplayed ? videoLength : videoLength - videoCurrentTime
|
|
137
|
+
|
|
138
|
+
const currentTimestamp = getTimestamp(currentTime)
|
|
139
|
+
const remainingTimestamp = getTimestamp(remainingTime)
|
|
140
|
+
|
|
141
|
+
const sharedProps = {
|
|
142
|
+
thumbWidth,
|
|
143
|
+
thumbHeight,
|
|
144
|
+
thumbBackground,
|
|
145
|
+
trackGradientStart,
|
|
146
|
+
trackGradientEnd,
|
|
147
|
+
rangeBackground
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<ProgressBarContainer {...selectProps(rest)}>
|
|
152
|
+
<StyledTimestamp margin={`0 ${timestampMarginRight}px 0 ${timestampMarginLeft}px`}>
|
|
153
|
+
<Typography variant={{ inverse: true }}>{currentTimestamp}</Typography>
|
|
154
|
+
</StyledTimestamp>
|
|
155
|
+
<StyledProgressBar
|
|
156
|
+
aria-label={videoText[copy].videoProgressBarLabel}
|
|
157
|
+
type="range"
|
|
158
|
+
step="any"
|
|
159
|
+
max={videoLength}
|
|
160
|
+
videoCurrentTime={videoCurrentTime}
|
|
161
|
+
onChange={handleVideoSkip}
|
|
162
|
+
onFocus={resetInactivityTimer}
|
|
163
|
+
videoBufferDisplay={videoBufferDisplay}
|
|
164
|
+
ref={videoProgressBar}
|
|
165
|
+
tabIndex="-1"
|
|
166
|
+
{...sharedProps}
|
|
167
|
+
/>
|
|
168
|
+
<StyledTimestamp>
|
|
169
|
+
<Typography variant={{ inverse: true }}>{remainingTimestamp}</Typography>
|
|
170
|
+
</StyledTimestamp>
|
|
171
|
+
</ProgressBarContainer>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
VideoProgressBar.propTypes = {
|
|
176
|
+
...selectedSystemPropTypes,
|
|
177
|
+
copy: PropTypes.oneOf(['en', 'fr']),
|
|
178
|
+
videoLength: PropTypes.number.isRequired,
|
|
179
|
+
videoCurrentTime: PropTypes.number.isRequired,
|
|
180
|
+
videoBufferEnd: PropTypes.number.isRequired,
|
|
181
|
+
setSeek: PropTypes.func.isRequired,
|
|
182
|
+
resetInactivityTimer: PropTypes.func.isRequired
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export default VideoProgressBar
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import { Icon, useThemeTokens, selectSystemProps } from '@telus-uds/components-base'
|
|
6
|
+
|
|
7
|
+
import VideoButton from '../VideoButton/VideoButton'
|
|
8
|
+
import videoText from '../../../videoText'
|
|
9
|
+
import { htmlAttrs } from '../../../../utils'
|
|
10
|
+
|
|
11
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
12
|
+
|
|
13
|
+
const VolumeSliderContainer = styled.div(({ videoPlayerWidth, compactModeThreshold, margin }) => ({
|
|
14
|
+
display: 'flex',
|
|
15
|
+
width: videoPlayerWidth > compactModeThreshold ? '12%' : '20%',
|
|
16
|
+
maxWidth: 120,
|
|
17
|
+
margin,
|
|
18
|
+
alignItems: 'center'
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
const sharedStyles = ({
|
|
22
|
+
thumbHeight,
|
|
23
|
+
thumbWidth,
|
|
24
|
+
thumbBackground,
|
|
25
|
+
trackGradientStart,
|
|
26
|
+
trackGradientEnd
|
|
27
|
+
}) => ({
|
|
28
|
+
thumb: {
|
|
29
|
+
appearance: 'none',
|
|
30
|
+
height: thumbHeight,
|
|
31
|
+
width: thumbWidth,
|
|
32
|
+
borderRadius: '50%',
|
|
33
|
+
background: thumbBackground,
|
|
34
|
+
cursor: 'pointer',
|
|
35
|
+
marginTop: -3,
|
|
36
|
+
|
|
37
|
+
'&:hover': {
|
|
38
|
+
transform: 'scale(1.5)'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
track: (videoCurrentVolume) => ({
|
|
42
|
+
width: '100%',
|
|
43
|
+
height: 2,
|
|
44
|
+
cursor: 'pointer',
|
|
45
|
+
borderRadius: 1.3,
|
|
46
|
+
background: `linear-gradient(to right, ${trackGradientStart} 0%, ${trackGradientEnd} ${
|
|
47
|
+
videoCurrentVolume * 100 - 0.01
|
|
48
|
+
}%, rgba(255,255,255,0.5) ${videoCurrentVolume * 100}%)`
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const StyledVolumeSlider = styled.input.attrs(({ videoCurrentVolume }) => ({
|
|
53
|
+
value: videoCurrentVolume
|
|
54
|
+
}))(({ videoCurrentVolume, rangeBackground, ...sharedProps }) => {
|
|
55
|
+
return {
|
|
56
|
+
width: '100%',
|
|
57
|
+
cursor: 'pointer',
|
|
58
|
+
padding: '5px 0',
|
|
59
|
+
|
|
60
|
+
'input[type=range]&': {
|
|
61
|
+
appearance: 'none',
|
|
62
|
+
width: '100%',
|
|
63
|
+
background: rangeBackground
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
'input[type=range]&:focus': {
|
|
67
|
+
outline: 'none'
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
'input[type=range]&::-webkit-slider-thumb': sharedStyles(sharedProps).thumb,
|
|
71
|
+
'input[type=range]&::-moz-range-thumb': {
|
|
72
|
+
...sharedStyles.thumb,
|
|
73
|
+
border: 'none'
|
|
74
|
+
},
|
|
75
|
+
'input[type=range]&::-ms-thumb': {
|
|
76
|
+
...sharedStyles.thumb,
|
|
77
|
+
margin: 0,
|
|
78
|
+
border: 'none'
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
'input[type=range]&::-webkit-slider-runnable-track':
|
|
82
|
+
sharedStyles(sharedProps).track(videoCurrentVolume),
|
|
83
|
+
'input[type=range]&::-moz-range-track': sharedStyles(sharedProps).track(videoCurrentVolume),
|
|
84
|
+
'input[type=range]&::-ms-track': {
|
|
85
|
+
...sharedStyles(sharedProps).track(videoCurrentVolume),
|
|
86
|
+
margin: '6px 0',
|
|
87
|
+
border: 'none'
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
'input[type=range]&::-ms-fill-lower': {
|
|
91
|
+
background: 'transparent'
|
|
92
|
+
},
|
|
93
|
+
'input[type=range]&::-ms-tooltip': {
|
|
94
|
+
display: 'none'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const VolumeSlider = ({
|
|
100
|
+
setVolume,
|
|
101
|
+
compactModeThreshold,
|
|
102
|
+
disableFocus,
|
|
103
|
+
videoPlayerWidth,
|
|
104
|
+
videoIsMuted,
|
|
105
|
+
videoCurrentVolume,
|
|
106
|
+
copy,
|
|
107
|
+
toggleMute,
|
|
108
|
+
resetInactivityTimer,
|
|
109
|
+
tokens,
|
|
110
|
+
variant,
|
|
111
|
+
...rest
|
|
112
|
+
}) => {
|
|
113
|
+
const refVolumeSlider = React.useRef()
|
|
114
|
+
|
|
115
|
+
const {
|
|
116
|
+
marginLeft,
|
|
117
|
+
marginRight,
|
|
118
|
+
thumbHeight,
|
|
119
|
+
thumbWidth,
|
|
120
|
+
thumbBackground,
|
|
121
|
+
trackGradientStart,
|
|
122
|
+
trackGradientEnd,
|
|
123
|
+
rangeBackground,
|
|
124
|
+
mutedIcon,
|
|
125
|
+
unmutedIcon
|
|
126
|
+
} = useThemeTokens('VideoVolumeSlider', tokens, variant)
|
|
127
|
+
|
|
128
|
+
const sharedProps = {
|
|
129
|
+
thumbHeight,
|
|
130
|
+
thumbWidth,
|
|
131
|
+
thumbBackground,
|
|
132
|
+
trackGradientStart,
|
|
133
|
+
trackGradientEnd,
|
|
134
|
+
rangeBackground
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const handleVolumeChange = () => setVolume(refVolumeSlider.current.value)
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<VolumeSliderContainer
|
|
141
|
+
compactModeThreshold={compactModeThreshold}
|
|
142
|
+
videoPlayerWidth={videoPlayerWidth}
|
|
143
|
+
margin={`0 ${marginRight}px 0 ${marginLeft}px`}
|
|
144
|
+
{...selectProps(rest)}
|
|
145
|
+
>
|
|
146
|
+
<VideoButton
|
|
147
|
+
icon={videoIsMuted ? <Icon icon={mutedIcon} /> : <Icon icon={unmutedIcon} />}
|
|
148
|
+
label={videoIsMuted ? videoText[copy].unmute : videoText[copy].mute}
|
|
149
|
+
disableFocus={disableFocus}
|
|
150
|
+
onClick={toggleMute}
|
|
151
|
+
onFocus={resetInactivityTimer}
|
|
152
|
+
/>
|
|
153
|
+
<StyledVolumeSlider
|
|
154
|
+
type="range"
|
|
155
|
+
min="0"
|
|
156
|
+
max="1"
|
|
157
|
+
step="any"
|
|
158
|
+
value={videoCurrentVolume}
|
|
159
|
+
videoCurrentVolume={videoCurrentVolume}
|
|
160
|
+
ref={refVolumeSlider}
|
|
161
|
+
onChange={handleVolumeChange}
|
|
162
|
+
onFocus={resetInactivityTimer}
|
|
163
|
+
tabIndex="-1"
|
|
164
|
+
aria-label={videoText[copy].volumeSliderLabel}
|
|
165
|
+
{...sharedProps}
|
|
166
|
+
/>
|
|
167
|
+
</VolumeSliderContainer>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
VolumeSlider.propTypes = {
|
|
172
|
+
...selectedSystemPropTypes,
|
|
173
|
+
videoCurrentVolume: PropTypes.number.isRequired,
|
|
174
|
+
setVolume: PropTypes.func.isRequired,
|
|
175
|
+
videoIsMuted: PropTypes.bool.isRequired,
|
|
176
|
+
toggleMute: PropTypes.func.isRequired,
|
|
177
|
+
resetInactivityTimer: PropTypes.func.isRequired,
|
|
178
|
+
copy: PropTypes.oneOf(['en', 'fr']).isRequired,
|
|
179
|
+
compactModeThreshold: PropTypes.number.isRequired,
|
|
180
|
+
videoPlayerWidth: PropTypes.number.isRequired,
|
|
181
|
+
disableFocus: PropTypes.bool.isRequired
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export default VolumeSlider
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import { useThemeTokens, selectSystemProps } from '@telus-uds/components-base'
|
|
6
|
+
import { htmlAttrs } from '../../utils'
|
|
7
|
+
|
|
8
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
9
|
+
|
|
10
|
+
const StyledMiddleControlButton = styled.button(({ isHidden, width, height, background }) => ({
|
|
11
|
+
width,
|
|
12
|
+
height,
|
|
13
|
+
borderRadius: '50%',
|
|
14
|
+
transition: 'opacity 0.4s',
|
|
15
|
+
opacity: isHidden ? 0 : 1,
|
|
16
|
+
background,
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
border: 'none',
|
|
20
|
+
padding: 0,
|
|
21
|
+
font: 'inherit',
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
alignItems: 'center'
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
const MiddleControlButton = ({
|
|
27
|
+
icon: Icon,
|
|
28
|
+
isHidden = false,
|
|
29
|
+
onClick,
|
|
30
|
+
onFocus,
|
|
31
|
+
tokens,
|
|
32
|
+
variant,
|
|
33
|
+
...rest
|
|
34
|
+
}) => {
|
|
35
|
+
const { width, height, background, iconColor } = useThemeTokens(
|
|
36
|
+
'VideoMiddleControlButton',
|
|
37
|
+
tokens,
|
|
38
|
+
variant
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<StyledMiddleControlButton
|
|
43
|
+
isHidden={isHidden}
|
|
44
|
+
onClick={onClick}
|
|
45
|
+
onFocus={onFocus}
|
|
46
|
+
width={width}
|
|
47
|
+
height={height}
|
|
48
|
+
background={background}
|
|
49
|
+
{...selectProps(rest)}
|
|
50
|
+
>
|
|
51
|
+
<Icon color={iconColor} size={24} />
|
|
52
|
+
</StyledMiddleControlButton>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
MiddleControlButton.propTypes = {
|
|
57
|
+
...selectedSystemPropTypes,
|
|
58
|
+
icon: PropTypes.elementType.isRequired,
|
|
59
|
+
isHidden: PropTypes.bool,
|
|
60
|
+
onClick: PropTypes.func,
|
|
61
|
+
onFocus: PropTypes.func
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default MiddleControlButton
|