@telus-uds/components-base 1.75.0 → 1.77.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 (57) hide show
  1. package/CHANGELOG.md +31 -2
  2. package/lib/Box/Box.js +112 -7
  3. package/lib/Box/backgroundImageStylesMap.js +101 -0
  4. package/lib/Carousel/CarouselThumbnail.js +10 -4
  5. package/lib/Carousel/CarouselThumbnailNavigation.js +3 -3
  6. package/lib/ExpandCollapse/Panel.js +21 -10
  7. package/lib/Footnote/Footnote.js +9 -13
  8. package/lib/Link/ChevronLink.js +2 -0
  9. package/lib/Link/InlinePressable.js +15 -2
  10. package/lib/Link/LinkBase.js +1 -0
  11. package/lib/OrderedList/OrderedList.js +21 -20
  12. package/lib/PriceLockup/PriceLockup.js +220 -0
  13. package/lib/PriceLockup/index.js +10 -0
  14. package/lib/PriceLockup/utils/renderFootnoteContent.js +93 -0
  15. package/lib/PriceLockup/utils/renderFootnoteLinks.js +36 -0
  16. package/lib/PriceLockup/utils/renderPrice.js +147 -0
  17. package/lib/PriceLockup/utils/renderTypography.js +31 -0
  18. package/lib/Skeleton/Skeleton.js +6 -3
  19. package/lib/index.js +8 -0
  20. package/lib-module/Box/Box.js +115 -9
  21. package/lib-module/Box/backgroundImageStylesMap.js +94 -0
  22. package/lib-module/Carousel/CarouselThumbnail.js +10 -4
  23. package/lib-module/Carousel/CarouselThumbnailNavigation.js +3 -3
  24. package/lib-module/ExpandCollapse/Panel.js +21 -10
  25. package/lib-module/Footnote/Footnote.js +9 -13
  26. package/lib-module/Link/ChevronLink.js +2 -0
  27. package/lib-module/Link/InlinePressable.js +16 -2
  28. package/lib-module/Link/LinkBase.js +1 -0
  29. package/lib-module/OrderedList/OrderedList.js +21 -20
  30. package/lib-module/PriceLockup/PriceLockup.js +214 -0
  31. package/lib-module/PriceLockup/index.js +2 -0
  32. package/lib-module/PriceLockup/utils/renderFootnoteContent.js +87 -0
  33. package/lib-module/PriceLockup/utils/renderFootnoteLinks.js +28 -0
  34. package/lib-module/PriceLockup/utils/renderPrice.js +141 -0
  35. package/lib-module/PriceLockup/utils/renderTypography.js +23 -0
  36. package/lib-module/Skeleton/Skeleton.js +6 -3
  37. package/lib-module/index.js +1 -0
  38. package/package.json +2 -2
  39. package/src/Box/Box.jsx +120 -9
  40. package/src/Box/backgroundImageStylesMap.js +21 -0
  41. package/src/Carousel/CarouselThumbnail.jsx +8 -6
  42. package/src/Carousel/CarouselThumbnailNavigation.jsx +3 -4
  43. package/src/ExpandCollapse/Panel.jsx +16 -10
  44. package/src/Footnote/Footnote.jsx +3 -6
  45. package/src/Link/ChevronLink.jsx +5 -1
  46. package/src/Link/InlinePressable.jsx +36 -15
  47. package/src/Link/LinkBase.jsx +1 -0
  48. package/src/OrderedList/OrderedList.jsx +17 -20
  49. package/src/PriceLockup/PriceLockup.jsx +218 -0
  50. package/src/PriceLockup/index.js +3 -0
  51. package/src/PriceLockup/utils/renderFootnoteContent.jsx +77 -0
  52. package/src/PriceLockup/utils/renderFootnoteLinks.jsx +38 -0
  53. package/src/PriceLockup/utils/renderPrice.jsx +201 -0
  54. package/src/PriceLockup/utils/renderTypography.jsx +13 -0
  55. package/src/Skeleton/Skeleton.jsx +8 -3
  56. package/src/index.js +1 -0
  57. package/types/Typography.d.ts +1 -0
@@ -0,0 +1,77 @@
1
+ import React from 'react'
2
+ import { StyleSheet, View, Text, Platform } from 'react-native'
3
+ import renderTypography from './renderTypography'
4
+ import renderFootnoteLinks from './renderFootnoteLinks'
5
+
6
+ const selectFootnoteContainer = ({ footnoteMarginTop }) => ({
7
+ marginTop: footnoteMarginTop
8
+ })
9
+
10
+ const selectFootnoteBottomTextContainer = ({ bottomTextMarginTop }) => ({
11
+ marginTop: bottomTextMarginTop
12
+ })
13
+
14
+ const selectFootnoteLinksStyles = ({ bottomLinksMarginLeft }) => ({
15
+ marginLeft: bottomLinksMarginLeft
16
+ })
17
+
18
+ const renderFootnoteContent = (
19
+ footnoteMarginTop,
20
+ bottomTextMarginTop,
21
+ bottomText,
22
+ bottomTextTypographyTokens,
23
+ fontColor,
24
+ footnoteLinks,
25
+ bottomLinksMarginLeft,
26
+ onClickFootnote,
27
+ themeTokens
28
+ ) => {
29
+ const MAX_FOOTNOTE_LINKS_ALLOWED = 3
30
+ return (
31
+ <>
32
+ <View
33
+ style={[staticStyles.footnoteContainer, selectFootnoteContainer({ footnoteMarginTop })]}
34
+ >
35
+ <Text style={selectFootnoteBottomTextContainer({ bottomTextMarginTop })}>
36
+ {renderTypography(bottomText, bottomTextTypographyTokens, undefined, fontColor)}{' '}
37
+ </Text>
38
+ {footnoteLinks.length <= MAX_FOOTNOTE_LINKS_ALLOWED ? (
39
+ <View
40
+ style={[
41
+ staticStyles.footnoteLinkContainer,
42
+ selectFootnoteLinksStyles({ bottomLinksMarginLeft })
43
+ ]}
44
+ >
45
+ {renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)}
46
+ </View>
47
+ ) : null}
48
+ </View>
49
+ {footnoteLinks.length > MAX_FOOTNOTE_LINKS_ALLOWED ? (
50
+ <View style={staticStyles.verticalFootnoteLinkContainer}>
51
+ {renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)}
52
+ </View>
53
+ ) : null}
54
+ </>
55
+ )
56
+ }
57
+
58
+ export default renderFootnoteContent
59
+
60
+ const staticStyles = StyleSheet.create({
61
+ footnoteContainer: {
62
+ flexDirection: 'row'
63
+ },
64
+ footnoteLinkContainer: {
65
+ flexDirection: 'row',
66
+ ...Platform.select({
67
+ ios: { alignSelf: 'flex-end', top: 2 },
68
+ android: { alignSelf: 'center', top: -8 }
69
+ })
70
+ },
71
+ verticalFootnoteLinkContainer: {
72
+ ...Platform.select({
73
+ ios: { top: 10 },
74
+ android: { top: -2 }
75
+ })
76
+ }
77
+ })
@@ -0,0 +1,38 @@
1
+ import React from 'react'
2
+ import FootnoteLink from '../../Footnote/FootnoteLink'
3
+
4
+ const selectFootnoteLinkStyles = (
5
+ {
6
+ footnoteLinkColor,
7
+ footnoteLinkFontName,
8
+ footnoteLinkFontWeight,
9
+ footnoteLinkLineHeight,
10
+ footnoteLinkFontSize
11
+ },
12
+ footnoteLinks
13
+ ) => {
14
+ // This is used to apply the proper line height when there is 4 or more footnote links
15
+ const MAX_FOOTNOTE_LINKS_ALLOWED = 3
16
+ const lineHeight =
17
+ footnoteLinks.length > MAX_FOOTNOTE_LINKS_ALLOWED
18
+ ? footnoteLinkFontSize * footnoteLinkLineHeight
19
+ : undefined
20
+ return {
21
+ color: footnoteLinkColor,
22
+ fontName: footnoteLinkFontName,
23
+ fontWeight: footnoteLinkFontWeight,
24
+ lineHeight,
25
+ fontSize: footnoteLinkFontSize
26
+ }
27
+ }
28
+
29
+ const renderFootnoteLinks = (footnoteLinks, themeTokens, onClickFootnote) =>
30
+ footnoteLinks && footnoteLinks.length > 0 ? (
31
+ <FootnoteLink
32
+ tokens={selectFootnoteLinkStyles(themeTokens, footnoteLinks)}
33
+ content={footnoteLinks}
34
+ onClick={onClickFootnote}
35
+ />
36
+ ) : null
37
+
38
+ export default renderFootnoteLinks
@@ -0,0 +1,201 @@
1
+ import React from 'react'
2
+ import { StyleSheet, View, Text, Platform } from 'react-native'
3
+ import A11yText from '../../A11yText'
4
+ import renderTypography from './renderTypography'
5
+ import renderFootnoteLinks from './renderFootnoteLinks'
6
+
7
+ const selectStrikeThroughStyles = ({ strikeThroughColor }) => ({
8
+ textDecorationColor: strikeThroughColor
9
+ })
10
+
11
+ const selectFootnoteLinksStyles = ({ bottomLinksMarginLeft }) => ({
12
+ marginLeft: bottomLinksMarginLeft
13
+ })
14
+
15
+ const renderCurrencySymbol = (
16
+ currencySymbol,
17
+ currencySymbolTypographyTokens,
18
+ ratePosition,
19
+ fontColor
20
+ ) => renderTypography(`${currencySymbol}`, currencySymbolTypographyTokens, ratePosition, fontColor)
21
+
22
+ const renderAmount = (
23
+ amount,
24
+ amountTypographyTokens,
25
+ strikeThrough,
26
+ a11yText,
27
+ fontColor,
28
+ themeTokens
29
+ ) => {
30
+ const amountText = renderTypography(amount, amountTypographyTokens, undefined, fontColor) // undefined is ratePosition
31
+ if (strikeThrough) {
32
+ return (
33
+ <>
34
+ <A11yText text={a11yText} />
35
+ <Text style={[staticStyles.strikeThroughContainer, selectStrikeThroughStyles(themeTokens)]}>
36
+ {amountText}
37
+ </Text>
38
+ </>
39
+ )
40
+ }
41
+
42
+ return amountText
43
+ }
44
+
45
+ const renderPrice = (
46
+ price,
47
+ rateText,
48
+ ratePosition,
49
+ signDirection,
50
+ currencySymbol,
51
+ currencySymbolTypographyTokens,
52
+ amountTypographyTokens,
53
+ centsTypographyTokens,
54
+ rateTypographyTokens,
55
+ fontColor,
56
+ strikeThrough,
57
+ a11yText,
58
+ bottomText,
59
+ bottomLinksMarginLeft,
60
+ footnoteLinks,
61
+ onClickFootnote,
62
+ themeTokens
63
+ ) => {
64
+ const priceString = price
65
+ const lastDotPosition = priceString.lastIndexOf('.')
66
+ const lastCommaPosition = priceString.lastIndexOf(',')
67
+ const [separator, separatorPosition] =
68
+ lastDotPosition > lastCommaPosition ? ['.', lastDotPosition] : [',', lastCommaPosition]
69
+
70
+ // If the separator is at the fourth character from the end of the string or more, it's most probably
71
+ // a part of the amount, and the cents are not included in the price string
72
+ const EXCLUDE_CENTS = 3
73
+ const hasCents =
74
+ separatorPosition !== -1 && separatorPosition >= priceString.length - EXCLUDE_CENTS
75
+ const amount = hasCents ? priceString.substring(0, separatorPosition) : priceString
76
+ const cents = hasCents ? priceString.substring(separatorPosition + 1) : null
77
+
78
+ const footnoteLinkPositionStyles = rateText
79
+ ? staticStyles.footnoteLinksWithoutBottomText
80
+ : staticStyles.footnoteLinksWithoutBottomTextAndRateText
81
+
82
+ const MAX_FOOTNOTE_LINKS_ALLOWED = 3
83
+ return (
84
+ <>
85
+ <View
86
+ style={
87
+ ratePosition === 'bottom'
88
+ ? staticStyles.priceContainerColumn
89
+ : staticStyles.priceContainerRow
90
+ }
91
+ >
92
+ <View style={staticStyles.priceContainer}>
93
+ {signDirection === 'left' ? (
94
+ <Text>
95
+ {renderCurrencySymbol(
96
+ currencySymbol,
97
+ currencySymbolTypographyTokens,
98
+ ratePosition,
99
+ fontColor
100
+ )}
101
+ </Text>
102
+ ) : null}
103
+ {renderAmount(
104
+ amount,
105
+ amountTypographyTokens,
106
+ strikeThrough,
107
+ a11yText,
108
+ fontColor,
109
+ themeTokens
110
+ )}
111
+ {cents
112
+ ? renderTypography(`${separator}${cents}`, centsTypographyTokens, undefined, fontColor)
113
+ : null}
114
+ {signDirection === 'right' ? (
115
+ <Text style={staticStyles.currencySymbol}>
116
+ {renderCurrencySymbol(
117
+ currencySymbol,
118
+ currencySymbolTypographyTokens,
119
+ ratePosition,
120
+ fontColor
121
+ )}
122
+ </Text>
123
+ ) : null}
124
+ </View>
125
+ {rateText ? (
126
+ <Text
127
+ style={
128
+ ratePosition === 'bottom'
129
+ ? staticStyles.rateTextVerticalPosition
130
+ : [staticStyles.rateTextPosition, staticStyles.rateTextVerticalPosition]
131
+ }
132
+ >
133
+ {renderTypography(rateText, rateTypographyTokens, ratePosition, fontColor)}
134
+ </Text>
135
+ ) : null}
136
+ {!bottomText && footnoteLinks.length <= MAX_FOOTNOTE_LINKS_ALLOWED ? (
137
+ <Text
138
+ style={[
139
+ footnoteLinkPositionStyles,
140
+ selectFootnoteLinksStyles({ bottomLinksMarginLeft })
141
+ ]}
142
+ >
143
+ {renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)}
144
+ </Text>
145
+ ) : null}
146
+ </View>
147
+ {!bottomText && footnoteLinks.length > MAX_FOOTNOTE_LINKS_ALLOWED ? (
148
+ <View style={staticStyles.verticalFootnoteLinkContainer}>
149
+ {renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)}
150
+ </View>
151
+ ) : null}
152
+ </>
153
+ )
154
+ }
155
+
156
+ export default renderPrice
157
+
158
+ const staticStyles = StyleSheet.create({
159
+ priceContainerRow: {
160
+ flexDirection: 'row'
161
+ },
162
+ priceContainerColumn: {
163
+ flexDirection: 'column'
164
+ },
165
+ priceContainer: {
166
+ flexDirection: 'row',
167
+ alignSelf: 'flex-start',
168
+ marginTop: 4
169
+ },
170
+ currencySymbol: {
171
+ paddingLeft: 4
172
+ },
173
+ verticalFootnoteLinkContainer: {
174
+ ...Platform.select({
175
+ ios: { top: 10 },
176
+ android: { top: -2 }
177
+ })
178
+ },
179
+ footnoteLinksWithoutBottomText: {
180
+ ...Platform.select({
181
+ ios: { alignSelf: 'flex-end', top: -10 },
182
+ android: { alignSelf: 'center', top: -14 }
183
+ })
184
+ },
185
+ footnoteLinksWithoutBottomTextAndRateText: {
186
+ ...Platform.select({
187
+ ios: { alignSelf: 'center' },
188
+ android: { alignSelf: 'flex-start' }
189
+ })
190
+ },
191
+ strikeThroughContainer: {
192
+ textDecorationLine: 'line-through',
193
+ textDecorationThickness: '1px'
194
+ },
195
+ rateTextPosition: {
196
+ alignSelf: 'flex-end'
197
+ },
198
+ rateTextVerticalPosition: {
199
+ top: -8
200
+ }
201
+ })
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+ import Typography from '../../Typography'
3
+
4
+ const renderTypography = (value, themeTokens, ratePosition, fontColor) => {
5
+ const customProps =
6
+ ratePosition === 'bottom'
7
+ ? { variant: { size: 'micro' }, tokens: { color: fontColor } }
8
+ : { tokens: { ...themeTokens, color: fontColor } }
9
+
10
+ return <Typography {...customProps}>{value}</Typography>
11
+ }
12
+
13
+ export default renderTypography
@@ -25,9 +25,10 @@ const selectSkeletonStyles = ({ color, radius }) => ({
25
25
  maxWidth: '100%'
26
26
  })
27
27
 
28
- const selectLineStyles = ({ skeletonHeight, lineWidth }) => ({
28
+ const selectLineStyles = ({ skeletonHeight, lineWidth, radius }) => ({
29
29
  width: lineWidth,
30
- height: skeletonHeight
30
+ height: skeletonHeight,
31
+ borderRadius: radius
31
32
  })
32
33
 
33
34
  const selectShapeStyles = ({ skeletonHeight }) => ({
@@ -101,7 +102,11 @@ const Skeleton = forwardRef(
101
102
  ]
102
103
  }
103
104
 
104
- return selectLineStyles({ skeletonHeight, lineWidth: getLineWidth() })
105
+ return selectLineStyles({
106
+ skeletonHeight,
107
+ lineWidth: getLineWidth(),
108
+ radius: themeTokens.lineRadius
109
+ })
105
110
  }
106
111
 
107
112
  const renderSkeleton = (index = 0) => {
package/src/index.js CHANGED
@@ -32,6 +32,7 @@ export { default as MultiSelectFilter } from './MultiSelectFilter'
32
32
  export { default as Notification } from './Notification'
33
33
  export { default as OrderedList } from './OrderedList'
34
34
  export { default as Pagination } from './Pagination'
35
+ export { default as PriceLockup } from './PriceLockup'
35
36
  export { default as Progress } from './Progress'
36
37
  export { default as QuickLinks } from './QuickLinks'
37
38
  export { default as QuickLinksFeature } from './QuickLinksFeature'
@@ -23,6 +23,7 @@ export type TypographyVariants = {
23
23
  characters?: number
24
24
  spaceBetweenLines?: number
25
25
  squareRadius?: number
26
+ lineRadius?: number
26
27
  inverse?: boolean
27
28
  }
28
29