@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,204 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { Icon, selectSystemProps, Typography, useThemeTokens } from '@telus-uds/components-base';
|
|
5
|
+
import Image from '../Image';
|
|
6
|
+
import { htmlAttrs } from '../utils';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
10
|
+
const TestimonialContainer = /*#__PURE__*/styled.figure.withConfig({
|
|
11
|
+
displayName: "Testimonial__TestimonialContainer",
|
|
12
|
+
componentId: "components-web__sc-1az53gr-0"
|
|
13
|
+
})(_ref => {
|
|
14
|
+
let {
|
|
15
|
+
testimonialContainerGap
|
|
16
|
+
} = _ref;
|
|
17
|
+
return {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
gap: testimonialContainerGap,
|
|
21
|
+
margin: 0
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
const QuoteContainer = /*#__PURE__*/styled.div.withConfig({
|
|
25
|
+
displayName: "Testimonial__QuoteContainer",
|
|
26
|
+
componentId: "components-web__sc-1az53gr-1"
|
|
27
|
+
})(_ref2 => {
|
|
28
|
+
let {
|
|
29
|
+
quoteContainerGap
|
|
30
|
+
} = _ref2;
|
|
31
|
+
return {
|
|
32
|
+
display: 'flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
gap: quoteContainerGap
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
const Divider = /*#__PURE__*/styled.div.withConfig({
|
|
38
|
+
displayName: "Testimonial__Divider",
|
|
39
|
+
componentId: "components-web__sc-1az53gr-2"
|
|
40
|
+
})(_ref3 => {
|
|
41
|
+
let {
|
|
42
|
+
dividerBorder,
|
|
43
|
+
dividerBackgroundColor
|
|
44
|
+
} = _ref3;
|
|
45
|
+
return {
|
|
46
|
+
height: dividerBorder,
|
|
47
|
+
background: dividerBackgroundColor,
|
|
48
|
+
width: '100%'
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
const BlockQuote = /*#__PURE__*/styled.blockquote.withConfig({
|
|
52
|
+
displayName: "Testimonial__BlockQuote",
|
|
53
|
+
componentId: "components-web__sc-1az53gr-3"
|
|
54
|
+
})({
|
|
55
|
+
margin: 0
|
|
56
|
+
});
|
|
57
|
+
const AuthorInfoContainer = /*#__PURE__*/styled.div.withConfig({
|
|
58
|
+
displayName: "Testimonial__AuthorInfoContainer",
|
|
59
|
+
componentId: "components-web__sc-1az53gr-4"
|
|
60
|
+
})({
|
|
61
|
+
display: 'flex',
|
|
62
|
+
flexDirection: 'column'
|
|
63
|
+
});
|
|
64
|
+
const Figcaption = /*#__PURE__*/styled.figcaption.withConfig({
|
|
65
|
+
displayName: "Testimonial__Figcaption",
|
|
66
|
+
componentId: "components-web__sc-1az53gr-5"
|
|
67
|
+
})(_ref4 => {
|
|
68
|
+
let {
|
|
69
|
+
figcaptionGap
|
|
70
|
+
} = _ref4;
|
|
71
|
+
return {
|
|
72
|
+
display: 'flex',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
gap: figcaptionGap
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const Testimonial = _ref5 => {
|
|
79
|
+
let {
|
|
80
|
+
showDivider,
|
|
81
|
+
testimonial,
|
|
82
|
+
title,
|
|
83
|
+
imageSrc,
|
|
84
|
+
image = imageSrc,
|
|
85
|
+
additionalInfo,
|
|
86
|
+
testimonialStyle = 'heading',
|
|
87
|
+
tokens,
|
|
88
|
+
variant = {},
|
|
89
|
+
...rest
|
|
90
|
+
} = _ref5;
|
|
91
|
+
const {
|
|
92
|
+
testimonialContainerGap,
|
|
93
|
+
quoteContainerGap,
|
|
94
|
+
dividerBorder,
|
|
95
|
+
dividerBackgroundColor,
|
|
96
|
+
figcaptionGap,
|
|
97
|
+
textColor,
|
|
98
|
+
icon,
|
|
99
|
+
iconColor,
|
|
100
|
+
imageSize
|
|
101
|
+
} = useThemeTokens('Testimonial', tokens, variant);
|
|
102
|
+
return /*#__PURE__*/_jsxs(TestimonialContainer, {
|
|
103
|
+
testimonialContainerGap: testimonialContainerGap,
|
|
104
|
+
...selectProps(rest),
|
|
105
|
+
children: [/*#__PURE__*/_jsxs(QuoteContainer, {
|
|
106
|
+
quoteContainerGap: quoteContainerGap,
|
|
107
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
108
|
+
tokens: {
|
|
109
|
+
color: iconColor
|
|
110
|
+
},
|
|
111
|
+
variant: {
|
|
112
|
+
size: 'micro'
|
|
113
|
+
},
|
|
114
|
+
icon: icon
|
|
115
|
+
}), showDivider && /*#__PURE__*/_jsx(Divider, {
|
|
116
|
+
dividerBackgroundColor: dividerBackgroundColor,
|
|
117
|
+
dividerBorder: dividerBorder,
|
|
118
|
+
role: "separator"
|
|
119
|
+
})]
|
|
120
|
+
}), /*#__PURE__*/_jsx(BlockQuote, {
|
|
121
|
+
children: /*#__PURE__*/_jsx(Typography, {
|
|
122
|
+
variant: {
|
|
123
|
+
size: testimonialStyle === 'large' ? 'large' : 'h3'
|
|
124
|
+
},
|
|
125
|
+
tokens: {
|
|
126
|
+
color: textColor,
|
|
127
|
+
fontWeight: '400'
|
|
128
|
+
},
|
|
129
|
+
children: `\u201C${testimonial}\u201D`
|
|
130
|
+
})
|
|
131
|
+
}), (image || title || additionalInfo) && /*#__PURE__*/_jsxs(Figcaption, {
|
|
132
|
+
figcaptionGap: figcaptionGap,
|
|
133
|
+
children: [image && (typeof image === 'string' ? /*#__PURE__*/_jsx(Image, {
|
|
134
|
+
rounded: "circle",
|
|
135
|
+
src: image,
|
|
136
|
+
alt: title,
|
|
137
|
+
width: imageSize,
|
|
138
|
+
height: imageSize
|
|
139
|
+
}) : image), (title || additionalInfo) && /*#__PURE__*/_jsxs(AuthorInfoContainer, {
|
|
140
|
+
children: [title && /*#__PURE__*/_jsx(Typography, {
|
|
141
|
+
variant: {
|
|
142
|
+
size: 'small',
|
|
143
|
+
colour: 'secondary'
|
|
144
|
+
},
|
|
145
|
+
tokens: {
|
|
146
|
+
fontWeight: '500'
|
|
147
|
+
},
|
|
148
|
+
children: title
|
|
149
|
+
}), additionalInfo && /*#__PURE__*/_jsx(Typography, {
|
|
150
|
+
variant: {
|
|
151
|
+
size: 'micro',
|
|
152
|
+
colour: 'secondary'
|
|
153
|
+
},
|
|
154
|
+
tokens: {
|
|
155
|
+
fontWeight: '400'
|
|
156
|
+
},
|
|
157
|
+
children: additionalInfo
|
|
158
|
+
})]
|
|
159
|
+
})]
|
|
160
|
+
}), showDivider && /*#__PURE__*/_jsx(Divider, {
|
|
161
|
+
dividerBackgroundColor: dividerBackgroundColor,
|
|
162
|
+
dividerBorder: dividerBorder,
|
|
163
|
+
role: "separator"
|
|
164
|
+
})]
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
Testimonial.propTypes = { ...selectedSystemPropTypes,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Testimonial content
|
|
172
|
+
*/
|
|
173
|
+
testimonial: PropTypes.string.isRequired,
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Testimonial author or source
|
|
177
|
+
*/
|
|
178
|
+
title: PropTypes.string,
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Additional information on the author or source
|
|
182
|
+
*/
|
|
183
|
+
additionalInfo: PropTypes.string,
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Testimonial style
|
|
187
|
+
*/
|
|
188
|
+
testimonialStyle: PropTypes.oneOf(['large', 'heading']),
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Whether to show or not dividers at the top and the bottom of the testimonial
|
|
192
|
+
showDivider: PropTypes.bool,
|
|
193
|
+
/**
|
|
194
|
+
* The src attribute for the Image component or custom JSX content to render instead
|
|
195
|
+
*/
|
|
196
|
+
image: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The src attribute for the `Image` component to be displayed on the testimonial
|
|
200
|
+
* @deprecated please use the `image` prop instead
|
|
201
|
+
*/
|
|
202
|
+
imageSrc: PropTypes.string
|
|
203
|
+
};
|
|
204
|
+
export default Testimonial;
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { StackView, useThemeTokens, selectSystemProps, Icon } from '@telus-uds/components-base';
|
|
5
|
+
import VideoProgressBar from './Controls/VideoProgressBar/VideoProgressBar';
|
|
6
|
+
import VolumeSlider from './Controls/VolumeSlider/VolumeSlider';
|
|
7
|
+
import VideoButton from './Controls/VideoButton/VideoButton';
|
|
8
|
+
import VideoMenu from './Controls/VideoMenu/VideoMenu';
|
|
9
|
+
import videoText from '../videoText';
|
|
10
|
+
import { htmlAttrs } from '../../utils';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
14
|
+
|
|
15
|
+
const getIcon = icon => /*#__PURE__*/_jsx(Icon, {
|
|
16
|
+
icon: icon
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const ControlBarContainer = /*#__PURE__*/styled.div.withConfig({
|
|
20
|
+
displayName: "ControlBar__ControlBarContainer",
|
|
21
|
+
componentId: "components-web__sc-13y61ky-0"
|
|
22
|
+
})(_ref => {
|
|
23
|
+
let {
|
|
24
|
+
isHidden,
|
|
25
|
+
isMobile
|
|
26
|
+
} = _ref;
|
|
27
|
+
return {
|
|
28
|
+
width: '100%',
|
|
29
|
+
position: 'relative',
|
|
30
|
+
transition: 'opacity 0.4s',
|
|
31
|
+
opacity: isHidden ? 0 : 1,
|
|
32
|
+
display: isMobile ? 'none' : undefined
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const StyledControlBar = /*#__PURE__*/styled.div.withConfig({
|
|
36
|
+
displayName: "ControlBar__StyledControlBar",
|
|
37
|
+
componentId: "components-web__sc-13y61ky-1"
|
|
38
|
+
})(_ref2 => {
|
|
39
|
+
let {
|
|
40
|
+
padding
|
|
41
|
+
} = _ref2;
|
|
42
|
+
return {
|
|
43
|
+
boxSizing: 'border-box',
|
|
44
|
+
position: 'absolute',
|
|
45
|
+
width: '100%',
|
|
46
|
+
height: 56,
|
|
47
|
+
padding,
|
|
48
|
+
bottom: 0,
|
|
49
|
+
backgroundColor: 'rgba(42, 44, 46, 0.85)',
|
|
50
|
+
// TODO: replace with opaque greyThunder
|
|
51
|
+
margin: 'auto',
|
|
52
|
+
display: 'flex',
|
|
53
|
+
justifyContent: 'space-between',
|
|
54
|
+
zIndex: 9
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const VideoProgressBarContainer = /*#__PURE__*/styled.div.withConfig({
|
|
58
|
+
displayName: "ControlBar__VideoProgressBarContainer",
|
|
59
|
+
componentId: "components-web__sc-13y61ky-2"
|
|
60
|
+
})({
|
|
61
|
+
display: 'flex',
|
|
62
|
+
flexGrow: 1
|
|
63
|
+
});
|
|
64
|
+
const MenuContainer = /*#__PURE__*/styled.div.withConfig({
|
|
65
|
+
displayName: "ControlBar__MenuContainer",
|
|
66
|
+
componentId: "components-web__sc-13y61ky-3"
|
|
67
|
+
})(_ref3 => {
|
|
68
|
+
let {
|
|
69
|
+
isOpen,
|
|
70
|
+
menuBottom,
|
|
71
|
+
menuRight,
|
|
72
|
+
menuMarginLeft
|
|
73
|
+
} = _ref3;
|
|
74
|
+
return {
|
|
75
|
+
position: 'absolute',
|
|
76
|
+
bottom: menuBottom,
|
|
77
|
+
right: menuRight,
|
|
78
|
+
display: isOpen ? 'block' : 'none',
|
|
79
|
+
marginLeft: menuMarginLeft
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const ControlBar = _ref4 => {
|
|
84
|
+
let {
|
|
85
|
+
videoPlayer,
|
|
86
|
+
videoPlayerContainer,
|
|
87
|
+
sources,
|
|
88
|
+
tracks,
|
|
89
|
+
videoPlaying,
|
|
90
|
+
videoUnplayed,
|
|
91
|
+
videoBufferEnd,
|
|
92
|
+
isHidden = false,
|
|
93
|
+
videoLength,
|
|
94
|
+
videoCurrentTime,
|
|
95
|
+
videoCurrentVolume,
|
|
96
|
+
videoIsMuted,
|
|
97
|
+
setVolume,
|
|
98
|
+
isMobile,
|
|
99
|
+
tracksAvailable,
|
|
100
|
+
togglePlayPause,
|
|
101
|
+
setSeek,
|
|
102
|
+
toggleMute,
|
|
103
|
+
toggleFullscreen,
|
|
104
|
+
videoIsFullscreen,
|
|
105
|
+
setTextTracks,
|
|
106
|
+
selectedTextTrack,
|
|
107
|
+
resetInactivityTimer,
|
|
108
|
+
videoQuality,
|
|
109
|
+
setVideoQuality,
|
|
110
|
+
captionsMenuOpen,
|
|
111
|
+
setCaptionsMenuOpen,
|
|
112
|
+
qualityMenuOpen,
|
|
113
|
+
setQualityMenuOpen,
|
|
114
|
+
clearInactivityTimer,
|
|
115
|
+
copy,
|
|
116
|
+
compactModeThreshold,
|
|
117
|
+
videoPlayerWidth,
|
|
118
|
+
tokens,
|
|
119
|
+
variant,
|
|
120
|
+
...rest
|
|
121
|
+
} = _ref4;
|
|
122
|
+
const {
|
|
123
|
+
paddingTop,
|
|
124
|
+
paddingBottom,
|
|
125
|
+
paddingLeft: paddingLeftDefault,
|
|
126
|
+
paddingRight: paddingRightDefault,
|
|
127
|
+
paddingLeftCompactMode,
|
|
128
|
+
paddingRightCompactMode,
|
|
129
|
+
menuBottom,
|
|
130
|
+
menuRight,
|
|
131
|
+
menuMarginLeft,
|
|
132
|
+
captionsIcon,
|
|
133
|
+
settingsIcon,
|
|
134
|
+
minimizeIcon,
|
|
135
|
+
maximizeIcon
|
|
136
|
+
} = useThemeTokens('VideoControlBar', tokens, variant);
|
|
137
|
+
|
|
138
|
+
const parseVideoQuality = () => {
|
|
139
|
+
return sources.map(source => {
|
|
140
|
+
if (!source.isFallback) {
|
|
141
|
+
return {
|
|
142
|
+
name: source.qualityName,
|
|
143
|
+
value: source.qualityRank
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {};
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const parseTracks = () => {
|
|
152
|
+
const parsed = tracks.map((track, trackNumber) => {
|
|
153
|
+
return {
|
|
154
|
+
name: videoText[copy][track.language],
|
|
155
|
+
value: trackNumber
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
parsed.unshift({
|
|
159
|
+
name: videoText[copy].captionsNone,
|
|
160
|
+
value: -1
|
|
161
|
+
});
|
|
162
|
+
return parsed;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const paddingLeft = videoPlayerWidth > compactModeThreshold ? paddingLeftDefault : paddingLeftCompactMode;
|
|
166
|
+
const paddingRight = videoPlayerWidth > compactModeThreshold ? paddingRightDefault : paddingRightCompactMode;
|
|
167
|
+
const menuContainerStyleProps = {
|
|
168
|
+
menuBottom,
|
|
169
|
+
menuRight,
|
|
170
|
+
menuMarginLeft
|
|
171
|
+
};
|
|
172
|
+
return /*#__PURE__*/_jsx(ControlBarContainer, {
|
|
173
|
+
isHidden: isHidden,
|
|
174
|
+
isMobile: isMobile,
|
|
175
|
+
...selectProps(rest),
|
|
176
|
+
children: /*#__PURE__*/_jsxs(StyledControlBar, {
|
|
177
|
+
padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,
|
|
178
|
+
children: [/*#__PURE__*/_jsx(VideoProgressBarContainer, {
|
|
179
|
+
children: /*#__PURE__*/_jsx(VideoProgressBar, {
|
|
180
|
+
copy: copy,
|
|
181
|
+
videoPlayer: videoPlayer,
|
|
182
|
+
videoLength: videoLength,
|
|
183
|
+
videoCurrentTime: videoCurrentTime,
|
|
184
|
+
videoBufferEnd: videoBufferEnd,
|
|
185
|
+
setSeek: setSeek,
|
|
186
|
+
resetInactivityTimer: resetInactivityTimer
|
|
187
|
+
})
|
|
188
|
+
}), /*#__PURE__*/_jsx(VolumeSlider, {
|
|
189
|
+
videoPlayer: videoPlayer,
|
|
190
|
+
videoCurrentVolume: videoCurrentVolume,
|
|
191
|
+
setVolume: setVolume,
|
|
192
|
+
videoIsMuted: videoIsMuted,
|
|
193
|
+
toggleMute: toggleMute,
|
|
194
|
+
resetInactivityTimer: resetInactivityTimer,
|
|
195
|
+
copy: copy,
|
|
196
|
+
compactModeThreshold: compactModeThreshold,
|
|
197
|
+
videoPlayerWidth: videoPlayerWidth,
|
|
198
|
+
disableFocus: videoUnplayed
|
|
199
|
+
}), /*#__PURE__*/_jsxs(StackView, {
|
|
200
|
+
space: 3,
|
|
201
|
+
direction: "row",
|
|
202
|
+
children: [tracksAvailable && /*#__PURE__*/_jsx(VideoButton, {
|
|
203
|
+
disableFocus: videoUnplayed,
|
|
204
|
+
label: videoText[copy].captionsToggle,
|
|
205
|
+
icon: getIcon(captionsIcon),
|
|
206
|
+
onClick: () => {
|
|
207
|
+
setCaptionsMenuOpen(!captionsMenuOpen);
|
|
208
|
+
setQualityMenuOpen(false);
|
|
209
|
+
clearInactivityTimer();
|
|
210
|
+
},
|
|
211
|
+
onFocus: resetInactivityTimer,
|
|
212
|
+
onBlur: resetInactivityTimer
|
|
213
|
+
}), /*#__PURE__*/_jsx(VideoButton, {
|
|
214
|
+
disableFocus: videoUnplayed,
|
|
215
|
+
label: videoText[copy].qualityToggle,
|
|
216
|
+
icon: getIcon(settingsIcon),
|
|
217
|
+
onClick: () => {
|
|
218
|
+
setQualityMenuOpen(!qualityMenuOpen);
|
|
219
|
+
setCaptionsMenuOpen(false);
|
|
220
|
+
clearInactivityTimer();
|
|
221
|
+
},
|
|
222
|
+
onFocus: resetInactivityTimer,
|
|
223
|
+
onBlur: resetInactivityTimer
|
|
224
|
+
}), /*#__PURE__*/_jsx(VideoButton, {
|
|
225
|
+
disableFocus: videoUnplayed,
|
|
226
|
+
label: videoText[copy].fullScreenToggle,
|
|
227
|
+
icon: videoIsFullscreen ? getIcon(minimizeIcon) : getIcon(maximizeIcon),
|
|
228
|
+
onClick: toggleFullscreen,
|
|
229
|
+
onFocus: resetInactivityTimer,
|
|
230
|
+
onBlur: resetInactivityTimer
|
|
231
|
+
})]
|
|
232
|
+
}), captionsMenuOpen && /*#__PURE__*/_jsx(MenuContainer, {
|
|
233
|
+
isOpen: captionsMenuOpen,
|
|
234
|
+
...menuContainerStyleProps,
|
|
235
|
+
children: /*#__PURE__*/_jsx(VideoMenu, {
|
|
236
|
+
menuLabel: videoText[copy].captionsDialogue,
|
|
237
|
+
menuOptions: parseTracks(),
|
|
238
|
+
setSelection: setTextTracks,
|
|
239
|
+
selectedItem: selectedTextTrack,
|
|
240
|
+
copy: copy
|
|
241
|
+
})
|
|
242
|
+
}), qualityMenuOpen && /*#__PURE__*/_jsx(MenuContainer, {
|
|
243
|
+
isOpen: qualityMenuOpen,
|
|
244
|
+
...menuContainerStyleProps,
|
|
245
|
+
children: /*#__PURE__*/_jsx(VideoMenu, {
|
|
246
|
+
menuLabel: videoText[copy].qualityDialogue,
|
|
247
|
+
menuOptions: parseVideoQuality(),
|
|
248
|
+
setSelection: setVideoQuality,
|
|
249
|
+
selectedItem: videoQuality,
|
|
250
|
+
copy: copy
|
|
251
|
+
})
|
|
252
|
+
})]
|
|
253
|
+
})
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
ControlBar.propTypes = { ...selectedSystemPropTypes,
|
|
258
|
+
videoPlayer: PropTypes.object.isRequired,
|
|
259
|
+
videoPlayerContainer: PropTypes.object.isRequired,
|
|
260
|
+
sources: PropTypes.array.isRequired,
|
|
261
|
+
tracks: PropTypes.array,
|
|
262
|
+
videoPlaying: PropTypes.bool.isRequired,
|
|
263
|
+
videoUnplayed: PropTypes.bool.isRequired,
|
|
264
|
+
videoBufferEnd: PropTypes.number.isRequired,
|
|
265
|
+
isHidden: PropTypes.bool,
|
|
266
|
+
videoLength: PropTypes.number.isRequired,
|
|
267
|
+
videoCurrentTime: PropTypes.number.isRequired,
|
|
268
|
+
videoCurrentVolume: PropTypes.number.isRequired,
|
|
269
|
+
videoIsMuted: PropTypes.bool.isRequired,
|
|
270
|
+
setVolume: PropTypes.func.isRequired,
|
|
271
|
+
isMobile: PropTypes.bool.isRequired,
|
|
272
|
+
tracksAvailable: PropTypes.bool.isRequired,
|
|
273
|
+
togglePlayPause: PropTypes.func.isRequired,
|
|
274
|
+
setSeek: PropTypes.func.isRequired,
|
|
275
|
+
toggleMute: PropTypes.func.isRequired,
|
|
276
|
+
toggleFullscreen: PropTypes.func.isRequired,
|
|
277
|
+
videoIsFullscreen: PropTypes.bool.isRequired,
|
|
278
|
+
setTextTracks: PropTypes.func.isRequired,
|
|
279
|
+
selectedTextTrack: PropTypes.number.isRequired,
|
|
280
|
+
resetInactivityTimer: PropTypes.func.isRequired,
|
|
281
|
+
videoQuality: PropTypes.number.isRequired,
|
|
282
|
+
setVideoQuality: PropTypes.func.isRequired,
|
|
283
|
+
captionsMenuOpen: PropTypes.bool.isRequired,
|
|
284
|
+
setCaptionsMenuOpen: PropTypes.func.isRequired,
|
|
285
|
+
qualityMenuOpen: PropTypes.bool.isRequired,
|
|
286
|
+
setQualityMenuOpen: PropTypes.func.isRequired,
|
|
287
|
+
clearInactivityTimer: PropTypes.func.isRequired,
|
|
288
|
+
copy: PropTypes.oneOf(['en', 'fr']).isRequired,
|
|
289
|
+
compactModeThreshold: PropTypes.number.isRequired,
|
|
290
|
+
videoPlayerWidth: PropTypes.number.isRequired
|
|
291
|
+
};
|
|
292
|
+
export default ControlBar;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { useThemeTokens, selectSystemProps } from '@telus-uds/components-base';
|
|
5
|
+
import { htmlAttrs } from '../../../../utils';
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
8
|
+
const StyledButton = /*#__PURE__*/styled.button.withConfig({
|
|
9
|
+
displayName: "VideoButton__StyledButton",
|
|
10
|
+
componentId: "components-web__sc-kfw0tr-0"
|
|
11
|
+
})(_ref => {
|
|
12
|
+
let {
|
|
13
|
+
color
|
|
14
|
+
} = _ref;
|
|
15
|
+
return {
|
|
16
|
+
background: 'none',
|
|
17
|
+
border: 'none',
|
|
18
|
+
padding: 0,
|
|
19
|
+
cursor: 'pointer',
|
|
20
|
+
display: 'inline-flex',
|
|
21
|
+
alignItems: 'stretch',
|
|
22
|
+
'svg path': {
|
|
23
|
+
fill: color
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const VideoButton = _ref2 => {
|
|
29
|
+
let {
|
|
30
|
+
icon,
|
|
31
|
+
label,
|
|
32
|
+
disableFocus,
|
|
33
|
+
children,
|
|
34
|
+
tokens,
|
|
35
|
+
variant,
|
|
36
|
+
...rest
|
|
37
|
+
} = _ref2;
|
|
38
|
+
const {
|
|
39
|
+
color
|
|
40
|
+
} = useThemeTokens('VideoButton', tokens, variant);
|
|
41
|
+
|
|
42
|
+
const handleOnKeyDown = event => {
|
|
43
|
+
const key = event.key || event.keyCode; // Disables playing by space bar, as that can be used to click a button
|
|
44
|
+
|
|
45
|
+
if (key === ' ' || key === 32) {
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const handleClick = event => {
|
|
51
|
+
var _rest$onClick;
|
|
52
|
+
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
(_rest$onClick = rest.onClick) === null || _rest$onClick === void 0 ? void 0 : _rest$onClick.call(rest, event);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return /*#__PURE__*/_jsxs(StyledButton, {
|
|
58
|
+
"aria-label": label,
|
|
59
|
+
onKeyDown: handleOnKeyDown,
|
|
60
|
+
tabIndex: disableFocus ? '-1' : undefined,
|
|
61
|
+
color: color,
|
|
62
|
+
...selectProps(rest),
|
|
63
|
+
onClick: handleClick,
|
|
64
|
+
children: [icon, children]
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
VideoButton.propTypes = { ...selectedSystemPropTypes,
|
|
69
|
+
icon: PropTypes.element.isRequired,
|
|
70
|
+
label: PropTypes.string.isRequired,
|
|
71
|
+
disableFocus: PropTypes.bool.isRequired,
|
|
72
|
+
children: PropTypes.node
|
|
73
|
+
};
|
|
74
|
+
export default VideoButton;
|