@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
package/src/Ribbon/Ribbon.jsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { selectSystemProps, Typography, useThemeTokens } from '@telus-uds/components-base'
|
|
4
|
-
// import palette from '@telus-uds/palette-allium/build/web/palette'
|
|
5
4
|
import styled from 'styled-components'
|
|
6
5
|
import { htmlAttrs } from '../utils'
|
|
7
6
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
import { selectSystemProps } from '@telus-uds/components-base'
|
|
5
|
+
|
|
6
|
+
import { htmlAttrs, useTypographyTheme } from '../utils'
|
|
7
|
+
|
|
8
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
|
|
9
|
+
|
|
10
|
+
const StyledSpan = styled.span`${({ flex }) => (flex ? 'display: inline-flex' : '')}};`
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Text as an HTML ```<span>``` element.
|
|
14
|
+
*
|
|
15
|
+
* Span may be used in cases where an inline span or direct access to HTML attributes is required.
|
|
16
|
+
* In most cases, `Typography` should be used for text, or Paragraph for body text.
|
|
17
|
+
*/
|
|
18
|
+
const Span = ({ children, variant, tokens, testID, flex, ...rest }) => {
|
|
19
|
+
const style = useTypographyTheme(variant, tokens)
|
|
20
|
+
return (
|
|
21
|
+
<StyledSpan data-testid={testID} flex={flex} style={style} {...selectProps(rest)}>
|
|
22
|
+
{children}
|
|
23
|
+
</StyledSpan>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Span.propTypes = {
|
|
28
|
+
...selectedSystemPropTypes,
|
|
29
|
+
children: PropTypes.node.isRequired,
|
|
30
|
+
testID: PropTypes.string,
|
|
31
|
+
/**
|
|
32
|
+
* Sets display to inline-flex so that children are laid out using the flex model.
|
|
33
|
+
* Use this if the span contains children that expect to be inside a flex container.
|
|
34
|
+
*/
|
|
35
|
+
flex: PropTypes.bool,
|
|
36
|
+
/**
|
|
37
|
+
* Span takes the same tokens overrides as Typography
|
|
38
|
+
*/
|
|
39
|
+
tokens: PropTypes.oneOf([PropTypes.object, PropTypes.func]),
|
|
40
|
+
/**
|
|
41
|
+
* Span can take any of Typography's theme variants
|
|
42
|
+
*/
|
|
43
|
+
variant: PropTypes.exact({
|
|
44
|
+
bold: PropTypes.bool,
|
|
45
|
+
colour: PropTypes.oneOf(['secondary', 'tertiary']),
|
|
46
|
+
compact: PropTypes.bool,
|
|
47
|
+
inverse: PropTypes.bool,
|
|
48
|
+
size: PropTypes.oneOf([
|
|
49
|
+
'micro',
|
|
50
|
+
'small',
|
|
51
|
+
'large',
|
|
52
|
+
'eyebrow',
|
|
53
|
+
'h1',
|
|
54
|
+
'h2',
|
|
55
|
+
'h3',
|
|
56
|
+
'h4',
|
|
57
|
+
'h5',
|
|
58
|
+
'h6',
|
|
59
|
+
'display1',
|
|
60
|
+
'display2'
|
|
61
|
+
]),
|
|
62
|
+
weight: PropTypes.oneOf(['semibold', 'bold'])
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default Span
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export { default as Badge } from './Badge'
|
|
2
2
|
export { default as OrderedList } from './OrderedList'
|
|
3
|
+
export { default as PreviewCard } from './PreviewCard'
|
|
4
|
+
export { default as ResponsiveImage } from './ResponsiveImage'
|
|
3
5
|
export { default as Ribbon } from './Ribbon'
|
|
6
|
+
export { default as DatePicker } from './DatePicker'
|
|
7
|
+
export { default as Paragraph } from './Paragraph'
|
|
8
|
+
export { default as Span } from './Span'
|
|
9
|
+
export { default as ExpandCollapseMini } from './ExpandCollapseMini'
|
|
10
|
+
export { default as Callout } from './Callout'
|
|
11
|
+
export { default as PriceLockup } from './PriceLockup'
|
|
12
|
+
export { default as Footnote } from './Footnote'
|
|
4
13
|
export { transformGradient } from './utils'
|
|
14
|
+
export { default as Breadcrumbs } from './Breadcrumbs'
|
|
5
15
|
|
|
6
16
|
export * from './baseExports'
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styled from 'styled-components'
|
|
4
|
+
|
|
5
|
+
import ResponsiveImage from '../../ResponsiveImage'
|
|
6
|
+
|
|
7
|
+
const selectFullBleedContentProps = ({
|
|
8
|
+
alt,
|
|
9
|
+
height,
|
|
10
|
+
loading,
|
|
11
|
+
src,
|
|
12
|
+
width,
|
|
13
|
+
fallbackSrc = src,
|
|
14
|
+
lgSrc = src,
|
|
15
|
+
mdSrc = src,
|
|
16
|
+
smSrc = src,
|
|
17
|
+
xlSrc = src,
|
|
18
|
+
xsSrc = src
|
|
19
|
+
}) => ({
|
|
20
|
+
alt,
|
|
21
|
+
height,
|
|
22
|
+
loading,
|
|
23
|
+
src,
|
|
24
|
+
width,
|
|
25
|
+
fallbackSrc,
|
|
26
|
+
lgSrc,
|
|
27
|
+
mdSrc,
|
|
28
|
+
smSrc,
|
|
29
|
+
xlSrc,
|
|
30
|
+
xsSrc
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const FullBleedContentContainer = styled.div(
|
|
34
|
+
({
|
|
35
|
+
borderBottomLeftRadius,
|
|
36
|
+
borderBottomRightRadius,
|
|
37
|
+
borderTopLeftRadius,
|
|
38
|
+
borderTopRightRadius
|
|
39
|
+
}) => ({
|
|
40
|
+
overflow: 'hidden',
|
|
41
|
+
borderBottomLeftRadius,
|
|
42
|
+
borderBottomRightRadius,
|
|
43
|
+
borderTopLeftRadius,
|
|
44
|
+
borderTopRightRadius
|
|
45
|
+
})
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Full bleed content component can accept either a single source,
|
|
50
|
+
* a number of sources corresponding to the `ResponsiveImage` component API,
|
|
51
|
+
* or a custom component.
|
|
52
|
+
*/
|
|
53
|
+
const FullBleedContent = ({ borderRadius, content, ...rest }) => (
|
|
54
|
+
<FullBleedContentContainer {...borderRadius}>
|
|
55
|
+
{content ?? <ResponsiveImage {...selectFullBleedContentProps(rest)} />}
|
|
56
|
+
</FullBleedContentContainer>
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
FullBleedContent.propTypes = {
|
|
60
|
+
/**
|
|
61
|
+
* Content border radius matching the edge values on the parent card.
|
|
62
|
+
*/
|
|
63
|
+
borderRadius: PropTypes.shape({
|
|
64
|
+
borderBottomLeftRadius: PropTypes.number,
|
|
65
|
+
borderBottomRightRadius: PropTypes.number,
|
|
66
|
+
borderTopLeftRadius: PropTypes.number,
|
|
67
|
+
borderTopRightRadius: PropTypes.number
|
|
68
|
+
}),
|
|
69
|
+
/**
|
|
70
|
+
* Custom JSX to be used for rendering the content (defaults to `ResponsiveImage` receiving other props).
|
|
71
|
+
*/
|
|
72
|
+
content: PropTypes.node,
|
|
73
|
+
/**
|
|
74
|
+
* Image source.
|
|
75
|
+
*/
|
|
76
|
+
src: PropTypes.string,
|
|
77
|
+
/**
|
|
78
|
+
* Also accept props for `ResponsiveImage`...
|
|
79
|
+
*/
|
|
80
|
+
...ResponsiveImage.propTypes,
|
|
81
|
+
/**
|
|
82
|
+
* ...but make the required ones optional.
|
|
83
|
+
*/
|
|
84
|
+
alt: PropTypes.string,
|
|
85
|
+
xsSrc: PropTypes.string,
|
|
86
|
+
smSrc: PropTypes.string,
|
|
87
|
+
fallbackSrc: PropTypes.string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default FullBleedContent
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the border radius values for an item of content that goes right up to
|
|
3
|
+
* the edges of its container, to the top, bottom, left or right of other content.
|
|
4
|
+
*
|
|
5
|
+
* Gives the full bleed item the same border radius as the container on the corners
|
|
6
|
+
* that are flush with the corners of the container.
|
|
7
|
+
*
|
|
8
|
+
* @param {number} borderRadius
|
|
9
|
+
* @param {'top'|'bottom'|'left'|'right'} position
|
|
10
|
+
* @param {boolean} hasFooter
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
const getFullBleedBorderRadius = (borderRadius, position, hasFooter = false) => {
|
|
14
|
+
const innerBorderRadius = {
|
|
15
|
+
borderBottomLeftRadius: 0,
|
|
16
|
+
borderBottomRightRadius: 0,
|
|
17
|
+
borderTopLeftRadius: 0,
|
|
18
|
+
borderTopRightRadius: 0
|
|
19
|
+
}
|
|
20
|
+
if (position && position !== 'none') {
|
|
21
|
+
if (borderRadius) {
|
|
22
|
+
// Depending on the position of the image, we need to round some
|
|
23
|
+
// corners, but not the others
|
|
24
|
+
switch (position) {
|
|
25
|
+
case 'bottom':
|
|
26
|
+
if (!hasFooter) {
|
|
27
|
+
innerBorderRadius.borderBottomLeftRadius = borderRadius
|
|
28
|
+
innerBorderRadius.borderBottomRightRadius = borderRadius
|
|
29
|
+
}
|
|
30
|
+
break
|
|
31
|
+
case 'left':
|
|
32
|
+
if (!hasFooter) {
|
|
33
|
+
innerBorderRadius.borderBottomLeftRadius = borderRadius
|
|
34
|
+
}
|
|
35
|
+
innerBorderRadius.borderTopLeftRadius = borderRadius
|
|
36
|
+
break
|
|
37
|
+
case 'right':
|
|
38
|
+
if (!hasFooter) {
|
|
39
|
+
innerBorderRadius.borderBottomRightRadius = borderRadius
|
|
40
|
+
}
|
|
41
|
+
innerBorderRadius.borderTopRightRadius = borderRadius
|
|
42
|
+
break
|
|
43
|
+
case 'top':
|
|
44
|
+
innerBorderRadius.borderTopLeftRadius = borderRadius
|
|
45
|
+
innerBorderRadius.borderTopRightRadius = borderRadius
|
|
46
|
+
break
|
|
47
|
+
default:
|
|
48
|
+
break
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return innerBorderRadius
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default getFullBleedBorderRadius
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useResponsiveProp } from '@telus-uds/components-base'
|
|
2
|
+
|
|
3
|
+
const getContentStackDirection = (fullBleedContentPosition) => {
|
|
4
|
+
switch (fullBleedContentPosition) {
|
|
5
|
+
case 'left':
|
|
6
|
+
return 'row-reverse'
|
|
7
|
+
case 'right':
|
|
8
|
+
return 'row'
|
|
9
|
+
case 'top':
|
|
10
|
+
return 'column-reverse'
|
|
11
|
+
default:
|
|
12
|
+
return 'column'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const getContentStackAlign = (fullBleedContentAlign) => {
|
|
17
|
+
switch (fullBleedContentAlign) {
|
|
18
|
+
case 'center':
|
|
19
|
+
return 'center'
|
|
20
|
+
|
|
21
|
+
case 'end':
|
|
22
|
+
case 'flex-end':
|
|
23
|
+
return 'flex-end'
|
|
24
|
+
|
|
25
|
+
case 'start':
|
|
26
|
+
case 'flex-start':
|
|
27
|
+
return 'flex-start'
|
|
28
|
+
|
|
29
|
+
default:
|
|
30
|
+
return 'stretch'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Resolves a set of `FullBleedContent` props into the variables a container needs to
|
|
36
|
+
* correctly position a `FullBleedContent` component for the current viewport.
|
|
37
|
+
*
|
|
38
|
+
* @param {object} [fullBleedContent] - a set of valid proptypes for FullBleedContent
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
const useFullBleedContentProps = (fullBleedContent) => {
|
|
42
|
+
const {
|
|
43
|
+
align: fullBleedContentAlignProp,
|
|
44
|
+
position: fullBleedContentPositionProp,
|
|
45
|
+
...fullBleedContentProps
|
|
46
|
+
} = fullBleedContent ?? {
|
|
47
|
+
position: 'none'
|
|
48
|
+
}
|
|
49
|
+
const fullBleedContentPosition = useResponsiveProp(fullBleedContentPositionProp, 'none')
|
|
50
|
+
const contentStackDirection = getContentStackDirection(fullBleedContentPosition)
|
|
51
|
+
|
|
52
|
+
const fullBleedContentAlign = useResponsiveProp(fullBleedContentAlignProp, 'stretch')
|
|
53
|
+
const contentStackAlign = getContentStackAlign(fullBleedContentAlign)
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
contentStackAlign,
|
|
57
|
+
contentStackDirection,
|
|
58
|
+
fullBleedContentPosition,
|
|
59
|
+
fullBleedContentProps
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default useFullBleedContentProps
|
package/src/utils/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { transformGradient } from './transforms'
|
|
2
|
+
import useTypographyTheme from './useTypographyTheme'
|
|
2
3
|
import htmlAttrs from './htmlAttrs'
|
|
4
|
+
import { warn } from './logger'
|
|
5
|
+
import media from './media'
|
|
6
|
+
import renderStructuredContent from './renderStructuredContent'
|
|
3
7
|
|
|
4
|
-
export { htmlAttrs, transformGradient }
|
|
8
|
+
export { htmlAttrs, transformGradient, useTypographyTheme, warn, media, renderStructuredContent }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const deprecate = (componentName, message) => {
|
|
2
|
+
if (process.env.NODE_ENV === 'production') {
|
|
3
|
+
return
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
console.warn(`[Allium] [Deprecate] ${componentName}: ${message}`) // eslint-disable-line no-console
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const warn = (componentName, message) => {
|
|
10
|
+
if (process.env.NODE_ENV === 'production') {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
console.warn(`[Allium] ${componentName}: ${message}`) // eslint-disable-line no-console
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
deprecate,
|
|
19
|
+
warn
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { viewports } from '@telus-uds/system-constants'
|
|
2
|
+
|
|
3
|
+
export default function media() {
|
|
4
|
+
return {
|
|
5
|
+
query: {},
|
|
6
|
+
from(breakpoint) {
|
|
7
|
+
if (breakpoint !== viewports.xs) {
|
|
8
|
+
this.query.minWidth = breakpoint
|
|
9
|
+
}
|
|
10
|
+
return this
|
|
11
|
+
},
|
|
12
|
+
until(breakpoint) {
|
|
13
|
+
this.query.maxWidth = breakpoint
|
|
14
|
+
return this
|
|
15
|
+
},
|
|
16
|
+
and(custom) {
|
|
17
|
+
this.query.and = custom
|
|
18
|
+
return this
|
|
19
|
+
},
|
|
20
|
+
css(style) {
|
|
21
|
+
const { minWidth, maxWidth, and } = this.query
|
|
22
|
+
|
|
23
|
+
const min = minWidth ? `(min-width: ${viewports.map.get(minWidth)}px)` : undefined
|
|
24
|
+
const max = maxWidth ? `(max-width: ${viewports.map.get(maxWidth) - 1}px)` : undefined
|
|
25
|
+
|
|
26
|
+
if (typeof min !== 'undefined' || typeof max !== 'undefined' || typeof and !== 'undefined') {
|
|
27
|
+
const mediaQuery = `@media ${[min, max, and].filter((a) => a).join(' and ')}`
|
|
28
|
+
this.query = {}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
[mediaQuery]: {
|
|
32
|
+
...(typeof style === 'function' ? style() : style)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return typeof style === 'function' ? style() : style
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Link } from '@telus-uds/components-base'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Takes a string content and marks up all the links in it by wrapping them
|
|
6
|
+
* in `Link` component.
|
|
7
|
+
*/
|
|
8
|
+
const generateLinks = (content) => {
|
|
9
|
+
const linkRegex = /<\s*a([^>]*)>(.*?)<\s*\/\s*a>/g
|
|
10
|
+
const attributeRegex = /(\w+)\s*=\s*((["'])(.*?)\3|(?=\s|\/>))/g
|
|
11
|
+
|
|
12
|
+
const parts = content.split(linkRegex)
|
|
13
|
+
if (parts.length === 1) {
|
|
14
|
+
return parts
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Start with first anchor text, attributes will be in the previous part
|
|
18
|
+
for (let i = 2; i < parts.length; i += 3) {
|
|
19
|
+
const o = {}
|
|
20
|
+
// Get attributes from previous part
|
|
21
|
+
const attributes = parts[i - 1].trim()
|
|
22
|
+
|
|
23
|
+
// Create object from attributes
|
|
24
|
+
const matchedAttributes = attributes.match(attributeRegex)
|
|
25
|
+
if (matchedAttributes) {
|
|
26
|
+
matchedAttributes.forEach((attribute) => {
|
|
27
|
+
const split = attribute.split('=')
|
|
28
|
+
o[split[0]] = split[1].substr(1, split[1].length - 2)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
// Remove anchor attributes from parts
|
|
32
|
+
parts[i - 1] = undefined
|
|
33
|
+
// Replace anchor text with Link in parts
|
|
34
|
+
parts[i] = (
|
|
35
|
+
<Link {...o} key={i}>
|
|
36
|
+
{parts[i]}
|
|
37
|
+
</Link>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return parts
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Takes an array of strings and in each element replaces the breaks with `<br>` tags.
|
|
46
|
+
*/
|
|
47
|
+
const generateBreaks = (parts) => {
|
|
48
|
+
const breakRegex = /<br\s?\/*>/g
|
|
49
|
+
|
|
50
|
+
const partsWithBreaks = parts
|
|
51
|
+
|
|
52
|
+
for (let i = 0; i < partsWithBreaks.length; i += 1) {
|
|
53
|
+
if (typeof partsWithBreaks[i] === 'string' && partsWithBreaks[i].search(breakRegex) !== -1) {
|
|
54
|
+
const toSplit = partsWithBreaks[i].split(breakRegex)
|
|
55
|
+
for (let x = 1; x < toSplit.length; x += 2) {
|
|
56
|
+
toSplit.splice(x, 0, <br key={`break-${i}-${x}`} />)
|
|
57
|
+
}
|
|
58
|
+
partsWithBreaks[i] = toSplit
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return partsWithBreaks
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const renderStructuredContent = (content) => {
|
|
66
|
+
if (typeof content !== 'string') {
|
|
67
|
+
return content
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return generateBreaks(generateLinks(content))
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default renderStructuredContent
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { applyTextStyles, useTheme, useThemeTokens, useViewport } from '@telus-uds/components-base'
|
|
2
|
+
|
|
3
|
+
const useTypographyTheme = (variant, tokens) => {
|
|
4
|
+
const viewport = useViewport()
|
|
5
|
+
const themeTokens = useThemeTokens('Typography', tokens, variant, { viewport })
|
|
6
|
+
const { themeOptions } = useTheme()
|
|
7
|
+
const { fontSize, lineHeight, ...rnStyles } = applyTextStyles({
|
|
8
|
+
...themeTokens,
|
|
9
|
+
themeOptions
|
|
10
|
+
})
|
|
11
|
+
return { ...rnStyles, fontSize: `${fontSize}px`, lineHeight: `${lineHeight}px` }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default useTypographyTheme
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComponentType, ElementType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
export interface CalloutProps extends HTMLAttrs {
|
|
5
|
+
children: ReactNode
|
|
6
|
+
variant?: Variant
|
|
7
|
+
icon?: ElementType
|
|
8
|
+
verticalAlign?: 'top' | 'middle' | 'bottom'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const Callout: ComponentType<CalloutProps>
|
|
12
|
+
|
|
13
|
+
export default Callout
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentType } from 'react'
|
|
2
|
+
import type { HTMLAttrs } from './common'
|
|
3
|
+
|
|
4
|
+
export interface DatePickerProps extends HTMLAttrs {
|
|
5
|
+
id: string
|
|
6
|
+
copy?: 'en' | 'fr'
|
|
7
|
+
date?: any
|
|
8
|
+
feedback?: string
|
|
9
|
+
onDateChange?: (date: any) => void
|
|
10
|
+
isDayDisabled?: (date: any) => boolean
|
|
11
|
+
label?: string
|
|
12
|
+
inline?: boolean
|
|
13
|
+
hint?: string
|
|
14
|
+
hintPosition?: 'inline' | 'below'
|
|
15
|
+
tooltip?: string
|
|
16
|
+
validation?: 'error' | 'success'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const DatePicker: ComponentType<DatePickerProps>
|
|
20
|
+
|
|
21
|
+
export default DatePicker
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
type copyShape = {
|
|
5
|
+
close: string
|
|
6
|
+
heading: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface FootnoteProps extends HTMLAttrs {
|
|
10
|
+
children: ReactNode
|
|
11
|
+
variant?: Variant
|
|
12
|
+
copy?: 'en' | 'fr' | copyShape
|
|
13
|
+
content?: string
|
|
14
|
+
isOpen?: boolean
|
|
15
|
+
number?: number
|
|
16
|
+
onClose: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare const Footnote: ComponentType<FootnoteProps>
|
|
20
|
+
|
|
21
|
+
export default Footnote
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
type copyShape = {
|
|
5
|
+
close: string
|
|
6
|
+
heading: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface FootnoteLinkProps extends HTMLAttrs {
|
|
10
|
+
children: ReactNode
|
|
11
|
+
number: number | string | [number] | [string]
|
|
12
|
+
variant?: Variant
|
|
13
|
+
copy?: 'en' | 'fr' | copyShape
|
|
14
|
+
fontSize?: number | string
|
|
15
|
+
onClick: MouseEvent
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const FootnoteLink: ComponentType<FootnoteLinkProps>
|
|
19
|
+
|
|
20
|
+
export default FootnoteLink
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
import type { HTMLAttrs, Variant } from './common'
|
|
3
|
+
|
|
4
|
+
export interface PriceLockupProps extends HTMLAttrs {
|
|
5
|
+
children: ReactNode
|
|
6
|
+
variant?: Variant
|
|
7
|
+
size?: 'small' | 'medium' | 'large'
|
|
8
|
+
signDirection?: 'left' | 'right'
|
|
9
|
+
footnoteLinks?: [number] | [string]
|
|
10
|
+
topText?: string
|
|
11
|
+
price: number
|
|
12
|
+
currencySymbol?: string
|
|
13
|
+
rateText?: string
|
|
14
|
+
bottomText?: string
|
|
15
|
+
onClickFootnote?: MouseEvent
|
|
16
|
+
strikeThrough?: boolean
|
|
17
|
+
a11yText?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare const PriceLockup: ComponentType<PriceLockupProps>
|
|
21
|
+
|
|
22
|
+
export default PriceLockup
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AriaRole, AriaAttributes } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface HTMLAttrs extends AriaAttributes {
|
|
4
|
+
dataSet?: Record<string, any>
|
|
5
|
+
id?: string
|
|
6
|
+
loading?: 'eager' | 'lazy'
|
|
7
|
+
role?: AriaRole
|
|
8
|
+
src?: string
|
|
9
|
+
tabIndex?: string | number
|
|
10
|
+
testID?: string
|
|
11
|
+
title?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type Variant = Record<string, string | number | boolean>
|