@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.
- package/CHANGELOG.md +31 -2
- package/lib/Box/Box.js +112 -7
- package/lib/Box/backgroundImageStylesMap.js +101 -0
- package/lib/Carousel/CarouselThumbnail.js +10 -4
- package/lib/Carousel/CarouselThumbnailNavigation.js +3 -3
- package/lib/ExpandCollapse/Panel.js +21 -10
- package/lib/Footnote/Footnote.js +9 -13
- package/lib/Link/ChevronLink.js +2 -0
- package/lib/Link/InlinePressable.js +15 -2
- package/lib/Link/LinkBase.js +1 -0
- package/lib/OrderedList/OrderedList.js +21 -20
- package/lib/PriceLockup/PriceLockup.js +220 -0
- package/lib/PriceLockup/index.js +10 -0
- package/lib/PriceLockup/utils/renderFootnoteContent.js +93 -0
- package/lib/PriceLockup/utils/renderFootnoteLinks.js +36 -0
- package/lib/PriceLockup/utils/renderPrice.js +147 -0
- package/lib/PriceLockup/utils/renderTypography.js +31 -0
- package/lib/Skeleton/Skeleton.js +6 -3
- package/lib/index.js +8 -0
- package/lib-module/Box/Box.js +115 -9
- package/lib-module/Box/backgroundImageStylesMap.js +94 -0
- package/lib-module/Carousel/CarouselThumbnail.js +10 -4
- package/lib-module/Carousel/CarouselThumbnailNavigation.js +3 -3
- package/lib-module/ExpandCollapse/Panel.js +21 -10
- package/lib-module/Footnote/Footnote.js +9 -13
- package/lib-module/Link/ChevronLink.js +2 -0
- package/lib-module/Link/InlinePressable.js +16 -2
- package/lib-module/Link/LinkBase.js +1 -0
- package/lib-module/OrderedList/OrderedList.js +21 -20
- package/lib-module/PriceLockup/PriceLockup.js +214 -0
- package/lib-module/PriceLockup/index.js +2 -0
- package/lib-module/PriceLockup/utils/renderFootnoteContent.js +87 -0
- package/lib-module/PriceLockup/utils/renderFootnoteLinks.js +28 -0
- package/lib-module/PriceLockup/utils/renderPrice.js +141 -0
- package/lib-module/PriceLockup/utils/renderTypography.js +23 -0
- package/lib-module/Skeleton/Skeleton.js +6 -3
- package/lib-module/index.js +1 -0
- package/package.json +2 -2
- package/src/Box/Box.jsx +120 -9
- package/src/Box/backgroundImageStylesMap.js +21 -0
- package/src/Carousel/CarouselThumbnail.jsx +8 -6
- package/src/Carousel/CarouselThumbnailNavigation.jsx +3 -4
- package/src/ExpandCollapse/Panel.jsx +16 -10
- package/src/Footnote/Footnote.jsx +3 -6
- package/src/Link/ChevronLink.jsx +5 -1
- package/src/Link/InlinePressable.jsx +36 -15
- package/src/Link/LinkBase.jsx +1 -0
- package/src/OrderedList/OrderedList.jsx +17 -20
- package/src/PriceLockup/PriceLockup.jsx +218 -0
- package/src/PriceLockup/index.js +3 -0
- package/src/PriceLockup/utils/renderFootnoteContent.jsx +77 -0
- package/src/PriceLockup/utils/renderFootnoteLinks.jsx +38 -0
- package/src/PriceLockup/utils/renderPrice.jsx +201 -0
- package/src/PriceLockup/utils/renderTypography.jsx +13 -0
- package/src/Skeleton/Skeleton.jsx +8 -3
- package/src/index.js +1 -0
- package/types/Typography.d.ts +1 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import Divider from '../Divider';
|
|
6
|
+
import { useViewport } from '../ViewportProvider';
|
|
7
|
+
import { useThemeTokens } from '../ThemeProvider';
|
|
8
|
+
import { selectSystemProps, getTokensPropType, htmlAttrs, viewProps } from '../utils';
|
|
9
|
+
import renderFootnoteContent from './utils/renderFootnoteContent';
|
|
10
|
+
import renderPrice from './utils/renderPrice';
|
|
11
|
+
import renderTypography from './utils/renderTypography';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps]);
|
|
16
|
+
const selectTopTextTypographyTokens = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
topTextFontSize,
|
|
19
|
+
topTextLineHeight
|
|
20
|
+
} = _ref;
|
|
21
|
+
return {
|
|
22
|
+
fontSize: topTextFontSize,
|
|
23
|
+
lineHeight: topTextLineHeight
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const selectCurrencySymbolTypographyTokens = _ref2 => {
|
|
27
|
+
let {
|
|
28
|
+
currencySymbolFontSize,
|
|
29
|
+
currencySymbolLineHeight,
|
|
30
|
+
currencySymbolFontWeight
|
|
31
|
+
} = _ref2;
|
|
32
|
+
return {
|
|
33
|
+
fontSize: currencySymbolFontSize,
|
|
34
|
+
lineHeight: currencySymbolLineHeight,
|
|
35
|
+
fontWeight: currencySymbolFontWeight
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const selectAmountTypographyTokens = _ref3 => {
|
|
39
|
+
let {
|
|
40
|
+
amountFontSize,
|
|
41
|
+
amountLineHeight,
|
|
42
|
+
amountLetterSpacing,
|
|
43
|
+
amountFontWeight,
|
|
44
|
+
fontColor
|
|
45
|
+
} = _ref3;
|
|
46
|
+
// This is used to apply the proper line height to the amount
|
|
47
|
+
const lineHeightMultiplier = 1.18;
|
|
48
|
+
return {
|
|
49
|
+
color: fontColor,
|
|
50
|
+
fontSize: amountFontSize,
|
|
51
|
+
lineHeight: amountLineHeight * lineHeightMultiplier,
|
|
52
|
+
letterSpacing: amountLetterSpacing,
|
|
53
|
+
fontWeight: amountFontWeight
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const selectCentsTypographyTokens = _ref4 => {
|
|
57
|
+
let {
|
|
58
|
+
centsFontSize,
|
|
59
|
+
centsLineHeight,
|
|
60
|
+
centsFontWeight
|
|
61
|
+
} = _ref4;
|
|
62
|
+
return {
|
|
63
|
+
fontSize: centsFontSize,
|
|
64
|
+
lineHeight: centsLineHeight,
|
|
65
|
+
fontWeight: centsFontWeight
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const selectRateTypographyTokens = _ref5 => {
|
|
69
|
+
let {
|
|
70
|
+
rateFontSize,
|
|
71
|
+
rateLineHeight,
|
|
72
|
+
rateFontWeight
|
|
73
|
+
} = _ref5;
|
|
74
|
+
return {
|
|
75
|
+
fontSize: rateFontSize,
|
|
76
|
+
lineHeight: rateLineHeight,
|
|
77
|
+
fontWeight: rateFontWeight
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const selectBottomTextTypographyTokens = _ref6 => {
|
|
81
|
+
let {
|
|
82
|
+
bottomTextFontSize,
|
|
83
|
+
bottomTextLineHeight
|
|
84
|
+
} = _ref6;
|
|
85
|
+
return {
|
|
86
|
+
fontSize: bottomTextFontSize,
|
|
87
|
+
lineHeight: bottomTextLineHeight
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
const PriceLockup = _ref7 => {
|
|
91
|
+
let {
|
|
92
|
+
size = 'medium',
|
|
93
|
+
signDirection = 'left',
|
|
94
|
+
footnoteLinks,
|
|
95
|
+
topText,
|
|
96
|
+
price,
|
|
97
|
+
currencySymbol = '$',
|
|
98
|
+
rateText,
|
|
99
|
+
ratePosition = 'right',
|
|
100
|
+
bottomText,
|
|
101
|
+
onClickFootnote,
|
|
102
|
+
strikeThrough,
|
|
103
|
+
a11yText,
|
|
104
|
+
tokens: priceLockupTokens,
|
|
105
|
+
variant = {},
|
|
106
|
+
...rest
|
|
107
|
+
} = _ref7;
|
|
108
|
+
const viewport = useViewport();
|
|
109
|
+
const {
|
|
110
|
+
footnoteMarginTop,
|
|
111
|
+
footnoteGap,
|
|
112
|
+
bottomTextMarginTop,
|
|
113
|
+
priceMarginBottom,
|
|
114
|
+
bottomLinksMarginLeft,
|
|
115
|
+
topTextMarginBottom,
|
|
116
|
+
fontColor,
|
|
117
|
+
dividerColor,
|
|
118
|
+
...themeTokens
|
|
119
|
+
} = useThemeTokens('PriceLockup', priceLockupTokens, {
|
|
120
|
+
...variant,
|
|
121
|
+
size
|
|
122
|
+
}, {
|
|
123
|
+
viewport,
|
|
124
|
+
strikeThrough
|
|
125
|
+
});
|
|
126
|
+
const currencySymbolTypographyTokens = selectCurrencySymbolTypographyTokens(themeTokens);
|
|
127
|
+
const amountTypographyTokens = selectAmountTypographyTokens(themeTokens);
|
|
128
|
+
const centsTypographyTokens = selectCentsTypographyTokens(themeTokens);
|
|
129
|
+
const rateTypographyTokens = selectRateTypographyTokens(themeTokens);
|
|
130
|
+
const topTextTypographyTokens = selectTopTextTypographyTokens(themeTokens);
|
|
131
|
+
const bottomTextTypographyTokens = selectBottomTextTypographyTokens(themeTokens);
|
|
132
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
133
|
+
style: [staticStyles.priceLockupContainer, {
|
|
134
|
+
...selectProps(rest)
|
|
135
|
+
}],
|
|
136
|
+
children: [topText ? /*#__PURE__*/_jsx(View, {
|
|
137
|
+
children: renderTypography(topText, topTextTypographyTokens)
|
|
138
|
+
}) : null, renderPrice(price, rateText, ratePosition, signDirection, currencySymbol, currencySymbolTypographyTokens, amountTypographyTokens, centsTypographyTokens, rateTypographyTokens, fontColor, strikeThrough, a11yText, bottomText, bottomLinksMarginLeft, footnoteLinks, onClickFootnote, themeTokens), bottomText ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
139
|
+
children: [/*#__PURE__*/_jsx(Divider, {
|
|
140
|
+
testID: "price-lockup-divider",
|
|
141
|
+
role: "separator",
|
|
142
|
+
tokens: {
|
|
143
|
+
color: dividerColor
|
|
144
|
+
}
|
|
145
|
+
}), renderFootnoteContent(footnoteMarginTop, bottomTextMarginTop, bottomText, bottomTextTypographyTokens, fontColor, footnoteLinks, bottomLinksMarginLeft, onClickFootnote, themeTokens)]
|
|
146
|
+
}) : null]
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
PriceLockup.displayName = 'PriceLockup';
|
|
150
|
+
PriceLockup.propTypes = {
|
|
151
|
+
...selectedSystemPropTypes,
|
|
152
|
+
/**
|
|
153
|
+
* Size of the component
|
|
154
|
+
*
|
|
155
|
+
* Small for pricing in product catalogue pages, medium for pricing in product comparison cards.
|
|
156
|
+
*/
|
|
157
|
+
size: PropTypes.oneOf(['small', 'medium']),
|
|
158
|
+
/**
|
|
159
|
+
* If currency symbol other than `$` to be used
|
|
160
|
+
*/
|
|
161
|
+
currencySymbol: PropTypes.string,
|
|
162
|
+
/**
|
|
163
|
+
* Shows additional info above the price
|
|
164
|
+
*/
|
|
165
|
+
topText: PropTypes.string,
|
|
166
|
+
/**
|
|
167
|
+
* Monetary value (including decimals separated by ".")
|
|
168
|
+
*/
|
|
169
|
+
price: PropTypes.string.isRequired,
|
|
170
|
+
/**
|
|
171
|
+
* Shows month/year unit
|
|
172
|
+
*/
|
|
173
|
+
rateText: PropTypes.string,
|
|
174
|
+
/**
|
|
175
|
+
* Shows additional info below the price with a `Divider`
|
|
176
|
+
*/
|
|
177
|
+
bottomText: PropTypes.string,
|
|
178
|
+
/**
|
|
179
|
+
* Displays which side the currency should appear (left, right)
|
|
180
|
+
*/
|
|
181
|
+
signDirection: PropTypes.oneOf(['right', 'left']),
|
|
182
|
+
/**
|
|
183
|
+
* Displays where the rate should appear (bottom, right)
|
|
184
|
+
*/
|
|
185
|
+
ratePosition: PropTypes.oneOf(['right', 'bottom']),
|
|
186
|
+
/**
|
|
187
|
+
* Shows additional link for context
|
|
188
|
+
*/
|
|
189
|
+
footnoteLinks: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
|
|
190
|
+
/**
|
|
191
|
+
* Function to be called when a footnote link is clicked
|
|
192
|
+
*/
|
|
193
|
+
onClickFootnote: PropTypes.func,
|
|
194
|
+
/**
|
|
195
|
+
* To show price savings comparison
|
|
196
|
+
*/
|
|
197
|
+
strikeThrough: PropTypes.bool,
|
|
198
|
+
/**
|
|
199
|
+
* To provide a11y text for `PriceLockup` component
|
|
200
|
+
*
|
|
201
|
+
* **Note:** a11yText will override strikethrough price, so it must include price (ie. "was 50 dollars per month")
|
|
202
|
+
*/
|
|
203
|
+
a11yText: PropTypes.string,
|
|
204
|
+
/**
|
|
205
|
+
* `PriceLockup` tokens
|
|
206
|
+
*/
|
|
207
|
+
tokens: getTokensPropType('PriceLockup')
|
|
208
|
+
};
|
|
209
|
+
export default PriceLockup;
|
|
210
|
+
const staticStyles = StyleSheet.create({
|
|
211
|
+
priceLockupContainer: {
|
|
212
|
+
alignSelf: 'flex-start'
|
|
213
|
+
}
|
|
214
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
5
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
6
|
+
import renderTypography from './renderTypography';
|
|
7
|
+
import renderFootnoteLinks from './renderFootnoteLinks';
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
const selectFootnoteContainer = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
footnoteMarginTop
|
|
14
|
+
} = _ref;
|
|
15
|
+
return {
|
|
16
|
+
marginTop: footnoteMarginTop
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const selectFootnoteBottomTextContainer = _ref2 => {
|
|
20
|
+
let {
|
|
21
|
+
bottomTextMarginTop
|
|
22
|
+
} = _ref2;
|
|
23
|
+
return {
|
|
24
|
+
marginTop: bottomTextMarginTop
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const selectFootnoteLinksStyles = _ref3 => {
|
|
28
|
+
let {
|
|
29
|
+
bottomLinksMarginLeft
|
|
30
|
+
} = _ref3;
|
|
31
|
+
return {
|
|
32
|
+
marginLeft: bottomLinksMarginLeft
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const renderFootnoteContent = (footnoteMarginTop, bottomTextMarginTop, bottomText, bottomTextTypographyTokens, fontColor, footnoteLinks, bottomLinksMarginLeft, onClickFootnote, themeTokens) => {
|
|
36
|
+
const MAX_FOOTNOTE_LINKS_ALLOWED = 3;
|
|
37
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
38
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
39
|
+
style: [staticStyles.footnoteContainer, selectFootnoteContainer({
|
|
40
|
+
footnoteMarginTop
|
|
41
|
+
})],
|
|
42
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
43
|
+
style: selectFootnoteBottomTextContainer({
|
|
44
|
+
bottomTextMarginTop
|
|
45
|
+
}),
|
|
46
|
+
children: [renderTypography(bottomText, bottomTextTypographyTokens, undefined, fontColor), ' ']
|
|
47
|
+
}), footnoteLinks.length <= MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
|
|
48
|
+
style: [staticStyles.footnoteLinkContainer, selectFootnoteLinksStyles({
|
|
49
|
+
bottomLinksMarginLeft
|
|
50
|
+
})],
|
|
51
|
+
children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
|
|
52
|
+
}) : null]
|
|
53
|
+
}), footnoteLinks.length > MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
|
|
54
|
+
style: staticStyles.verticalFootnoteLinkContainer,
|
|
55
|
+
children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
|
|
56
|
+
}) : null]
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export default renderFootnoteContent;
|
|
60
|
+
const staticStyles = StyleSheet.create({
|
|
61
|
+
footnoteContainer: {
|
|
62
|
+
flexDirection: 'row'
|
|
63
|
+
},
|
|
64
|
+
footnoteLinkContainer: {
|
|
65
|
+
flexDirection: 'row',
|
|
66
|
+
...Platform.select({
|
|
67
|
+
ios: {
|
|
68
|
+
alignSelf: 'flex-end',
|
|
69
|
+
top: 2
|
|
70
|
+
},
|
|
71
|
+
android: {
|
|
72
|
+
alignSelf: 'center',
|
|
73
|
+
top: -8
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
},
|
|
77
|
+
verticalFootnoteLinkContainer: {
|
|
78
|
+
...Platform.select({
|
|
79
|
+
ios: {
|
|
80
|
+
top: 10
|
|
81
|
+
},
|
|
82
|
+
android: {
|
|
83
|
+
top: -2
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FootnoteLink from '../../Footnote/FootnoteLink';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const selectFootnoteLinkStyles = (_ref, footnoteLinks) => {
|
|
5
|
+
let {
|
|
6
|
+
footnoteLinkColor,
|
|
7
|
+
footnoteLinkFontName,
|
|
8
|
+
footnoteLinkFontWeight,
|
|
9
|
+
footnoteLinkLineHeight,
|
|
10
|
+
footnoteLinkFontSize
|
|
11
|
+
} = _ref;
|
|
12
|
+
// This is used to apply the proper line height when there is 4 or more footnote links
|
|
13
|
+
const MAX_FOOTNOTE_LINKS_ALLOWED = 3;
|
|
14
|
+
const lineHeight = footnoteLinks.length > MAX_FOOTNOTE_LINKS_ALLOWED ? footnoteLinkFontSize * footnoteLinkLineHeight : undefined;
|
|
15
|
+
return {
|
|
16
|
+
color: footnoteLinkColor,
|
|
17
|
+
fontName: footnoteLinkFontName,
|
|
18
|
+
fontWeight: footnoteLinkFontWeight,
|
|
19
|
+
lineHeight,
|
|
20
|
+
fontSize: footnoteLinkFontSize
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const renderFootnoteLinks = (footnoteLinks, themeTokens, onClickFootnote) => footnoteLinks && footnoteLinks.length > 0 ? /*#__PURE__*/_jsx(FootnoteLink, {
|
|
24
|
+
tokens: selectFootnoteLinkStyles(themeTokens, footnoteLinks),
|
|
25
|
+
content: footnoteLinks,
|
|
26
|
+
onClick: onClickFootnote
|
|
27
|
+
}) : null;
|
|
28
|
+
export default renderFootnoteLinks;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
3
|
+
import View from "react-native-web/dist/exports/View";
|
|
4
|
+
import Text from "react-native-web/dist/exports/Text";
|
|
5
|
+
import Platform from "react-native-web/dist/exports/Platform";
|
|
6
|
+
import A11yText from '../../A11yText';
|
|
7
|
+
import renderTypography from './renderTypography';
|
|
8
|
+
import renderFootnoteLinks from './renderFootnoteLinks';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const selectStrikeThroughStyles = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
strikeThroughColor
|
|
15
|
+
} = _ref;
|
|
16
|
+
return {
|
|
17
|
+
textDecorationColor: strikeThroughColor
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const selectFootnoteLinksStyles = _ref2 => {
|
|
21
|
+
let {
|
|
22
|
+
bottomLinksMarginLeft
|
|
23
|
+
} = _ref2;
|
|
24
|
+
return {
|
|
25
|
+
marginLeft: bottomLinksMarginLeft
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const renderCurrencySymbol = (currencySymbol, currencySymbolTypographyTokens, ratePosition, fontColor) => renderTypography(`${currencySymbol}`, currencySymbolTypographyTokens, ratePosition, fontColor);
|
|
29
|
+
const renderAmount = (amount, amountTypographyTokens, strikeThrough, a11yText, fontColor, themeTokens) => {
|
|
30
|
+
const amountText = renderTypography(amount, amountTypographyTokens, undefined, fontColor); // undefined is ratePosition
|
|
31
|
+
if (strikeThrough) {
|
|
32
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
33
|
+
children: [/*#__PURE__*/_jsx(A11yText, {
|
|
34
|
+
text: a11yText
|
|
35
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
36
|
+
style: [staticStyles.strikeThroughContainer, selectStrikeThroughStyles(themeTokens)],
|
|
37
|
+
children: amountText
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return amountText;
|
|
42
|
+
};
|
|
43
|
+
const renderPrice = (price, rateText, ratePosition, signDirection, currencySymbol, currencySymbolTypographyTokens, amountTypographyTokens, centsTypographyTokens, rateTypographyTokens, fontColor, strikeThrough, a11yText, bottomText, bottomLinksMarginLeft, footnoteLinks, onClickFootnote, themeTokens) => {
|
|
44
|
+
const priceString = price;
|
|
45
|
+
const lastDotPosition = priceString.lastIndexOf('.');
|
|
46
|
+
const lastCommaPosition = priceString.lastIndexOf(',');
|
|
47
|
+
const [separator, separatorPosition] = lastDotPosition > lastCommaPosition ? ['.', lastDotPosition] : [',', lastCommaPosition];
|
|
48
|
+
|
|
49
|
+
// If the separator is at the fourth character from the end of the string or more, it's most probably
|
|
50
|
+
// a part of the amount, and the cents are not included in the price string
|
|
51
|
+
const EXCLUDE_CENTS = 3;
|
|
52
|
+
const hasCents = separatorPosition !== -1 && separatorPosition >= priceString.length - EXCLUDE_CENTS;
|
|
53
|
+
const amount = hasCents ? priceString.substring(0, separatorPosition) : priceString;
|
|
54
|
+
const cents = hasCents ? priceString.substring(separatorPosition + 1) : null;
|
|
55
|
+
const footnoteLinkPositionStyles = rateText ? staticStyles.footnoteLinksWithoutBottomText : staticStyles.footnoteLinksWithoutBottomTextAndRateText;
|
|
56
|
+
const MAX_FOOTNOTE_LINKS_ALLOWED = 3;
|
|
57
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
58
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
59
|
+
style: ratePosition === 'bottom' ? staticStyles.priceContainerColumn : staticStyles.priceContainerRow,
|
|
60
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
61
|
+
style: staticStyles.priceContainer,
|
|
62
|
+
children: [signDirection === 'left' ? /*#__PURE__*/_jsx(Text, {
|
|
63
|
+
children: renderCurrencySymbol(currencySymbol, currencySymbolTypographyTokens, ratePosition, fontColor)
|
|
64
|
+
}) : null, renderAmount(amount, amountTypographyTokens, strikeThrough, a11yText, fontColor, themeTokens), cents ? renderTypography(`${separator}${cents}`, centsTypographyTokens, undefined, fontColor) : null, signDirection === 'right' ? /*#__PURE__*/_jsx(Text, {
|
|
65
|
+
style: staticStyles.currencySymbol,
|
|
66
|
+
children: renderCurrencySymbol(currencySymbol, currencySymbolTypographyTokens, ratePosition, fontColor)
|
|
67
|
+
}) : null]
|
|
68
|
+
}), rateText ? /*#__PURE__*/_jsx(Text, {
|
|
69
|
+
style: ratePosition === 'bottom' ? staticStyles.rateTextVerticalPosition : [staticStyles.rateTextPosition, staticStyles.rateTextVerticalPosition],
|
|
70
|
+
children: renderTypography(rateText, rateTypographyTokens, ratePosition, fontColor)
|
|
71
|
+
}) : null, !bottomText && footnoteLinks.length <= MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(Text, {
|
|
72
|
+
style: [footnoteLinkPositionStyles, selectFootnoteLinksStyles({
|
|
73
|
+
bottomLinksMarginLeft
|
|
74
|
+
})],
|
|
75
|
+
children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
|
|
76
|
+
}) : null]
|
|
77
|
+
}), !bottomText && footnoteLinks.length > MAX_FOOTNOTE_LINKS_ALLOWED ? /*#__PURE__*/_jsx(View, {
|
|
78
|
+
style: staticStyles.verticalFootnoteLinkContainer,
|
|
79
|
+
children: renderFootnoteLinks(footnoteLinks, themeTokens, onClickFootnote)
|
|
80
|
+
}) : null]
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
export default renderPrice;
|
|
84
|
+
const staticStyles = StyleSheet.create({
|
|
85
|
+
priceContainerRow: {
|
|
86
|
+
flexDirection: 'row'
|
|
87
|
+
},
|
|
88
|
+
priceContainerColumn: {
|
|
89
|
+
flexDirection: 'column'
|
|
90
|
+
},
|
|
91
|
+
priceContainer: {
|
|
92
|
+
flexDirection: 'row',
|
|
93
|
+
alignSelf: 'flex-start',
|
|
94
|
+
marginTop: 4
|
|
95
|
+
},
|
|
96
|
+
currencySymbol: {
|
|
97
|
+
paddingLeft: 4
|
|
98
|
+
},
|
|
99
|
+
verticalFootnoteLinkContainer: {
|
|
100
|
+
...Platform.select({
|
|
101
|
+
ios: {
|
|
102
|
+
top: 10
|
|
103
|
+
},
|
|
104
|
+
android: {
|
|
105
|
+
top: -2
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
},
|
|
109
|
+
footnoteLinksWithoutBottomText: {
|
|
110
|
+
...Platform.select({
|
|
111
|
+
ios: {
|
|
112
|
+
alignSelf: 'flex-end',
|
|
113
|
+
top: -10
|
|
114
|
+
},
|
|
115
|
+
android: {
|
|
116
|
+
alignSelf: 'center',
|
|
117
|
+
top: -14
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
footnoteLinksWithoutBottomTextAndRateText: {
|
|
122
|
+
...Platform.select({
|
|
123
|
+
ios: {
|
|
124
|
+
alignSelf: 'center'
|
|
125
|
+
},
|
|
126
|
+
android: {
|
|
127
|
+
alignSelf: 'flex-start'
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
},
|
|
131
|
+
strikeThroughContainer: {
|
|
132
|
+
textDecorationLine: 'line-through',
|
|
133
|
+
textDecorationThickness: '1px'
|
|
134
|
+
},
|
|
135
|
+
rateTextPosition: {
|
|
136
|
+
alignSelf: 'flex-end'
|
|
137
|
+
},
|
|
138
|
+
rateTextVerticalPosition: {
|
|
139
|
+
top: -8
|
|
140
|
+
}
|
|
141
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Typography from '../../Typography';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
const renderTypography = (value, themeTokens, ratePosition, fontColor) => {
|
|
5
|
+
const customProps = ratePosition === 'bottom' ? {
|
|
6
|
+
variant: {
|
|
7
|
+
size: 'micro'
|
|
8
|
+
},
|
|
9
|
+
tokens: {
|
|
10
|
+
color: fontColor
|
|
11
|
+
}
|
|
12
|
+
} : {
|
|
13
|
+
tokens: {
|
|
14
|
+
...themeTokens,
|
|
15
|
+
color: fontColor
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return /*#__PURE__*/_jsx(Typography, {
|
|
19
|
+
...customProps,
|
|
20
|
+
children: value
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export default renderTypography;
|
|
@@ -25,11 +25,13 @@ const selectSkeletonStyles = _ref => {
|
|
|
25
25
|
const selectLineStyles = _ref2 => {
|
|
26
26
|
let {
|
|
27
27
|
skeletonHeight,
|
|
28
|
-
lineWidth
|
|
28
|
+
lineWidth,
|
|
29
|
+
radius
|
|
29
30
|
} = _ref2;
|
|
30
31
|
return {
|
|
31
32
|
width: lineWidth,
|
|
32
|
-
height: skeletonHeight
|
|
33
|
+
height: skeletonHeight,
|
|
34
|
+
borderRadius: radius
|
|
33
35
|
};
|
|
34
36
|
};
|
|
35
37
|
const selectShapeStyles = _ref3 => {
|
|
@@ -112,7 +114,8 @@ const Skeleton = /*#__PURE__*/forwardRef((_ref5, ref) => {
|
|
|
112
114
|
}
|
|
113
115
|
return selectLineStyles({
|
|
114
116
|
skeletonHeight,
|
|
115
|
-
lineWidth: getLineWidth()
|
|
117
|
+
lineWidth: getLineWidth(),
|
|
118
|
+
radius: themeTokens.lineRadius
|
|
116
119
|
});
|
|
117
120
|
};
|
|
118
121
|
const renderSkeleton = function () {
|
package/lib-module/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';
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@floating-ui/react-native": "^0.8.1",
|
|
12
12
|
"@gorhom/portal": "^1.0.14",
|
|
13
13
|
"@telus-uds/system-constants": "^1.3.0",
|
|
14
|
-
"@telus-uds/system-theme-tokens": "^2.
|
|
14
|
+
"@telus-uds/system-theme-tokens": "^2.51.0",
|
|
15
15
|
"airbnb-prop-types": "^2.16.0",
|
|
16
16
|
"css-mediaquery": "^0.1.2",
|
|
17
17
|
"expo-linear-gradient": "^12.5.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"standard-engine": {
|
|
86
86
|
"skip": true
|
|
87
87
|
},
|
|
88
|
-
"version": "1.
|
|
88
|
+
"version": "1.77.0"
|
|
89
89
|
}
|