@telus-uds/components-web 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -2
- package/lib/Breadcrumbs/Breadcrumbs.js +247 -0
- package/lib/Breadcrumbs/Item/Item.js +165 -0
- package/lib/Breadcrumbs/index.js +15 -0
- package/lib/Callout/Callout.js +121 -0
- package/lib/Callout/index.js +13 -0
- package/lib/DatePicker/CalendarContainer.js +221 -0
- package/lib/DatePicker/DatePicker.js +329 -0
- package/lib/DatePicker/dictionary.js +134 -0
- package/lib/DatePicker/index.js +13 -0
- package/lib/DatePicker/reactDatesCss.js +12 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +75 -0
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +95 -0
- package/lib/ExpandCollapseMini/index.js +13 -0
- package/lib/Footnote/Footnote.js +571 -0
- package/lib/Footnote/FootnoteLink.js +149 -0
- package/lib/Footnote/dictionary.js +19 -0
- package/lib/Footnote/index.js +16 -0
- package/lib/Paragraph/Paragraph.js +107 -0
- package/lib/Paragraph/index.js +13 -0
- package/lib/PreviewCard/AuthorDate.js +64 -0
- package/lib/PreviewCard/PreviewCard.js +236 -0
- package/lib/PreviewCard/index.js +13 -0
- package/lib/PriceLockup/PriceLockup.js +237 -0
- package/lib/PriceLockup/index.js +13 -0
- package/lib/PriceLockup/tokens.js +131 -0
- package/lib/ResponsiveImage/ResponsiveImage.js +115 -0
- package/lib/ResponsiveImage/index.js +13 -0
- package/lib/Ribbon/Ribbon.js +0 -1
- package/lib/Span/Span.js +88 -0
- package/lib/Span/index.js +13 -0
- package/lib/index.js +91 -1
- package/lib/shared/FullBleedContent/FullBleedContent.js +121 -0
- package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +73 -0
- package/lib/shared/FullBleedContent/index.js +29 -0
- package/lib/shared/FullBleedContent/useFullBleedContentProps.js +73 -0
- package/lib/utils/index.js +32 -0
- package/lib/utils/logger.js +31 -0
- package/lib/utils/media.js +54 -0
- package/lib/utils/renderStructuredContent.js +89 -0
- package/lib/utils/useTypographyTheme.js +32 -0
- package/lib-module/Breadcrumbs/Breadcrumbs.js +228 -0
- package/lib-module/Breadcrumbs/Item/Item.js +141 -0
- package/lib-module/Breadcrumbs/index.js +1 -0
- package/lib-module/Callout/Callout.js +106 -0
- package/lib-module/Callout/index.js +2 -0
- package/lib-module/DatePicker/CalendarContainer.js +208 -0
- package/lib-module/DatePicker/DatePicker.js +302 -0
- package/lib-module/DatePicker/dictionary.js +127 -0
- package/lib-module/DatePicker/index.js +2 -0
- package/lib-module/DatePicker/reactDatesCss.js +3 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +56 -0
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +80 -0
- package/lib-module/ExpandCollapseMini/index.js +2 -0
- package/lib-module/Footnote/Footnote.js +541 -0
- package/lib-module/Footnote/FootnoteLink.js +130 -0
- package/lib-module/Footnote/dictionary.js +12 -0
- package/lib-module/Footnote/index.js +4 -0
- package/lib-module/Paragraph/Paragraph.js +89 -0
- package/lib-module/Paragraph/index.js +2 -0
- package/lib-module/PreviewCard/AuthorDate.js +53 -0
- package/lib-module/PreviewCard/PreviewCard.js +211 -0
- package/lib-module/PreviewCard/index.js +2 -0
- package/lib-module/PriceLockup/PriceLockup.js +213 -0
- package/lib-module/PriceLockup/index.js +2 -0
- package/lib-module/PriceLockup/tokens.js +120 -0
- package/lib-module/ResponsiveImage/ResponsiveImage.js +100 -0
- package/lib-module/ResponsiveImage/index.js +2 -0
- package/lib-module/Ribbon/Ribbon.js +1 -2
- package/lib-module/Span/Span.js +70 -0
- package/lib-module/Span/index.js +2 -0
- package/lib-module/index.js +10 -0
- package/lib-module/shared/FullBleedContent/FullBleedContent.js +106 -0
- package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +65 -0
- package/lib-module/shared/FullBleedContent/index.js +4 -0
- package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +65 -0
- package/lib-module/utils/index.js +5 -1
- package/lib-module/utils/logger.js +18 -0
- package/lib-module/utils/media.js +46 -0
- package/lib-module/utils/renderStructuredContent.js +77 -0
- package/lib-module/utils/useTypographyTheme.js +24 -0
- package/package.json +9 -5
- package/src/Breadcrumbs/Breadcrumbs.jsx +222 -0
- package/src/Breadcrumbs/Item/Item.jsx +127 -0
- package/src/Breadcrumbs/index.js +1 -0
- package/src/Callout/Callout.jsx +76 -0
- package/src/Callout/index.js +3 -0
- package/src/DatePicker/CalendarContainer.jsx +210 -0
- package/src/DatePicker/DatePicker.jsx +303 -0
- package/src/DatePicker/dictionary.js +92 -0
- package/src/DatePicker/index.js +3 -0
- package/src/DatePicker/reactDatesCss.js +892 -0
- package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +48 -0
- package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +67 -0
- package/src/ExpandCollapseMini/index.js +3 -0
- package/src/Footnote/Footnote.jsx +468 -0
- package/src/Footnote/FootnoteLink.jsx +120 -0
- package/src/Footnote/dictionary.js +12 -0
- package/src/Footnote/index.js +6 -0
- package/src/Paragraph/Paragraph.jsx +79 -0
- package/src/Paragraph/index.js +3 -0
- package/src/PreviewCard/AuthorDate.jsx +31 -0
- package/src/PreviewCard/PreviewCard.jsx +201 -0
- package/src/PreviewCard/index.js +3 -0
- package/src/PriceLockup/PriceLockup.jsx +210 -0
- package/src/PriceLockup/index.js +3 -0
- package/src/PriceLockup/tokens.js +58 -0
- package/src/ResponsiveImage/ResponsiveImage.jsx +77 -0
- package/src/ResponsiveImage/index.js +3 -0
- package/src/Ribbon/Ribbon.jsx +0 -1
- package/src/Span/Span.jsx +66 -0
- package/src/Span/index.js +3 -0
- package/src/index.js +10 -0
- package/src/shared/FullBleedContent/FullBleedContent.jsx +90 -0
- package/src/shared/FullBleedContent/getFullBleedBorderRadius.js +55 -0
- package/src/shared/FullBleedContent/index.js +6 -0
- package/src/shared/FullBleedContent/useFullBleedContentProps.js +63 -0
- package/src/utils/index.js +5 -1
- package/src/utils/logger.js +20 -0
- package/src/utils/media.js +40 -0
- package/src/utils/renderStructuredContent.jsx +73 -0
- package/src/utils/useTypographyTheme.js +14 -0
- package/types/Callout.d.ts +13 -0
- package/types/DatePicker.d.ts +21 -0
- package/types/Footnote.d.ts +21 -0
- package/types/FootnoteLink.d.ts +20 -0
- package/types/PriceLockup.d.ts +22 -0
- package/types/common.d.ts +14 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
15
|
+
|
|
16
|
+
var _dictionary = _interopRequireDefault(require("./dictionary"));
|
|
17
|
+
|
|
18
|
+
var _utils = require("../utils");
|
|
19
|
+
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
25
|
+
|
|
26
|
+
const StyledSup = /*#__PURE__*/_styledComponents.default.sup.withConfig({
|
|
27
|
+
displayName: "FootnoteLink__StyledSup",
|
|
28
|
+
componentId: "components-web__sc-17nd7xo-0"
|
|
29
|
+
})(_ref => {
|
|
30
|
+
let {
|
|
31
|
+
fontSize = 'smaller',
|
|
32
|
+
lineHeight,
|
|
33
|
+
paddingLeft,
|
|
34
|
+
paddingRight
|
|
35
|
+
} = _ref;
|
|
36
|
+
return {
|
|
37
|
+
border: 0,
|
|
38
|
+
color: 'inherit',
|
|
39
|
+
cursor: 'pointer',
|
|
40
|
+
fontSize,
|
|
41
|
+
lineHeight,
|
|
42
|
+
margin: 0,
|
|
43
|
+
paddingVertical: 0,
|
|
44
|
+
paddingLeft,
|
|
45
|
+
paddingRight,
|
|
46
|
+
textDecoration: 'underline'
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Use `FootnoteLink` to open `Footnote` component and display related legal content.
|
|
51
|
+
*
|
|
52
|
+
* ## Usage Criteria
|
|
53
|
+
*
|
|
54
|
+
* - Use FootnoteLink to open a Footnote component and display related legal content.
|
|
55
|
+
* - Avoid using FootnoteLink if there is only one annotation on a page. Consider including
|
|
56
|
+
* the annotation as part of the content whenever possible.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const FootnoteLink = _ref2 => {
|
|
61
|
+
let {
|
|
62
|
+
copy = 'en',
|
|
63
|
+
number = [],
|
|
64
|
+
onClick,
|
|
65
|
+
fontSize,
|
|
66
|
+
tokens,
|
|
67
|
+
variant = {},
|
|
68
|
+
...rest
|
|
69
|
+
} = _ref2;
|
|
70
|
+
const {
|
|
71
|
+
lineHeight,
|
|
72
|
+
paddingLeft,
|
|
73
|
+
paddingRight
|
|
74
|
+
} = (0, _componentsBase.useThemeTokens)('FootnoteLink', tokens, variant);
|
|
75
|
+
const numbers = Array.isArray(number) ? number : [number];
|
|
76
|
+
const refs = numbers.map(() => /*#__PURE__*/_react.default.createRef());
|
|
77
|
+
|
|
78
|
+
const handleClick = index => {
|
|
79
|
+
onClick(numbers[index], refs[index]);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const getCopy = (0, _componentsBase.useCopy)({
|
|
83
|
+
dictionary: _dictionary.default,
|
|
84
|
+
copy
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const handleOnClick = (event, index) => {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
event.stopPropagation();
|
|
90
|
+
handleClick(index);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const handleOnKeyDown = (event, index) => {
|
|
94
|
+
if (event.key === 'Enter' || event.key === 13) {
|
|
95
|
+
handleClick(index);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
100
|
+
children: numbers.map((num, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledSup, {
|
|
101
|
+
onKeyDown: event => handleOnKeyDown(event, index),
|
|
102
|
+
role: "button",
|
|
103
|
+
"aria-label": getCopy('a11yLabel'),
|
|
104
|
+
ref: refs[index],
|
|
105
|
+
onClick: event => handleOnClick(event, index),
|
|
106
|
+
fontSize: fontSize,
|
|
107
|
+
lineHeight: lineHeight,
|
|
108
|
+
paddingLeft: paddingLeft,
|
|
109
|
+
paddingRight: paddingRight,
|
|
110
|
+
...selectProps(rest),
|
|
111
|
+
children: `${num}${index !== numbers.length - 1 ? ',' : ''}`
|
|
112
|
+
}, num))
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const copyShape = _propTypes.default.shape({
|
|
117
|
+
a11yLabel: _propTypes.default.string.isRequired
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
FootnoteLink.propTypes = { ...selectedSystemPropTypes,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Use the `copy` prop to either select provided English or French copy by passing 'en' or 'fr' respectively.
|
|
124
|
+
* To provide your own, pass a JSON object with the key `a11yLabel`.
|
|
125
|
+
*/
|
|
126
|
+
copy: _propTypes.default.oneOfType([_propTypes.default.oneOf(['en', 'fr']), copyShape]),
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The footnote number, or multiple numbers if passed as an array.
|
|
130
|
+
* If using an array, a comma-separated group of numbers will be rendered as superscript.
|
|
131
|
+
*/
|
|
132
|
+
number: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.arrayOf(_propTypes.default.number), _propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]).isRequired,
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A callback function to handle the click of a FootnoteLink.
|
|
136
|
+
*/
|
|
137
|
+
onClick: _propTypes.default.func.isRequired,
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Override default `fontSize` to set specific font size value
|
|
141
|
+
*/
|
|
142
|
+
fontSize: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
143
|
+
};
|
|
144
|
+
FootnoteLink.defaultProps = {
|
|
145
|
+
copy: 'en',
|
|
146
|
+
fontSize: 'smaller'
|
|
147
|
+
};
|
|
148
|
+
var _default = FootnoteLink;
|
|
149
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
en: {
|
|
9
|
+
a11yLabel: 'Read legal footnote',
|
|
10
|
+
close: 'close',
|
|
11
|
+
heading: 'Terms and conditions'
|
|
12
|
+
},
|
|
13
|
+
fr: {
|
|
14
|
+
a11yLabel: 'Lire la note de bas de page légale',
|
|
15
|
+
close: 'fermer',
|
|
16
|
+
heading: 'Modalités et conditions'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _Footnote = _interopRequireDefault(require("./Footnote"));
|
|
9
|
+
|
|
10
|
+
var _FootnoteLink = _interopRequireDefault(require("./FootnoteLink"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
_Footnote.default.Link = _FootnoteLink.default;
|
|
15
|
+
var _default = _Footnote.default;
|
|
16
|
+
exports.default = _default;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
15
|
+
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
23
|
+
|
|
24
|
+
const StyledParagraph = /*#__PURE__*/_styledComponents.default.p.withConfig({
|
|
25
|
+
displayName: "Paragraph__StyledParagraph",
|
|
26
|
+
componentId: "components-web__sc-1bg9r8p-0"
|
|
27
|
+
})(["", " ", " &:first-child{margin-block-start:0em;}&:last-child{margin-block-end:0em;}"], _ref => {
|
|
28
|
+
let {
|
|
29
|
+
align
|
|
30
|
+
} = _ref;
|
|
31
|
+
return align ? `text-align: ${align};` : '';
|
|
32
|
+
}, _ref2 => {
|
|
33
|
+
let {
|
|
34
|
+
linesBetween
|
|
35
|
+
} = _ref2;
|
|
36
|
+
return `
|
|
37
|
+
margin-block-start: ${linesBetween}em;
|
|
38
|
+
margin-block-end: ${linesBetween}em;
|
|
39
|
+
`;
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Block text as an HTML ```<p>``` element.
|
|
43
|
+
*
|
|
44
|
+
* ##Usage criteria
|
|
45
|
+
*
|
|
46
|
+
* - All body text should be contained in a **Paragraph**, regardless of length.
|
|
47
|
+
* - If the Paragraph is on a dark background, variant **{ invert: true }** must be used to maintain sufficient colour
|
|
48
|
+
contrast.
|
|
49
|
+
* - All Allium Typography variants other than header size variants are supported.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const Paragraph = _ref3 => {
|
|
54
|
+
let {
|
|
55
|
+
children,
|
|
56
|
+
variant,
|
|
57
|
+
tokens,
|
|
58
|
+
testID,
|
|
59
|
+
align,
|
|
60
|
+
linesBetween = 1,
|
|
61
|
+
...rest
|
|
62
|
+
} = _ref3;
|
|
63
|
+
const style = (0, _utils.useTypographyTheme)(variant, tokens);
|
|
64
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledParagraph, {
|
|
65
|
+
linesBetween: linesBetween,
|
|
66
|
+
"data-testid": testID,
|
|
67
|
+
align: align,
|
|
68
|
+
style: style,
|
|
69
|
+
...selectProps(rest),
|
|
70
|
+
children: children
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Paragraph.propTypes = { ...selectedSystemPropTypes,
|
|
75
|
+
children: _propTypes.default.node.isRequired,
|
|
76
|
+
testID: _propTypes.default.string,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sets the alignment style for the paragraph. Same options as Typography's `align` prop.
|
|
80
|
+
* 'justify' should be avoided as it usually reduces ease of reading.
|
|
81
|
+
*/
|
|
82
|
+
align: _propTypes.default.oneOf(['auto', 'left', 'right', 'center', 'justify']),
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* How much space between consecutive paragraphs, or between a paragraph and its siblings, in CSS
|
|
86
|
+
* `em` units: 1 gives space equal to one line of paragraph text, 0.5 would be half a line, etc.
|
|
87
|
+
* @default 1
|
|
88
|
+
*/
|
|
89
|
+
linesBetween: _propTypes.default.number,
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Paragraph takes the same tokens overrides as Typography
|
|
93
|
+
*/
|
|
94
|
+
tokens: _propTypes.default.oneOf([_propTypes.default.object, _propTypes.default.func]),
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Paragraph takes any of Typography's theme variants except for header sizes
|
|
98
|
+
*/
|
|
99
|
+
variant: _propTypes.default.exact({
|
|
100
|
+
bold: _propTypes.default.bool,
|
|
101
|
+
colour: _propTypes.default.oneOf(['secondary', 'tertiary']),
|
|
102
|
+
inverse: _propTypes.default.bool,
|
|
103
|
+
size: _propTypes.default.oneOf(['micro', 'small', 'large'])
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
var _default = Paragraph;
|
|
107
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _Paragraph = _interopRequireDefault(require("./Paragraph"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _Paragraph.default;
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A footer for PreviewCard that composes author and date in a standard way
|
|
20
|
+
*
|
|
21
|
+
* @TODO
|
|
22
|
+
* Add same locale-based date formatting as StoryCard when ready.
|
|
23
|
+
* Get locale based on decision of https://github.com/telus/universal-design-system/issues/715
|
|
24
|
+
*/
|
|
25
|
+
const AuthorDate = _ref => {
|
|
26
|
+
let {
|
|
27
|
+
author,
|
|
28
|
+
date
|
|
29
|
+
} = _ref;
|
|
30
|
+
const {
|
|
31
|
+
separatorColor: color
|
|
32
|
+
} = (0, _componentsBase.useThemeTokens)('PreviewCard', {}, {});
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackWrap, {
|
|
34
|
+
space: 2,
|
|
35
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
36
|
+
variant: {
|
|
37
|
+
size: 'small',
|
|
38
|
+
colour: 'secondary'
|
|
39
|
+
},
|
|
40
|
+
children: author
|
|
41
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
42
|
+
variant: {
|
|
43
|
+
size: 'small'
|
|
44
|
+
},
|
|
45
|
+
tokens: {
|
|
46
|
+
color
|
|
47
|
+
},
|
|
48
|
+
children: "\xB7"
|
|
49
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
50
|
+
variant: {
|
|
51
|
+
size: 'small',
|
|
52
|
+
colour: 'secondary'
|
|
53
|
+
},
|
|
54
|
+
children: date
|
|
55
|
+
})]
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
AuthorDate.propTypes = {
|
|
60
|
+
author: _propTypes.default.string.isRequired,
|
|
61
|
+
date: _propTypes.default.string.isRequired
|
|
62
|
+
};
|
|
63
|
+
var _default = AuthorDate;
|
|
64
|
+
exports.default = _default;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash.omit"));
|
|
13
|
+
|
|
14
|
+
var _componentsBase = require("@telus-uds/components-base");
|
|
15
|
+
|
|
16
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
+
|
|
18
|
+
var _FullBleedContent = _interopRequireWildcard(require("../shared/FullBleedContent"));
|
|
19
|
+
|
|
20
|
+
var _AuthorDate = _interopRequireDefault(require("./AuthorDate"));
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
/* eslint-disable react/require-default-props */
|
|
31
|
+
// Passes React Native-oriented system props through UDS PressableCardBase
|
|
32
|
+
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_componentsBase.a11yProps, _componentsBase.focusHandlerProps, _componentsBase.viewProps]); // Stop changes to the card's inner border width causing the size and
|
|
33
|
+
// apparent position of the full bleed image to change.
|
|
34
|
+
|
|
35
|
+
const FullBleedOffsetOuter = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
36
|
+
displayName: "PreviewCard__FullBleedOffsetOuter",
|
|
37
|
+
componentId: "components-web__sc-1yfz4de-0"
|
|
38
|
+
})(_ref => {
|
|
39
|
+
let {
|
|
40
|
+
borderOffset
|
|
41
|
+
} = _ref;
|
|
42
|
+
return {
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
marginTop: borderOffset * 2
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const FullBleedOffsetInner = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
49
|
+
displayName: "PreviewCard__FullBleedOffsetInner",
|
|
50
|
+
componentId: "components-web__sc-1yfz4de-1"
|
|
51
|
+
})(_ref2 => {
|
|
52
|
+
let {
|
|
53
|
+
borderOffset
|
|
54
|
+
} = _ref2;
|
|
55
|
+
return {
|
|
56
|
+
position: 'relative',
|
|
57
|
+
margin: 0 - borderOffset
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const defaultTokens = {
|
|
62
|
+
minWidth: 0,
|
|
63
|
+
shadow: null
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Showcase and guide users to another page, with a preview containing title and a footer.
|
|
67
|
+
* Whole card is interactive, width expands based on column or container.
|
|
68
|
+
*
|
|
69
|
+
* - Use `tag` to show category of content
|
|
70
|
+
* - Use `title` to show title of the story
|
|
71
|
+
* - Use `footer` to show text such as the author / date
|
|
72
|
+
* - Use `href` to set the target URL
|
|
73
|
+
* - Use `fullBleedContent` to set the thumbnail image
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
const PreviewCard = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
77
|
+
let {
|
|
78
|
+
tag,
|
|
79
|
+
title,
|
|
80
|
+
footer,
|
|
81
|
+
fullBleedImage,
|
|
82
|
+
fullBleedContent = fullBleedImage,
|
|
83
|
+
onPress,
|
|
84
|
+
href,
|
|
85
|
+
...rest
|
|
86
|
+
} = _ref3;
|
|
87
|
+
const {
|
|
88
|
+
fullBleedContentPosition,
|
|
89
|
+
contentStackDirection,
|
|
90
|
+
fullBleedContentProps
|
|
91
|
+
} = (0, _FullBleedContent.useFullBleedContentProps)({ ...fullBleedContent,
|
|
92
|
+
position: 'bottom'
|
|
93
|
+
});
|
|
94
|
+
const {
|
|
95
|
+
components: {
|
|
96
|
+
PreviewCard: theme
|
|
97
|
+
}
|
|
98
|
+
} = (0, _componentsBase.useTheme)();
|
|
99
|
+
|
|
100
|
+
const getPressableCardTokens = cardState => ({ ...(0, _lodash.default)((0, _componentsBase.getThemeTokens)(theme, {}, {}, cardState), 'separatorColor'),
|
|
101
|
+
...defaultTokens
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const {
|
|
105
|
+
hrefAttrs,
|
|
106
|
+
rest: unusedRest
|
|
107
|
+
} = _componentsBase.hrefAttrsProp.bundle(rest);
|
|
108
|
+
|
|
109
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.PressableCardBase, {
|
|
110
|
+
onPress: onPress,
|
|
111
|
+
href: href,
|
|
112
|
+
hrefAttrs: hrefAttrs,
|
|
113
|
+
tokens: getPressableCardTokens,
|
|
114
|
+
ref: ref,
|
|
115
|
+
...selectProps(unusedRest),
|
|
116
|
+
children: cardState => {
|
|
117
|
+
const {
|
|
118
|
+
borderRadius,
|
|
119
|
+
borderWidth
|
|
120
|
+
} = getPressableCardTokens(cardState); // Stop content jumping around as border size changes
|
|
121
|
+
|
|
122
|
+
const borderOffset = borderWidth - theme.tokens.borderWidth;
|
|
123
|
+
const fullBleedBorderRadius = (0, _FullBleedContent.getFullBleedBorderRadius)(borderRadius + borderOffset, fullBleedContentPosition);
|
|
124
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
|
|
125
|
+
direction: contentStackDirection,
|
|
126
|
+
tokens: {
|
|
127
|
+
justifyContent: 'space-between',
|
|
128
|
+
flexGrow: 1
|
|
129
|
+
},
|
|
130
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.Box, {
|
|
131
|
+
horizontal: {
|
|
132
|
+
xs: 4,
|
|
133
|
+
lg: 5,
|
|
134
|
+
options: {
|
|
135
|
+
subtract: borderOffset
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
vertical: {
|
|
139
|
+
xs: 5,
|
|
140
|
+
lg: 7,
|
|
141
|
+
options: {
|
|
142
|
+
subtract: borderOffset
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
children: [Boolean(tag) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
146
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
147
|
+
variant: {
|
|
148
|
+
size: 'eyebrow',
|
|
149
|
+
colour: 'secondary'
|
|
150
|
+
},
|
|
151
|
+
children: tag
|
|
152
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
|
|
153
|
+
space: 2
|
|
154
|
+
})]
|
|
155
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
156
|
+
variant: {
|
|
157
|
+
size: 'h4',
|
|
158
|
+
colour: 'secondary'
|
|
159
|
+
},
|
|
160
|
+
children: title
|
|
161
|
+
}), Boolean(footer) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
162
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
|
|
163
|
+
space: 2
|
|
164
|
+
}), typeof footer === 'string' ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
|
|
165
|
+
variant: {
|
|
166
|
+
size: 'small',
|
|
167
|
+
colour: 'secondary'
|
|
168
|
+
},
|
|
169
|
+
children: footer
|
|
170
|
+
}) : footer]
|
|
171
|
+
})]
|
|
172
|
+
}), Boolean(fullBleedContentProps.src || fullBleedContentProps.content) && /*#__PURE__*/(0, _jsxRuntime.jsx)(FullBleedOffsetOuter, {
|
|
173
|
+
borderOffset: borderOffset,
|
|
174
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(FullBleedOffsetInner, {
|
|
175
|
+
borderOffset: borderOffset,
|
|
176
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullBleedContent.default, {
|
|
177
|
+
borderRadius: fullBleedBorderRadius,
|
|
178
|
+
...fullBleedContentProps
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
})]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
PreviewCard.displayName = 'PreviewCard'; // Provide standard author/date footer as a preset with the export
|
|
187
|
+
|
|
188
|
+
PreviewCard.AuthorDate = _AuthorDate.default;
|
|
189
|
+
PreviewCard.propTypes = { ...selectedSystemPropTypes,
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The URL of the story to be navigated to. Note that `Video` component does not play well when used within
|
|
193
|
+
* a `PreviewCard` with `href` prop set (the volume and progress sliders can be clicked but are not draggable).
|
|
194
|
+
* Please use `onPress` prop instead `href` to organize navigation in cases like this.
|
|
195
|
+
*
|
|
196
|
+
* @see https://github.com/telus/allium-design-system/issues/6
|
|
197
|
+
*/
|
|
198
|
+
href: _propTypes.default.string,
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Optional function to be called on press e.g. for within-page navigation.
|
|
202
|
+
*/
|
|
203
|
+
onPress: _propTypes.default.func,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Text stating the category of the content.
|
|
207
|
+
*/
|
|
208
|
+
tag: _propTypes.default.string,
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Section containing additional information, such as author and date.
|
|
212
|
+
* Use `<PreviewCard.AuthorDate author={...} date={...} />` here for author and date.
|
|
213
|
+
*/
|
|
214
|
+
footer: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string]),
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Text stating the title or headline of the story.
|
|
218
|
+
*/
|
|
219
|
+
title: _propTypes.default.string.isRequired,
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Full bleed image to be placed on the card, deprecated in favor of `fullBleedContent`.
|
|
223
|
+
*
|
|
224
|
+
* @deprecated
|
|
225
|
+
*/
|
|
226
|
+
fullBleedImage: _propTypes.default.exact(_FullBleedContent.default.propTypes || {}),
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Full bleed content to be placed on the card.
|
|
230
|
+
*/
|
|
231
|
+
fullBleedContent: _propTypes.default.exact(_FullBleedContent.default.propTypes || {})
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var _default = (0, _componentsBase.withLinkRouter)(PreviewCard);
|
|
235
|
+
|
|
236
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _PreviewCard = _interopRequireDefault(require("./PreviewCard"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = _PreviewCard.default;
|
|
13
|
+
exports.default = _default;
|