@telus-uds/components-web 1.6.1 → 1.8.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.
Files changed (68) hide show
  1. package/.eslintignore +2 -0
  2. package/.vscode/settings.json +7 -0
  3. package/CHANGELOG.md +26 -2
  4. package/lib/BlockQuote/BlockQuote.js +173 -0
  5. package/lib/BlockQuote/index.js +13 -0
  6. package/lib/IconButton/IconButton.js +70 -0
  7. package/lib/IconButton/index.js +13 -0
  8. package/lib/Listbox/GroupControl.js +94 -0
  9. package/lib/Listbox/Listbox.js +164 -0
  10. package/lib/Listbox/ListboxGroup.js +129 -0
  11. package/lib/Listbox/ListboxItem.js +137 -0
  12. package/lib/Listbox/ListboxOverlay.js +89 -0
  13. package/lib/Listbox/PressableItem.js +149 -0
  14. package/lib/Listbox/index.js +13 -0
  15. package/lib/Modal/Modal.js +5 -1
  16. package/lib/Modal/ModalContent.js +3 -1
  17. package/lib/NavigationBar/resolveItemSelection.js +24 -0
  18. package/lib/Spinner/Spinner.js +234 -0
  19. package/lib/Spinner/SpinnerContent.js +107 -0
  20. package/lib/Spinner/constants.js +14 -0
  21. package/lib/Spinner/index.js +13 -0
  22. package/lib/baseExports.js +0 -6
  23. package/lib/index.js +37 -1
  24. package/lib/utils/useOverlaidPosition.js +246 -0
  25. package/lib-module/BlockQuote/BlockQuote.js +156 -0
  26. package/lib-module/BlockQuote/index.js +2 -0
  27. package/lib-module/IconButton/IconButton.js +52 -0
  28. package/lib-module/IconButton/index.js +2 -0
  29. package/lib-module/Listbox/GroupControl.js +80 -0
  30. package/lib-module/Listbox/Listbox.js +142 -0
  31. package/lib-module/Listbox/ListboxGroup.js +106 -0
  32. package/lib-module/Listbox/ListboxItem.js +112 -0
  33. package/lib-module/Listbox/ListboxOverlay.js +68 -0
  34. package/lib-module/Listbox/PressableItem.js +128 -0
  35. package/lib-module/Listbox/index.js +2 -0
  36. package/lib-module/Modal/Modal.js +5 -1
  37. package/lib-module/Modal/ModalContent.js +3 -1
  38. package/lib-module/NavigationBar/resolveItemSelection.js +16 -0
  39. package/lib-module/Spinner/Spinner.js +213 -0
  40. package/lib-module/Spinner/SpinnerContent.js +90 -0
  41. package/lib-module/Spinner/constants.js +4 -0
  42. package/lib-module/Spinner/index.js +2 -0
  43. package/lib-module/baseExports.js +1 -1
  44. package/lib-module/index.js +4 -0
  45. package/lib-module/utils/useOverlaidPosition.js +235 -0
  46. package/package.json +3 -3
  47. package/src/BlockQuote/BlockQuote.jsx +130 -0
  48. package/src/BlockQuote/index.js +3 -0
  49. package/src/IconButton/IconButton.jsx +46 -0
  50. package/src/IconButton/index.js +3 -0
  51. package/src/Listbox/GroupControl.jsx +65 -0
  52. package/src/Listbox/Listbox.jsx +148 -0
  53. package/src/Listbox/ListboxGroup.jsx +110 -0
  54. package/src/Listbox/ListboxItem.jsx +101 -0
  55. package/src/Listbox/ListboxOverlay.jsx +71 -0
  56. package/src/Listbox/PressableItem.jsx +121 -0
  57. package/src/Listbox/index.js +3 -0
  58. package/src/Modal/Modal.jsx +12 -2
  59. package/src/Modal/ModalContent.jsx +3 -0
  60. package/src/NavigationBar/resolveItemSelection.js +11 -0
  61. package/src/Spinner/Spinner.jsx +186 -0
  62. package/src/Spinner/SpinnerContent.jsx +76 -0
  63. package/src/Spinner/constants.js +4 -0
  64. package/src/Spinner/index.js +3 -0
  65. package/src/baseExports.js +0 -1
  66. package/src/index.js +4 -0
  67. package/src/utils/useOverlaidPosition.js +226 -0
  68. package/types/Spinner.d.ts +16 -0
@@ -0,0 +1,90 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import { ActivityIndicator, StackView, Typography, selectSystemProps } from '@telus-uds/components-base';
5
+ import { htmlAttrs } from '../utils';
6
+ import { BACKDROP_Z_INDEX, LARGE } from './constants';
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 Container = /*#__PURE__*/styled.div.withConfig({
11
+ displayName: "SpinnerContent__Container",
12
+ componentId: "components-web__sc-1c8bd8e-0"
13
+ })(_ref => {
14
+ let {
15
+ overlay
16
+ } = _ref;
17
+ return {
18
+ display: 'inline-flex',
19
+ flexDirection: 'column',
20
+ alignItems: 'center',
21
+ ...(overlay && {
22
+ position: 'absolute',
23
+ top: '50%',
24
+ left: '50%',
25
+ transform: 'translate(-50%, -50%)',
26
+ zIndex: BACKDROP_Z_INDEX
27
+ })
28
+ };
29
+ });
30
+
31
+ const SpinnerContent = _ref2 => {
32
+ let {
33
+ label,
34
+ overlay = false,
35
+ sizeVariant,
36
+ size,
37
+ thickness,
38
+ isStatic,
39
+ ...rest
40
+ } = _ref2;
41
+ return /*#__PURE__*/_jsx(Container, {
42
+ overlay: overlay,
43
+ children: /*#__PURE__*/_jsxs(StackView, {
44
+ space: 3,
45
+ tokens: {
46
+ alignItems: 'center'
47
+ },
48
+ children: [/*#__PURE__*/_jsx(ActivityIndicator, {
49
+ label: label,
50
+ tokens: {
51
+ size,
52
+ thickness
53
+ },
54
+ isStatic: isStatic,
55
+ ...selectProps(rest)
56
+ }), sizeVariant === LARGE && /*#__PURE__*/_jsx(Typography, {
57
+ children: label
58
+ })]
59
+ })
60
+ });
61
+ };
62
+
63
+ SpinnerContent.propTypes = { ...selectedSystemPropTypes,
64
+
65
+ /**
66
+ * Communicates a message to assistive technology while visible. This same message will appear underneath the spinner when its `size` is `large`.
67
+ */
68
+ label: PropTypes.string.isRequired,
69
+
70
+ /**
71
+ * Whether the container has to have an overlay styling.
72
+ */
73
+ overlay: PropTypes.bool,
74
+
75
+ /**
76
+ * Size (width and height) of the spinner.
77
+ */
78
+ size: PropTypes.number,
79
+
80
+ /**
81
+ * The size of the spinner
82
+ */
83
+ sizeVariant: PropTypes.oneOf(['large', 'small']),
84
+
85
+ /**
86
+ * If true, it should render a static spinner
87
+ */
88
+ isStatic: PropTypes.bool
89
+ };
90
+ export default SpinnerContent;
@@ -0,0 +1,4 @@
1
+ export const BACKDROP_OPACITY = 0.06;
2
+ export const BACKDROP_Z_INDEX = 1400;
3
+ export const LARGE = 'large';
4
+ export const SMALL = 'small';
@@ -0,0 +1,2 @@
1
+ import Spinner from './Spinner';
2
+ export default Spinner;
@@ -5,7 +5,7 @@ export {
5
5
  /**
6
6
  * Most base components should be re-exported as-is.
7
7
  */
8
- A11yText, ActivityIndicator, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, Card, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, IconButton, InputLabel, InputSupports, Link, MultiSelectFilter, Notification, Pagination, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography,
8
+ A11yText, ActivityIndicator, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, Card, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, InputLabel, InputSupports, Link, MultiSelectFilter, Notification, Pagination, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography,
9
9
  /*
10
10
  * Most utilities exported from @telus-uds/components-base are for building systems, not apps.
11
11
  * Re-export only those utilities with a stable API and known use cases within apps / pages.
@@ -11,10 +11,14 @@ export { default as ExpandCollapseMini } from './ExpandCollapseMini';
11
11
  export { default as Callout } from './Callout';
12
12
  export { default as PriceLockup } from './PriceLockup';
13
13
  export { default as Footnote } from './Footnote';
14
+ export { default as IconButton } from './IconButton';
14
15
  export { transformGradient } from './utils';
15
16
  export { default as Breadcrumbs } from './Breadcrumbs';
17
+ export { default as BlockQuote } from './BlockQuote';
16
18
  export { default as Toast } from './Toast';
17
19
  export { default as Table } from './Table';
18
20
  export { default as Image } from './Image';
19
21
  export { default as WaffleGrid } from './WaffleGrid';
22
+ export { default as Spinner } from './Spinner';
23
+ export { default as Listbox } from './Listbox';
20
24
  export * from './baseExports';
@@ -0,0 +1,235 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react'; // TODO: add react-native as a peer dep and support native apps too.
2
+ // That requires some fiddling with Allium repo storybook config, babel, etc,
3
+ // unless ADS gets merged back into UDS monorepo.
4
+
5
+ import Dimensions from "react-native-web/dist/exports/Dimensions";
6
+
7
+ const adjustHorizontalToFit = (initialOffset, windowWidth, sourceWidth) => {
8
+ const offset = Math.max(0, initialOffset);
9
+ const otherEdgeOverflow = Math.max(0, offset + sourceWidth - windowWidth);
10
+ const tooWideBy = Math.max(0, otherEdgeOverflow - offset);
11
+ const adjusted = {
12
+ offset: Math.max(0, offset - otherEdgeOverflow)
13
+ };
14
+ if (tooWideBy) adjusted.width = Math.max(0, sourceWidth - tooWideBy);
15
+ return adjusted;
16
+ };
17
+
18
+ const getPosition = _ref => {
19
+ let {
20
+ edge,
21
+ fromEdge,
22
+ sourceSize
23
+ } = _ref;
24
+
25
+ switch (edge) {
26
+ case 'near':
27
+ return fromEdge;
28
+
29
+ case 'mid':
30
+ return fromEdge + sourceSize / 2;
31
+
32
+ case 'far':
33
+ return fromEdge + sourceSize;
34
+
35
+ default:
36
+ return 0;
37
+ }
38
+ };
39
+
40
+ const getEdgeType = (align, alignSide) => {
41
+ const alignTo = align[alignSide];
42
+ const edge = ['center', 'middle'].includes(alignTo) && 'mid' || (alignSide === alignTo ? 'near' : 'far');
43
+ return edge;
44
+ };
45
+ /**
46
+ * Based on UDS's private getTooltipPosition but generalised.
47
+ *
48
+ * Used for absolute positioning of the tooltip. Since the tooltip is always centered relatively
49
+ * to the source (button) and we have a limited set of positions, an easy and consistent way
50
+ * of positioning it is to check all of the possible positions and pick one that will be rendered
51
+ * within the window bounds. This way we can also rely on the tooltip being actually rendered
52
+ * before it is shown, which makes it account for the width being limiting in styles, custom font
53
+ * rendering, etc.
54
+ */
55
+
56
+
57
+ function getOverlaidPosition(_ref2) {
58
+ let {
59
+ sourceLayout,
60
+ targetDimensions,
61
+ windowDimensions,
62
+ offsets = {},
63
+ align
64
+ } = _ref2;
65
+ // Web-only: this will be difficult to mimic on native because there's no global scroll position.
66
+ // TODO: wire something in e.g. a scroll ref accessible from a provider included in Allium provider
67
+ // that can be passed to the appropriate ScrollView?
68
+ const {
69
+ scrollX = 0,
70
+ scrollY = 0
71
+ } = typeof window === 'object' ? window : {}; // Will have top, bottom, left and/or right offsets depending on `align`
72
+
73
+ const positioning = {};
74
+ if (align.top) positioning.top = getPosition({
75
+ edge: getEdgeType(align, 'top'),
76
+ fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0),
77
+ sourceSize: sourceLayout.height
78
+ });
79
+ if (align.middle) positioning.top = getPosition({
80
+ edge: getEdgeType(align, 'middle'),
81
+ fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0) - targetDimensions.height / 2,
82
+ sourceSize: sourceLayout.height
83
+ });
84
+ if (align.bottom) positioning.bottom = getPosition({
85
+ edge: getEdgeType(align, 'bottom'),
86
+ fromEdge: windowDimensions.height - (sourceLayout.y + scrollY + sourceLayout.height - (offsets.vertical ?? 0)),
87
+ sourceSize: sourceLayout.height
88
+ });
89
+ if (align.left) positioning.left = getPosition({
90
+ edge: getEdgeType(align, 'left'),
91
+ fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0),
92
+ sourceSize: sourceLayout.width
93
+ });
94
+ if (align.center) positioning.left = getPosition({
95
+ edge: getEdgeType(align, 'center'),
96
+ fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0) - targetDimensions.width / 2,
97
+ sourceSize: sourceLayout.width
98
+ });
99
+ if (align.right) positioning.right = getPosition({
100
+ edge: getEdgeType(align, 'right'),
101
+ fromEdge: windowDimensions.width - (sourceLayout.x + scrollX + sourceLayout.width - (offsets.horizontal ?? 0)),
102
+ sourceSize: sourceLayout.width
103
+ });
104
+
105
+ if (!(align.left && align.right)) {
106
+ // Check if the position and/or width need adjusting to fit on the screen
107
+ const side = align.right ? 'right' : 'left';
108
+ const adjusted = adjustHorizontalToFit(positioning[side], windowDimensions.width, sourceLayout.width);
109
+ if (typeof adjusted.width === 'number') positioning.width = adjusted.width;
110
+
111
+ if (typeof adjusted.offset === 'number') {
112
+ positioning[side] = adjusted.offset;
113
+ }
114
+ }
115
+
116
+ return positioning;
117
+ }
118
+ /**
119
+ * Positions an element in a modal or portal so that it appears tooltip-like below the
120
+ * target element.
121
+ *
122
+ * @TODO - add support for positioning other than 'below' like UDS's tooltip (this is not
123
+ * a small task because UDS's tooltip logic only really works for short text - it might be
124
+ * better to use a third-party library).
125
+ */
126
+
127
+
128
+ const useOverlaidPosition = _ref3 => {
129
+ let {
130
+ isShown = false,
131
+ offsets,
132
+ // By default, align the overlaid target's `top` to the bottom of the source, and center horizontally.
133
+ align = {
134
+ center: 'center',
135
+ top: 'bottom'
136
+ }
137
+ } = _ref3;
138
+ // Element in main document flow that the targetRef element is positioned around
139
+ const sourceRef = useRef(null);
140
+ const [sourceLayout, setSourceLayout] = useState(null); // Element in a modal or portal overlay positioned to appear adjacent to sourceRef
141
+
142
+ const targetRef = useRef(null);
143
+ const [targetDimensions, setTargetDimensions] = useState(null);
144
+ const [windowDimensions, setWindowDimensions] = useState(null);
145
+ const onTargetLayout = useCallback(_ref4 => {
146
+ let {
147
+ nativeEvent: {
148
+ layout: {
149
+ width,
150
+ height
151
+ }
152
+ }
153
+ } = _ref4;
154
+ // NOTE: UDS's Tooltip logic injects some additional width to allow for antialiasing etc of text,
155
+ // avoiding adding unnecessary line breaks to text that is slightly wider than it thinks it is.
156
+ // That is probably something specific to text tooltips that doesn't belong in a generic hook.
157
+ setTargetDimensions(previousDimensions => {
158
+ // Re-render on first non-zero width / height: avoid infinite loops on changes, or mispositioning
159
+ // if user scrolls while a slidedown animation is changing the height and recalculating position.
160
+ if (!previousDimensions && width && height) {
161
+ return {
162
+ width,
163
+ height
164
+ };
165
+ }
166
+
167
+ return previousDimensions;
168
+ });
169
+ }, []);
170
+ const readyToShow = Boolean(isShown && sourceRef.current);
171
+ useEffect(() => {
172
+ const handleDimensionsChange = _ref5 => {
173
+ var _sourceRef$current;
174
+
175
+ let {
176
+ window
177
+ } = _ref5;
178
+ (_sourceRef$current = sourceRef.current) === null || _sourceRef$current === void 0 ? void 0 : _sourceRef$current.measureInWindow((x, y, width, height) => {
179
+ // Could add a debouncer here if there's too many rerenders during gradual resizes
180
+ setWindowDimensions(window);
181
+ setSourceLayout({
182
+ x,
183
+ y,
184
+ width,
185
+ height
186
+ });
187
+ });
188
+ };
189
+
190
+ let subscription;
191
+
192
+ const unsubscribe = () => {
193
+ var _subscription;
194
+
195
+ if (typeof ((_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.remove) === 'function') {
196
+ // React Native >=0.65.0
197
+ subscription.remove();
198
+ } else if (typeof Dimensions.removeEventListener === 'function') {
199
+ // React Native <0.65.0
200
+ Dimensions.removeEventListener('change', handleDimensionsChange);
201
+ }
202
+
203
+ setSourceLayout(null);
204
+ setTargetDimensions(null);
205
+ };
206
+
207
+ if (readyToShow) {
208
+ subscription = Dimensions.addEventListener('change', handleDimensionsChange);
209
+ handleDimensionsChange({
210
+ window: Dimensions.get('window')
211
+ });
212
+ } else {
213
+ unsubscribe();
214
+ }
215
+
216
+ return unsubscribe;
217
+ }, [readyToShow]);
218
+ const isReady = Boolean(isShown && sourceLayout && windowDimensions && targetDimensions);
219
+ const overlaidPosition = isReady ? getOverlaidPosition({
220
+ sourceLayout,
221
+ targetDimensions,
222
+ windowDimensions,
223
+ offsets,
224
+ align
225
+ }) : {};
226
+ return {
227
+ overlaidPosition,
228
+ sourceRef,
229
+ targetRef,
230
+ onTargetLayout,
231
+ isReady
232
+ };
233
+ };
234
+
235
+ export default useOverlaidPosition;
package/package.json CHANGED
@@ -5,11 +5,11 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "@gorhom/portal": "^1.0.14",
8
- "@telus-uds/components-base": "1.35.0",
8
+ "@telus-uds/components-base": "1.37.0",
9
9
  "@telus-uds/system-constants": "^1.2.0",
10
10
  "react-dates": "^21.8.0",
11
11
  "react-moment-proptypes": "^1.8.1",
12
- "@telus-uds/system-theme-tokens": "^2.20.0",
12
+ "@telus-uds/system-theme-tokens": "^2.22.0",
13
13
  "prop-types": "^15.7.2",
14
14
  "lodash.omit": "^4.5.0",
15
15
  "lodash.throttle": "^4.1.1",
@@ -59,5 +59,5 @@
59
59
  "skip": true
60
60
  },
61
61
  "types": "types/index.d.ts",
62
- "version": "1.6.1"
62
+ "version": "1.8.0"
63
63
  }
@@ -0,0 +1,130 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import {
4
+ Link,
5
+ selectSystemProps,
6
+ StackView,
7
+ Typography,
8
+ useThemeTokens,
9
+ withLinkRouter
10
+ } from '@telus-uds/components-base'
11
+ import styled from 'styled-components'
12
+ import { htmlAttrs, transformGradient } from '../utils'
13
+
14
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
15
+
16
+ const BlockQuoteContainer = styled.blockquote`
17
+ margin: 0;
18
+ position: relative;
19
+ padding-left: ${({ paddingLeft }) => `${paddingLeft}px`};
20
+ padding-right: ${({ paddingRight }) => `${paddingRight}px`};
21
+ padding-bottom: ${({ paddingBottom }) => `${paddingBottom}px`};
22
+ padding-top: ${({ paddingTop }) => `${paddingTop}px`};
23
+ &::before {
24
+ content: '';
25
+ left: 0;
26
+ top: 0;
27
+ position: absolute;
28
+ height: 100%;
29
+ width: ${({ width }) => `${width}px`};
30
+ background: ${({ backgroundGradient }) =>
31
+ backgroundGradient && transformGradient(backgroundGradient)};
32
+ }
33
+ `
34
+
35
+ const QuoteContainer = styled.div`
36
+ margin-bottom: ${({ marginBottom }) => `${marginBottom}px`};
37
+ `
38
+
39
+ const BlockQuote = ({
40
+ children,
41
+ link,
42
+ additionalInfo,
43
+ linkHref,
44
+ textStyle = 'large',
45
+ LinkRouter,
46
+ linkRouterProps,
47
+ tokens,
48
+ variant,
49
+ ...rest
50
+ }) => {
51
+ const {
52
+ color,
53
+ paddingTop,
54
+ paddingBottom,
55
+ paddingLeft,
56
+ paddingRight,
57
+ marginBottom,
58
+ width,
59
+ backgroundGradient
60
+ } = useThemeTokens('BlockQuote', tokens, variant)
61
+
62
+ const mappedTextSize = textStyle === 'heading' ? 'h3' : textStyle
63
+ const renderLink = () => {
64
+ if (linkHref) {
65
+ return (
66
+ <Link
67
+ href={linkHref}
68
+ tokens={{ blockFontWeight: '500', color }}
69
+ variant={{ alternative: true }}
70
+ LinkRouter={LinkRouter}
71
+ linkRouterProps={linkRouterProps}
72
+ >
73
+ {link}
74
+ </Link>
75
+ )
76
+ }
77
+
78
+ return <Typography tokens={{ color, fontWeight: '500' }}>{link}</Typography>
79
+ }
80
+
81
+ const renderQuote = () => {
82
+ const quote = (
83
+ <Typography tokens={{ color, fontWeight: '400' }} variant={{ size: mappedTextSize }}>
84
+ {children}
85
+ </Typography>
86
+ )
87
+
88
+ if (additionalInfo || link) {
89
+ return <QuoteContainer marginBottom={marginBottom}>{quote}</QuoteContainer>
90
+ }
91
+
92
+ return quote
93
+ }
94
+
95
+ return (
96
+ <BlockQuoteContainer
97
+ {...selectProps(rest)}
98
+ paddingTop={paddingTop}
99
+ paddingBottom={paddingBottom}
100
+ paddingLeft={paddingLeft}
101
+ paddingRight={paddingRight}
102
+ width={width}
103
+ backgroundGradient={backgroundGradient}
104
+ >
105
+ {renderQuote()}
106
+ {(additionalInfo || link) && (
107
+ <StackView space={0}>
108
+ {link && renderLink()}
109
+ {additionalInfo && (
110
+ <Typography tokens={{ color }} variant={{ size: 'small' }}>
111
+ {additionalInfo}
112
+ </Typography>
113
+ )}
114
+ </StackView>
115
+ )}
116
+ </BlockQuoteContainer>
117
+ )
118
+ }
119
+
120
+ BlockQuote.propTypes = {
121
+ ...selectedSystemPropTypes,
122
+ ...withLinkRouter.propTypes,
123
+ children: PropTypes.node.isRequired,
124
+ link: PropTypes.string,
125
+ linkHref: PropTypes.string,
126
+ additionalInfo: PropTypes.string,
127
+ textStyle: PropTypes.oneOf(['large', 'heading'])
128
+ }
129
+
130
+ export default BlockQuote
@@ -0,0 +1,3 @@
1
+ import BlockQuote from './BlockQuote'
2
+
3
+ export default BlockQuote
@@ -0,0 +1,46 @@
1
+ import React, { forwardRef } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import { IconButton as IconButtonBase, useThemeTokens } from '@telus-uds/components-base'
4
+
5
+ const IconButton = forwardRef(({ icon, action, tokens, variant = {}, ...iconButtonProps }, ref) => {
6
+ const variantWithAction = action && !variant.action ? { ...variant, action } : variant
7
+ const { icon: themeIcon } = useThemeTokens('IconButton', tokens, variantWithAction)
8
+
9
+ return (
10
+ // If we want the arrow icons to have directional animation instead of scale, we can pass
11
+ // either appropriate iconTransateX/Y here, or define and pass variants like { direction: 'left' }
12
+ // which have theme rules that set `iconTranslateX` tokens in the theme rules and unset `iconScale`.
13
+ <IconButtonBase
14
+ ref={ref}
15
+ {...iconButtonProps}
16
+ tokens={tokens}
17
+ variant={variant}
18
+ icon={icon ?? themeIcon}
19
+ />
20
+ )
21
+ })
22
+
23
+ const multiBrandIconNames = [
24
+ 'add',
25
+ 'subtract',
26
+ 'close',
27
+ 'play',
28
+ 'moveUp',
29
+ 'moveDown',
30
+ 'moveLeft',
31
+ 'moveRight',
32
+ 'expand'
33
+ ]
34
+
35
+ IconButton.displayName = 'IconButton'
36
+ const propsWithoutIcon = ({ icon, ...props }) => props
37
+ IconButton.propTypes = {
38
+ ...propsWithoutIcon(IconButtonBase.propTypes),
39
+ // eslint-disable-next-line react/require-default-props
40
+ action: PropTypes.oneOf(multiBrandIconNames),
41
+ icon: PropTypes.func
42
+ }
43
+
44
+ IconButton.defaultProps = { icon: null }
45
+
46
+ export default IconButton
@@ -0,0 +1,3 @@
1
+ import IconButton from './IconButton'
2
+
3
+ export default IconButton
@@ -0,0 +1,65 @@
1
+ import React from 'react'
2
+ import styled from 'styled-components'
3
+ import PropTypes from 'prop-types'
4
+ import { Icon, Spacer, useThemeTokens } from '@telus-uds/components-base'
5
+
6
+ const StyledControlWrapper = styled.div(({ focus, tokens }) => ({
7
+ fontFamily: `${tokens.groupFontName}${tokens.groupFontWeight}normal`,
8
+ fontSize: tokens.groupFontSize,
9
+ color: tokens.groupColor,
10
+ textDecoration: tokens.itemTextDecoration,
11
+ backgroundColor: tokens.groupBackgroundColor,
12
+ outline: tokens.itemOutline,
13
+ width: '100%',
14
+ display: 'flex',
15
+ justifyContent: 'space-between',
16
+ ...(focus
17
+ ? {
18
+ border: `${tokens.groupBorderWidth} solid ${tokens.groupBorderColor}`,
19
+ borderRadius: tokens.groupBorderRadius,
20
+ paddingLeft: `calc(${tokens.groupPaddingLeft}px - ${tokens.groupBorderWidth}px)`,
21
+ paddingRight: `calc(${tokens.groupPaddingRight}px - ${tokens.groupBorderWidth}px)`,
22
+ paddingTop: `calc(${tokens.groupPaddingTop}px - ${tokens.groupBorderWidth}px)`,
23
+ paddingBottom: `calc(${tokens.groupPaddingBottom}px - ${tokens.groupBorderWidth}px)`
24
+ }
25
+ : {
26
+ paddingLeft: tokens.groupPaddingLeft,
27
+ paddingRight: tokens.groupPaddingRight,
28
+ paddingTop: tokens.groupPaddingTop,
29
+ paddingBottom: tokens.groupPaddingBottom
30
+ })
31
+ }))
32
+
33
+ const GroupControl = ({ expanded, pressed, hover, focus, current, label }) => {
34
+ const tokens = useThemeTokens(
35
+ 'ListBox',
36
+ {},
37
+ {},
38
+ {
39
+ expanded,
40
+ pressed,
41
+ hover,
42
+ current,
43
+ focus
44
+ }
45
+ )
46
+
47
+ return (
48
+ <StyledControlWrapper {...{ focus, tokens }}>
49
+ {label}
50
+ <Spacer space={1} direction="row" />
51
+ <Icon icon={tokens.groupIcon} variant={{ size: 'micro' }} />
52
+ </StyledControlWrapper>
53
+ )
54
+ }
55
+
56
+ GroupControl.propTypes = {
57
+ expanded: PropTypes.bool,
58
+ pressed: PropTypes.bool,
59
+ hover: PropTypes.bool,
60
+ focus: PropTypes.bool,
61
+ current: PropTypes.bool,
62
+ label: PropTypes.string
63
+ }
64
+
65
+ export default GroupControl