@telus-uds/components-base 1.46.0 → 1.48.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 (36) hide show
  1. package/CHANGELOG.md +32 -2
  2. package/component-docs.json +64 -12
  3. package/lib/Box/Box.js +29 -16
  4. package/lib/Button/ButtonBase.js +6 -3
  5. package/lib/ExpandCollapse/Control.js +2 -1
  6. package/lib/ExpandCollapse/Panel.js +4 -2
  7. package/lib/Link/ChevronLink.js +0 -2
  8. package/lib/Link/LinkBase.js +0 -2
  9. package/lib/Search/Search.js +4 -1
  10. package/lib/Skeleton/Skeleton.js +10 -3
  11. package/lib/Skeleton/skeleton.constant.js +2 -4
  12. package/lib/Skeleton/skeletonWebAnimation.js +13 -17
  13. package/lib/Skeleton/useSkeletonNativeAnimation.js +8 -3
  14. package/lib-module/Box/Box.js +29 -16
  15. package/lib-module/Button/ButtonBase.js +6 -3
  16. package/lib-module/ExpandCollapse/Control.js +2 -1
  17. package/lib-module/ExpandCollapse/Panel.js +4 -2
  18. package/lib-module/Link/ChevronLink.js +0 -2
  19. package/lib-module/Link/LinkBase.js +0 -2
  20. package/lib-module/Search/Search.js +4 -1
  21. package/lib-module/Skeleton/Skeleton.js +10 -3
  22. package/lib-module/Skeleton/skeleton.constant.js +1 -2
  23. package/lib-module/Skeleton/skeletonWebAnimation.js +14 -17
  24. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +9 -4
  25. package/package.json +2 -2
  26. package/src/Box/Box.jsx +27 -14
  27. package/src/Button/ButtonBase.jsx +6 -2
  28. package/src/ExpandCollapse/Control.jsx +15 -2
  29. package/src/ExpandCollapse/Panel.jsx +11 -4
  30. package/src/Link/ChevronLink.jsx +3 -10
  31. package/src/Link/LinkBase.jsx +2 -3
  32. package/src/Search/Search.jsx +1 -2
  33. package/src/Skeleton/Skeleton.jsx +9 -2
  34. package/src/Skeleton/skeleton.constant.js +0 -1
  35. package/src/Skeleton/skeletonWebAnimation.js +11 -11
  36. package/src/Skeleton/useSkeletonNativeAnimation.js +5 -4
package/CHANGELOG.md CHANGED
@@ -1,12 +1,42 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Tue, 30 May 2023 02:42:51 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 06 Jun 2023 20:37:42 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.48.0
8
+
9
+ Tue, 06 Jun 2023 20:37:42 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - add new story for 'ButtonDropdown' (kyle.king2@telus.com)
14
+ - change animation to skeleton component (mauricio.batresmontejo@telus.com)
15
+ - Bump @telus-uds/system-theme-tokens to v2.30.0
16
+
17
+ ### Patches
18
+
19
+ - Fix an issue where `Button` may not align as expected in a flex container (shahzaibkhalidmalik@outlook.com)
20
+
21
+ ## 1.47.0
22
+
23
+ Fri, 02 Jun 2023 00:34:55 GMT
24
+
25
+ ### Minor changes
26
+
27
+ - Override Search tokens with inactive variant if inactive is true (wlsdud194@hotmail.com)
28
+ - New variants added for the typography component (35577399+JoshHC@users.noreply.github.com)
29
+ - ExpandCollapse theme changes (akshay.pandey1@telus.com)
30
+ - `Box`: Introduce new `border` related tokens (shahzaibkhalidmalik@outlook.com)
31
+ - Bump @telus-uds/system-theme-tokens to v2.29.0
32
+
33
+ ### Patches
34
+
35
+ - Remove unnecessary ChevronLink changes ("textLineHeight") (kyle.king2@telus.com)
36
+
7
37
  ## 1.46.0
8
38
 
9
- Tue, 30 May 2023 02:42:51 GMT
39
+ Tue, 30 May 2023 02:46:46 GMT
10
40
 
11
41
  ### Minor changes
12
42
 
@@ -290,7 +290,13 @@
290
290
  },
291
291
  "Box": {
292
292
  "backgroundColor": "color",
293
- "gradient": "gradient"
293
+ "gradient": "gradient",
294
+ "borderWidth": "border",
295
+ "borderColor": "color",
296
+ "borderTopLeftRadius": "radius",
297
+ "borderTopRightRadius": "radius",
298
+ "borderBottomLeftRadius": "radius",
299
+ "borderBottomRightRadius": "radius"
294
300
  },
295
301
  "Button": {
296
302
  "borderColor": "color",
@@ -301,7 +307,6 @@
301
307
  "color": "color",
302
308
  "lineHeight": "lineHeight",
303
309
  "textAlign": "flexJustifyContent",
304
- "alignSelf": "flexAlign",
305
310
  "fontName": "fontName",
306
311
  "fontWeight": "fontWeight",
307
312
  "backgroundColor": "color",
@@ -499,7 +504,6 @@
499
504
  },
500
505
  "ChevronLink": {
501
506
  "fontSize": "fontSize",
502
- "textLineHeight": "lineHeight",
503
507
  "color": "color",
504
508
  "outerBorderColor": "color",
505
509
  "leftIcon": "icon",
@@ -594,7 +598,21 @@
594
598
  },
595
599
  "ExpandCollapseMiniControl": {
596
600
  "size": "size",
597
- "icon": "icon"
601
+ "icon": "icon",
602
+ "iconColor": "color",
603
+ "iconSize": "size",
604
+ "iconGap": "size",
605
+ "iconPaddingTop": "size",
606
+ "iconPosition": "position",
607
+ "verticalAlign": "verticalAlign",
608
+ "justifyContent": "flexJustifyContent",
609
+ "paddingLeft": "size",
610
+ "paddingRight": "size",
611
+ "paddingTop": "size",
612
+ "paddingBottom": "size",
613
+ "borderWidth": "border",
614
+ "borderColor": "color",
615
+ "backgroundColor": "color"
598
616
  },
599
617
  "ExpandCollapsePanel": {
600
618
  "expandDuration": "duration",
@@ -608,7 +626,21 @@
608
626
  "borderRadius": "radius",
609
627
  "borderWidth": "border",
610
628
  "expandDividerColor": "color",
611
- "expanddDividerWidth": "size"
629
+ "expandDividerWidth": "size"
630
+ },
631
+ "ExpandCollapseMiniPanel": {
632
+ "expandDuration": "duration",
633
+ "collapseDuration": "duration",
634
+ "contentPaddingLeft": "size",
635
+ "contentPaddingRight": "size",
636
+ "contentPaddingTop": "size",
637
+ "contentPaddingBottom": "size",
638
+ "marginBottom": "size",
639
+ "borderColor": "color",
640
+ "borderRadius": "radius",
641
+ "borderWidth": "border",
642
+ "expandDividerColor": "color",
643
+ "expandDividerWidth": "size"
612
644
  },
613
645
  "Feedback": {
614
646
  "backgroundColor": "color",
@@ -1650,6 +1682,8 @@
1650
1682
  },
1651
1683
  "Skeleton": {
1652
1684
  "color": "color",
1685
+ "secondColor": "color",
1686
+ "animationDuration": "integer",
1653
1687
  "size": "size",
1654
1688
  "radius": "radius",
1655
1689
  "baseWidth": "size",
@@ -3327,6 +3361,13 @@
3327
3361
  "required": false,
3328
3362
  "description": "Array of the ids of currently open groups"
3329
3363
  },
3364
+ "isMiniExpandCollapse": {
3365
+ "defaultValue": {
3366
+ "value": "false",
3367
+ "computed": false
3368
+ },
3369
+ "required": false
3370
+ },
3330
3371
  "variant": {
3331
3372
  "type": {
3332
3373
  "name": "objectOf",
@@ -3363,7 +3404,7 @@
3363
3404
  "borderRadius": "radius",
3364
3405
  "borderWidth": "border",
3365
3406
  "expandDividerColor": "color",
3366
- "expanddDividerWidth": "size"
3407
+ "expandDividerWidth": "size"
3367
3408
  }
3368
3409
  },
3369
3410
  "required": false,
@@ -3711,7 +3752,13 @@
3711
3752
  "name": "custom",
3712
3753
  "raw": {
3713
3754
  "backgroundColor": "color",
3714
- "gradient": "gradient"
3755
+ "gradient": "gradient",
3756
+ "borderWidth": "border",
3757
+ "borderColor": "color",
3758
+ "borderTopLeftRadius": "radius",
3759
+ "borderTopRightRadius": "radius",
3760
+ "borderBottomLeftRadius": "radius",
3761
+ "borderBottomRightRadius": "radius"
3715
3762
  }
3716
3763
  },
3717
3764
  "required": false,
@@ -4259,6 +4306,13 @@
4259
4306
  "required": false,
4260
4307
  "description": "Array of the ids of currently open groups"
4261
4308
  },
4309
+ "isMiniExpandCollapse": {
4310
+ "defaultValue": {
4311
+ "value": "false",
4312
+ "computed": false
4313
+ },
4314
+ "required": false
4315
+ },
4262
4316
  "variant": {
4263
4317
  "type": {
4264
4318
  "name": "objectOf",
@@ -4295,7 +4349,7 @@
4295
4349
  "borderRadius": "radius",
4296
4350
  "borderWidth": "border",
4297
4351
  "expandDividerColor": "color",
4298
- "expanddDividerWidth": "size"
4352
+ "expandDividerWidth": "size"
4299
4353
  }
4300
4354
  },
4301
4355
  "required": false,
@@ -9133,6 +9187,8 @@
9133
9187
  "name": "custom",
9134
9188
  "raw": {
9135
9189
  "color": "color",
9190
+ "secondColor": "color",
9191
+ "animationDuration": "integer",
9136
9192
  "size": "size",
9137
9193
  "radius": "radius",
9138
9194
  "baseWidth": "size",
@@ -10820,7 +10876,6 @@
10820
10876
  "color": "color",
10821
10877
  "lineHeight": "lineHeight",
10822
10878
  "textAlign": "flexJustifyContent",
10823
- "alignSelf": "flexAlign",
10824
10879
  "fontName": "fontName",
10825
10880
  "fontWeight": "fontWeight",
10826
10881
  "backgroundColor": "color",
@@ -11019,7 +11074,6 @@
11019
11074
  "color": "color",
11020
11075
  "lineHeight": "lineHeight",
11021
11076
  "textAlign": "flexJustifyContent",
11022
- "alignSelf": "flexAlign",
11023
11077
  "fontName": "fontName",
11024
11078
  "fontWeight": "fontWeight",
11025
11079
  "backgroundColor": "color",
@@ -11445,7 +11499,6 @@
11445
11499
  "color": "color",
11446
11500
  "lineHeight": "lineHeight",
11447
11501
  "textAlign": "flexJustifyContent",
11448
- "alignSelf": "flexAlign",
11449
11502
  "fontName": "fontName",
11450
11503
  "fontWeight": "fontWeight",
11451
11504
  "backgroundColor": "color",
@@ -13183,7 +13236,6 @@
13183
13236
  "name": "custom",
13184
13237
  "raw": {
13185
13238
  "fontSize": "fontSize",
13186
- "textLineHeight": "lineHeight",
13187
13239
  "color": "color",
13188
13240
  "outerBorderColor": "color",
13189
13241
  "leftIcon": "icon",
package/lib/Box/Box.js CHANGED
@@ -33,28 +33,41 @@ const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_u
33
33
  * @typedef {import('../utils/props/spacingProps.js').SpacingOptions} SpacingOptions
34
34
  */
35
35
 
36
- const selectBoxStyles = tokens => {
37
- let styles = {
38
- backgroundColor: tokens.backgroundColor
36
+ const selectBoxStyles = _ref => {
37
+ let {
38
+ backgroundColor,
39
+ gradient,
40
+ borderWidth,
41
+ borderColor,
42
+ borderTopLeftRadius,
43
+ borderTopRightRadius,
44
+ borderBottomLeftRadius,
45
+ borderBottomRightRadius,
46
+ ...rest
47
+ } = _ref;
48
+ const styles = {
49
+ backgroundColor,
50
+ borderWidth,
51
+ borderColor,
52
+ borderTopLeftRadius,
53
+ borderTopRightRadius,
54
+ borderBottomLeftRadius,
55
+ borderBottomRightRadius
39
56
  };
40
57
 
41
- if (tokens.gradient) {
58
+ if (gradient) {
42
59
  const {
43
- gradient: {
44
- angle,
45
- stops: [stopOne, stopTwo]
46
- }
47
- } = tokens;
48
- styles = { ...styles,
49
- backgroundImage: `linear-gradient(${angle}deg, ${stopOne.color}, 75% , ${stopTwo.color})`
50
- };
60
+ angle,
61
+ stops: [stopOne, stopTwo]
62
+ } = gradient;
63
+ styles.backgroundImage = `linear-gradient(${angle}deg, ${stopOne.color}, 75% , ${stopTwo.color})`;
51
64
  }
52
65
 
53
66
  const paddings = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']; // Only set on styles if token provided because we spread this object after the spacing scale values
54
67
 
55
68
  paddings.forEach(side => {
56
- if (tokens[side]) {
57
- styles[side] = tokens[side];
69
+ if (rest[side]) {
70
+ styles[side] = rest[side];
58
71
  }
59
72
  });
60
73
  return styles;
@@ -126,7 +139,7 @@ const selectBoxStyles = tokens => {
126
139
  */
127
140
 
128
141
 
129
- const Box = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
142
+ const Box = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
130
143
  let {
131
144
  space,
132
145
  horizontal = space,
@@ -145,7 +158,7 @@ const Box = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
145
158
  testID,
146
159
  dataSet,
147
160
  ...rest
148
- } = _ref;
161
+ } = _ref2;
149
162
  const props = {
150
163
  accessibilityRole,
151
164
  ...(0, _utils.getA11yPropsFromHtmlTag)(tag, accessibilityRole),
@@ -45,7 +45,6 @@ const getOuterBorderOffset = _ref => {
45
45
 
46
46
  const selectOuterContainerStyles = _ref2 => {
47
47
  let {
48
- alignSelf,
49
48
  opacity,
50
49
  outerBorderColor,
51
50
  outerBorderWidth,
@@ -53,8 +52,11 @@ const selectOuterContainerStyles = _ref2 => {
53
52
  borderRadius,
54
53
  outerBackgroundColor
55
54
  } = _ref2;
56
- return {
57
- alignSelf,
55
+ return { ..._Platform.default.select({
56
+ native: {
57
+ alignSelf: 'flex-start'
58
+ }
59
+ }),
58
60
  backgroundColor: outerBackgroundColor,
59
61
  opacity,
60
62
  ...(0, _ThemeProvider.applyOuterBorder)({
@@ -221,6 +223,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref8) => {
221
223
  web: {
222
224
  // if it would overflow the container, wraps instead
223
225
  maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
226
+ width: 'fit-content',
224
227
  outline: 'none',
225
228
  // removes the default browser :focus outline
226
229
  ...(0, _utils.getCursorStyle)(inactive, accessibilityRole)
@@ -84,9 +84,10 @@ const ExpandCollapseControl = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) =
84
84
  tokens,
85
85
  accessibilityRole = 'button',
86
86
  variant,
87
+ isMiniExpandCollapse = false,
87
88
  ...rest
88
89
  } = _ref3;
89
- const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('ExpandCollapseControl', tokens, variant);
90
+ const getTokens = (0, _ThemeProvider.useThemeTokensCallback)(isMiniExpandCollapse ? 'ExpandCollapseMiniControl' : 'ExpandCollapseControl', tokens, variant);
90
91
  const selectedProps = selectProps({
91
92
  accessibilityRole,
92
93
  ...rest,
@@ -70,6 +70,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
70
70
  children,
71
71
  tokens,
72
72
  variant,
73
+ isMiniExpandCollapse = false,
73
74
  controlRef,
74
75
  ...rest
75
76
  } = _ref2;
@@ -80,7 +81,7 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
80
81
  expanded: isExpanded
81
82
  }
82
83
  });
83
- const themeTokens = (0, _ThemeProvider.useThemeTokens)('ExpandCollapsePanel', tokens, variant, {
84
+ const themeTokens = (0, _ThemeProvider.useThemeTokens)(isMiniExpandCollapse ? 'ExpandCollapseMiniPanel' : 'ExpandCollapsePanel', tokens, variant, {
84
85
  expanded: isExpanded
85
86
  });
86
87
 
@@ -116,11 +117,12 @@ const ExpandCollapsePanel = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =>
116
117
  variant: variant,
117
118
  onPress: handleControlPress,
118
119
  ref: controlRef,
120
+ isMiniExpandCollapse: isMiniExpandCollapse,
119
121
  children: control
120
122
  }), isExpanded && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
121
123
  style: {
122
124
  borderTopColor: themeTokens.expandDividerColor,
123
- borderTopWidth: themeTokens.expanddDividerWidth,
125
+ borderTopWidth: themeTokens.expandDividerWidth,
124
126
  marginLeft: themeTokens.contentPaddingLeft,
125
127
  marginRight: themeTokens.contentPaddingRight
126
128
  }
@@ -46,7 +46,6 @@ const ChevronLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
46
46
  rightIcon,
47
47
  iconDisplace,
48
48
  height,
49
- textLineHeight,
50
49
  fontSize,
51
50
  ...otherTokens
52
51
  } = getChevronTokens(linkState);
@@ -54,7 +53,6 @@ const ChevronLink = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
54
53
  return { ...linkTokens,
55
54
  height,
56
55
  blockFontSize: tokens.fontSize ?? fontSize,
57
- textLineHeight,
58
56
  icon: direction === 'right' ? rightIcon : leftIcon,
59
57
  iconTranslateX: iconDisplace * (direction === 'right' ? 1 : -1) || 0
60
58
  };
@@ -63,13 +63,11 @@ const selectOuterBorderStyles = _ref => {
63
63
  const selectTextStyles = _ref2 => {
64
64
  let {
65
65
  color,
66
- textLineHeight,
67
66
  blockFontSize
68
67
  } = _ref2;
69
68
  return {
70
69
  color,
71
70
  ...(0, _ThemeProvider.applyTextStyles)({
72
- lineHeight: textLineHeight,
73
71
  blockFontSize
74
72
  }),
75
73
  ..._Platform.default.select({
@@ -108,7 +108,10 @@ const Search = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
108
108
  initialValue,
109
109
  onChange
110
110
  });
111
- const themeTokens = (0, _ThemeProvider.useThemeTokens)('Search', tokens, variant);
111
+ const themeTokens = (0, _ThemeProvider.useThemeTokens)('Search', tokens, {
112
+ inactive,
113
+ ...variant
114
+ });
112
115
  const buttonTokens = (0, _ThemeProvider.useThemeTokens)('SearchButton', tokens, variant);
113
116
  const getThemeTokens = (0, _ThemeProvider.useThemeTokensCallback)('Search', tokens, variant);
114
117
  const getButtonTokens = (0, _ThemeProvider.useThemeTokensCallback)('SearchButton', tokens, variant); // TODO: support overriding the a11y props using a custom dictionary
@@ -100,11 +100,18 @@ const Skeleton = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
100
100
  }
101
101
  } : // Size by an index on the spacing scale (getting default index from theme if none provided)
102
102
  sizeIndex || themeTokens.size;
103
- const skeletonHeight = (0, _utils.useSpacingScale)(spacingScaleValue);
104
- const nativeAnimation = (0, _useSkeletonNativeAnimation.default)();
103
+ const skeletonHeight = (0, _utils.useSpacingScale)(spacingScaleValue); // Animation color and animation duration
104
+
105
+ const {
106
+ secondColor,
107
+ animationDuration
108
+ } = themeTokens;
109
+ const nativeAnimation = (0, _useSkeletonNativeAnimation.default)({
110
+ animationDuration
111
+ });
105
112
 
106
113
  const getAnimationBasedOnPlatform = () => {
107
- const animation = _Platform.default.OS === 'web' ? _skeletonWebAnimation.default : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
114
+ const animation = _Platform.default.OS === 'web' ? (0, _skeletonWebAnimation.default)(secondColor, animationDuration) : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
108
115
  // @see https://github.com/necolas/react-native-web/issues/2387
109
116
 
110
117
  const styles = _StyleSheet.default.create({
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.OPACITY_STOP = exports.DEFAULT_OPACITY = exports.ANIMATION_DURATION = void 0;
6
+ exports.OPACITY_STOP = exports.DEFAULT_OPACITY = void 0;
7
7
  const DEFAULT_OPACITY = 1;
8
8
  exports.DEFAULT_OPACITY = DEFAULT_OPACITY;
9
9
  const OPACITY_STOP = 0.4;
10
- exports.OPACITY_STOP = OPACITY_STOP;
11
- const ANIMATION_DURATION = 1500;
12
- exports.ANIMATION_DURATION = ANIMATION_DURATION;
10
+ exports.OPACITY_STOP = OPACITY_STOP;
@@ -5,23 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _skeleton = require("./skeleton.constant");
9
-
10
- var _default = {
11
- animationDuration: `${_skeleton.ANIMATION_DURATION}ms`,
12
- animationTimingFunction: 'ease-in-out',
13
- animationDelay: '0.5s',
14
- animationIterationCount: 'infinite',
15
- animationKeyframes: {
16
- '0%': {
17
- opacity: _skeleton.DEFAULT_OPACITY
18
- },
19
- '50%': {
20
- opacity: _skeleton.OPACITY_STOP
21
- },
22
- '100%': {
23
- opacity: _skeleton.DEFAULT_OPACITY
8
+ const skeletonWebAnimation = (secondColor, animationTime) => {
9
+ return {
10
+ animationDuration: `${animationTime}ms`,
11
+ animationTimingFunction: 'ease-in-out',
12
+ animationDelay: '0.5s',
13
+ animationIterationCount: 'infinite',
14
+ animationKeyframes: {
15
+ '50%': {
16
+ backgroundColor: secondColor
17
+ }
24
18
  }
25
- }
19
+ };
26
20
  };
21
+
22
+ var _default = skeletonWebAnimation;
27
23
  exports.default = _default;
@@ -15,16 +15,21 @@ var _skeleton = require("./skeleton.constant");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const useSkeletonNativeAnimation = () => {
18
+ const useSkeletonNativeAnimation = _ref => {
19
+ let {
20
+ animationDuration
21
+ } = _ref;
19
22
  const fadeAnimation = (0, _react.useRef)(new _Animated.default.Value(_skeleton.DEFAULT_OPACITY)).current;
23
+ /* eslint-disable react-hooks/exhaustive-deps */
24
+
20
25
  (0, _react.useEffect)(() => {
21
26
  const fade = _Animated.default.sequence([_Animated.default.timing(fadeAnimation, {
22
27
  toValue: _skeleton.OPACITY_STOP,
23
- duration: _skeleton.ANIMATION_DURATION,
28
+ duration: animationDuration,
24
29
  useNativeDriver: _Platform.default.OS !== 'web'
25
30
  }), _Animated.default.timing(fadeAnimation, {
26
31
  toValue: _skeleton.DEFAULT_OPACITY,
27
- duration: _skeleton.ANIMATION_DURATION,
32
+ duration: animationDuration,
28
33
  useNativeDriver: _Platform.default.OS !== 'web'
29
34
  })]);
30
35
 
@@ -13,28 +13,41 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
13
13
  * @typedef {import('../utils/props/spacingProps.js').SpacingOptions} SpacingOptions
14
14
  */
15
15
 
16
- const selectBoxStyles = tokens => {
17
- let styles = {
18
- backgroundColor: tokens.backgroundColor
16
+ const selectBoxStyles = _ref => {
17
+ let {
18
+ backgroundColor,
19
+ gradient,
20
+ borderWidth,
21
+ borderColor,
22
+ borderTopLeftRadius,
23
+ borderTopRightRadius,
24
+ borderBottomLeftRadius,
25
+ borderBottomRightRadius,
26
+ ...rest
27
+ } = _ref;
28
+ const styles = {
29
+ backgroundColor,
30
+ borderWidth,
31
+ borderColor,
32
+ borderTopLeftRadius,
33
+ borderTopRightRadius,
34
+ borderBottomLeftRadius,
35
+ borderBottomRightRadius
19
36
  };
20
37
 
21
- if (tokens.gradient) {
38
+ if (gradient) {
22
39
  const {
23
- gradient: {
24
- angle,
25
- stops: [stopOne, stopTwo]
26
- }
27
- } = tokens;
28
- styles = { ...styles,
29
- backgroundImage: `linear-gradient(${angle}deg, ${stopOne.color}, 75% , ${stopTwo.color})`
30
- };
40
+ angle,
41
+ stops: [stopOne, stopTwo]
42
+ } = gradient;
43
+ styles.backgroundImage = `linear-gradient(${angle}deg, ${stopOne.color}, 75% , ${stopTwo.color})`;
31
44
  }
32
45
 
33
46
  const paddings = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']; // Only set on styles if token provided because we spread this object after the spacing scale values
34
47
 
35
48
  paddings.forEach(side => {
36
- if (tokens[side]) {
37
- styles[side] = tokens[side];
49
+ if (rest[side]) {
50
+ styles[side] = rest[side];
38
51
  }
39
52
  });
40
53
  return styles;
@@ -106,7 +119,7 @@ const selectBoxStyles = tokens => {
106
119
  */
107
120
 
108
121
 
109
- const Box = /*#__PURE__*/forwardRef((_ref, ref) => {
122
+ const Box = /*#__PURE__*/forwardRef((_ref2, ref) => {
110
123
  let {
111
124
  space,
112
125
  horizontal = space,
@@ -125,7 +138,7 @@ const Box = /*#__PURE__*/forwardRef((_ref, ref) => {
125
138
  testID,
126
139
  dataSet,
127
140
  ...rest
128
- } = _ref;
141
+ } = _ref2;
129
142
  const props = {
130
143
  accessibilityRole,
131
144
  ...getA11yPropsFromHtmlTag(tag, accessibilityRole),
@@ -21,7 +21,6 @@ const getOuterBorderOffset = _ref => {
21
21
 
22
22
  const selectOuterContainerStyles = _ref2 => {
23
23
  let {
24
- alignSelf,
25
24
  opacity,
26
25
  outerBorderColor,
27
26
  outerBorderWidth,
@@ -29,8 +28,11 @@ const selectOuterContainerStyles = _ref2 => {
29
28
  borderRadius,
30
29
  outerBackgroundColor
31
30
  } = _ref2;
32
- return {
33
- alignSelf,
31
+ return { ...Platform.select({
32
+ native: {
33
+ alignSelf: 'flex-start'
34
+ }
35
+ }),
34
36
  backgroundColor: outerBackgroundColor,
35
37
  opacity,
36
38
  ...applyOuterBorder({
@@ -197,6 +199,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref8) => {
197
199
  web: {
198
200
  // if it would overflow the container, wraps instead
199
201
  maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
202
+ width: 'fit-content',
200
203
  outline: 'none',
201
204
  // removes the default browser :focus outline
202
205
  ...getCursorStyle(inactive, accessibilityRole)
@@ -66,9 +66,10 @@ const ExpandCollapseControl = /*#__PURE__*/forwardRef((_ref3, ref) => {
66
66
  tokens,
67
67
  accessibilityRole = 'button',
68
68
  variant,
69
+ isMiniExpandCollapse = false,
69
70
  ...rest
70
71
  } = _ref3;
71
- const getTokens = useThemeTokensCallback('ExpandCollapseControl', tokens, variant);
72
+ const getTokens = useThemeTokensCallback(isMiniExpandCollapse ? 'ExpandCollapseMiniControl' : 'ExpandCollapseControl', tokens, variant);
72
73
  const selectedProps = selectProps({
73
74
  accessibilityRole,
74
75
  ...rest,
@@ -48,6 +48,7 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
48
48
  children,
49
49
  tokens,
50
50
  variant,
51
+ isMiniExpandCollapse = false,
51
52
  controlRef,
52
53
  ...rest
53
54
  } = _ref2;
@@ -58,7 +59,7 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
58
59
  expanded: isExpanded
59
60
  }
60
61
  });
61
- const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
62
+ const themeTokens = useThemeTokens(isMiniExpandCollapse ? 'ExpandCollapseMiniPanel' : 'ExpandCollapsePanel', tokens, variant, {
62
63
  expanded: isExpanded
63
64
  });
64
65
 
@@ -94,11 +95,12 @@ const ExpandCollapsePanel = /*#__PURE__*/forwardRef((_ref2, ref) => {
94
95
  variant: variant,
95
96
  onPress: handleControlPress,
96
97
  ref: controlRef,
98
+ isMiniExpandCollapse: isMiniExpandCollapse,
97
99
  children: control
98
100
  }), isExpanded && /*#__PURE__*/_jsx(View, {
99
101
  style: {
100
102
  borderTopColor: themeTokens.expandDividerColor,
101
- borderTopWidth: themeTokens.expanddDividerWidth,
103
+ borderTopWidth: themeTokens.expandDividerWidth,
102
104
  marginLeft: themeTokens.contentPaddingLeft,
103
105
  marginRight: themeTokens.contentPaddingRight
104
106
  }
@@ -28,7 +28,6 @@ const ChevronLink = /*#__PURE__*/forwardRef((_ref, ref) => {
28
28
  rightIcon,
29
29
  iconDisplace,
30
30
  height,
31
- textLineHeight,
32
31
  fontSize,
33
32
  ...otherTokens
34
33
  } = getChevronTokens(linkState);
@@ -36,7 +35,6 @@ const ChevronLink = /*#__PURE__*/forwardRef((_ref, ref) => {
36
35
  return { ...linkTokens,
37
36
  height,
38
37
  blockFontSize: tokens.fontSize ?? fontSize,
39
- textLineHeight,
40
38
  icon: direction === 'right' ? rightIcon : leftIcon,
41
39
  iconTranslateX: iconDisplace * (direction === 'right' ? 1 : -1) || 0
42
40
  };
@@ -38,13 +38,11 @@ const selectOuterBorderStyles = _ref => {
38
38
  const selectTextStyles = _ref2 => {
39
39
  let {
40
40
  color,
41
- textLineHeight,
42
41
  blockFontSize
43
42
  } = _ref2;
44
43
  return {
45
44
  color,
46
45
  ...applyTextStyles({
47
- lineHeight: textLineHeight,
48
46
  blockFontSize
49
47
  }),
50
48
  ...Platform.select({
@@ -85,7 +85,10 @@ const Search = /*#__PURE__*/forwardRef((_ref3, ref) => {
85
85
  initialValue,
86
86
  onChange
87
87
  });
88
- const themeTokens = useThemeTokens('Search', tokens, variant);
88
+ const themeTokens = useThemeTokens('Search', tokens, {
89
+ inactive,
90
+ ...variant
91
+ });
89
92
  const buttonTokens = useThemeTokens('SearchButton', tokens, variant);
90
93
  const getThemeTokens = useThemeTokensCallback('Search', tokens, variant);
91
94
  const getButtonTokens = useThemeTokensCallback('SearchButton', tokens, variant); // TODO: support overriding the a11y props using a custom dictionary
@@ -75,11 +75,18 @@ const Skeleton = /*#__PURE__*/forwardRef((_ref5, ref) => {
75
75
  }
76
76
  } : // Size by an index on the spacing scale (getting default index from theme if none provided)
77
77
  sizeIndex || themeTokens.size;
78
- const skeletonHeight = useSpacingScale(spacingScaleValue);
79
- const nativeAnimation = useSkeletonNativeAnimation();
78
+ const skeletonHeight = useSpacingScale(spacingScaleValue); // Animation color and animation duration
79
+
80
+ const {
81
+ secondColor,
82
+ animationDuration
83
+ } = themeTokens;
84
+ const nativeAnimation = useSkeletonNativeAnimation({
85
+ animationDuration
86
+ });
80
87
 
81
88
  const getAnimationBasedOnPlatform = () => {
82
- const animation = Platform.OS === 'web' ? skeletonWebAnimation : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
89
+ const animation = Platform.OS === 'web' ? skeletonWebAnimation(secondColor, animationDuration) : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
83
90
  // @see https://github.com/necolas/react-native-web/issues/2387
84
91
 
85
92
  const styles = StyleSheet.create({
@@ -1,3 +1,2 @@
1
1
  export const DEFAULT_OPACITY = 1;
2
- export const OPACITY_STOP = 0.4;
3
- export const ANIMATION_DURATION = 1500;
2
+ export const OPACITY_STOP = 0.4;
@@ -1,18 +1,15 @@
1
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
2
- export default {
3
- animationDuration: `${ANIMATION_DURATION}ms`,
4
- animationTimingFunction: 'ease-in-out',
5
- animationDelay: '0.5s',
6
- animationIterationCount: 'infinite',
7
- animationKeyframes: {
8
- '0%': {
9
- opacity: DEFAULT_OPACITY
10
- },
11
- '50%': {
12
- opacity: OPACITY_STOP
13
- },
14
- '100%': {
15
- opacity: DEFAULT_OPACITY
1
+ const skeletonWebAnimation = (secondColor, animationTime) => {
2
+ return {
3
+ animationDuration: `${animationTime}ms`,
4
+ animationTimingFunction: 'ease-in-out',
5
+ animationDelay: '0.5s',
6
+ animationIterationCount: 'infinite',
7
+ animationKeyframes: {
8
+ '50%': {
9
+ backgroundColor: secondColor
10
+ }
16
11
  }
17
- }
18
- };
12
+ };
13
+ };
14
+
15
+ export default skeletonWebAnimation;
@@ -1,18 +1,23 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  import Animated from "react-native-web/dist/exports/Animated";
3
3
  import Platform from "react-native-web/dist/exports/Platform";
4
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
4
+ import { DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
5
5
 
6
- const useSkeletonNativeAnimation = () => {
6
+ const useSkeletonNativeAnimation = _ref => {
7
+ let {
8
+ animationDuration
9
+ } = _ref;
7
10
  const fadeAnimation = useRef(new Animated.Value(DEFAULT_OPACITY)).current;
11
+ /* eslint-disable react-hooks/exhaustive-deps */
12
+
8
13
  useEffect(() => {
9
14
  const fade = Animated.sequence([Animated.timing(fadeAnimation, {
10
15
  toValue: OPACITY_STOP,
11
- duration: ANIMATION_DURATION,
16
+ duration: animationDuration,
12
17
  useNativeDriver: Platform.OS !== 'web'
13
18
  }), Animated.timing(fadeAnimation, {
14
19
  toValue: DEFAULT_OPACITY,
15
- duration: ANIMATION_DURATION,
20
+ duration: animationDuration,
16
21
  useNativeDriver: Platform.OS !== 'web'
17
22
  })]);
18
23
  Animated.loop(fade).start();
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.2.1",
14
- "@telus-uds/system-theme-tokens": "^2.28.0",
14
+ "@telus-uds/system-theme-tokens": "^2.30.0",
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "lodash.debounce": "^4.0.8",
17
17
  "lodash.merge": "^4.6.2",
@@ -72,5 +72,5 @@
72
72
  "standard-engine": {
73
73
  "skip": true
74
74
  },
75
- "version": "1.46.0"
75
+ "version": "1.48.0"
76
76
  }
package/src/Box/Box.jsx CHANGED
@@ -23,26 +23,39 @@ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, vie
23
23
  * @typedef {import('../utils/props/spacingProps.js').SpacingOptions} SpacingOptions
24
24
  */
25
25
 
26
- const selectBoxStyles = (tokens) => {
27
- let styles = { backgroundColor: tokens.backgroundColor }
28
- if (tokens.gradient) {
26
+ const selectBoxStyles = ({
27
+ backgroundColor,
28
+ gradient,
29
+ borderWidth,
30
+ borderColor,
31
+ borderTopLeftRadius,
32
+ borderTopRightRadius,
33
+ borderBottomLeftRadius,
34
+ borderBottomRightRadius,
35
+ ...rest
36
+ }) => {
37
+ const styles = {
38
+ backgroundColor,
39
+ borderWidth,
40
+ borderColor,
41
+ borderTopLeftRadius,
42
+ borderTopRightRadius,
43
+ borderBottomLeftRadius,
44
+ borderBottomRightRadius
45
+ }
46
+ if (gradient) {
29
47
  const {
30
- gradient: {
31
- angle,
32
- stops: [stopOne, stopTwo]
33
- }
34
- } = tokens
35
- styles = {
36
- ...styles,
37
- backgroundImage: `linear-gradient(${angle}deg, ${stopOne.color}, 75% , ${stopTwo.color})`
38
- }
48
+ angle,
49
+ stops: [stopOne, stopTwo]
50
+ } = gradient
51
+ styles.backgroundImage = `linear-gradient(${angle}deg, ${stopOne.color}, 75% , ${stopTwo.color})`
39
52
  }
40
53
 
41
54
  const paddings = ['paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom']
42
55
  // Only set on styles if token provided because we spread this object after the spacing scale values
43
56
  paddings.forEach((side) => {
44
- if (tokens[side]) {
45
- styles[side] = tokens[side]
57
+ if (rest[side]) {
58
+ styles[side] = rest[side]
46
59
  }
47
60
  })
48
61
  return styles
@@ -30,7 +30,6 @@ const getOuterBorderOffset = ({ outerBorderGap = 0, outerBorderWidth = 0 }) =>
30
30
  outerBorderGap + outerBorderWidth
31
31
 
32
32
  const selectOuterContainerStyles = ({
33
- alignSelf,
34
33
  opacity,
35
34
  outerBorderColor,
36
35
  outerBorderWidth,
@@ -38,7 +37,11 @@ const selectOuterContainerStyles = ({
38
37
  borderRadius,
39
38
  outerBackgroundColor
40
39
  }) => ({
41
- alignSelf,
40
+ ...Platform.select({
41
+ native: {
42
+ alignSelf: 'flex-start'
43
+ }
44
+ }),
42
45
  backgroundColor: outerBackgroundColor,
43
46
  opacity,
44
47
  ...applyOuterBorder({
@@ -162,6 +165,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, { accessibilityRole }) => {
162
165
  web: {
163
166
  // if it would overflow the container, wraps instead
164
167
  maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
168
+ width: 'fit-content',
165
169
  outline: 'none', // removes the default browser :focus outline
166
170
  ...getCursorStyle(inactive, accessibilityRole)
167
171
  },
@@ -52,10 +52,23 @@ function selectIconTokens(tokens) {
52
52
 
53
53
  const ExpandCollapseControl = forwardRef(
54
54
  (
55
- { onPress, isExpanded, children, tokens, accessibilityRole = 'button', variant, ...rest },
55
+ {
56
+ onPress,
57
+ isExpanded,
58
+ children,
59
+ tokens,
60
+ accessibilityRole = 'button',
61
+ variant,
62
+ isMiniExpandCollapse = false,
63
+ ...rest
64
+ },
56
65
  ref
57
66
  ) => {
58
- const getTokens = useThemeTokensCallback('ExpandCollapseControl', tokens, variant)
67
+ const getTokens = useThemeTokensCallback(
68
+ isMiniExpandCollapse ? 'ExpandCollapseMiniControl' : 'ExpandCollapseControl',
69
+ tokens,
70
+ variant
71
+ )
59
72
 
60
73
  const selectedProps = selectProps({
61
74
  accessibilityRole,
@@ -51,6 +51,7 @@ const ExpandCollapsePanel = forwardRef(
51
51
  children,
52
52
  tokens,
53
53
  variant,
54
+ isMiniExpandCollapse = false,
54
55
  controlRef,
55
56
  ...rest
56
57
  },
@@ -67,9 +68,14 @@ const ExpandCollapsePanel = forwardRef(
67
68
  }
68
69
  })
69
70
 
70
- const themeTokens = useThemeTokens('ExpandCollapsePanel', tokens, variant, {
71
- expanded: isExpanded
72
- })
71
+ const themeTokens = useThemeTokens(
72
+ isMiniExpandCollapse ? 'ExpandCollapseMiniPanel' : 'ExpandCollapsePanel',
73
+ tokens,
74
+ variant,
75
+ {
76
+ expanded: isExpanded
77
+ }
78
+ )
73
79
 
74
80
  const handleControlPress = (event) => {
75
81
  onToggle(panelId, event)
@@ -100,6 +106,7 @@ const ExpandCollapsePanel = forwardRef(
100
106
  variant={variant}
101
107
  onPress={handleControlPress}
102
108
  ref={controlRef}
109
+ isMiniExpandCollapse={isMiniExpandCollapse}
103
110
  >
104
111
  {control}
105
112
  </ExpandCollapseControl>
@@ -107,7 +114,7 @@ const ExpandCollapsePanel = forwardRef(
107
114
  <View
108
115
  style={{
109
116
  borderTopColor: themeTokens.expandDividerColor,
110
- borderTopWidth: themeTokens.expanddDividerWidth,
117
+ borderTopWidth: themeTokens.expandDividerWidth,
111
118
  marginLeft: themeTokens.contentPaddingLeft,
112
119
  marginRight: themeTokens.contentPaddingRight
113
120
  }}
@@ -15,22 +15,15 @@ const ChevronLink = forwardRef(
15
15
  ({ direction = 'right', children, tokens = {}, variant, dataSet, ...linkProps }, ref) => {
16
16
  const getChevronTokens = useThemeTokensCallback('ChevronLink', tokens, variant)
17
17
  const applyChevronTokens = (linkState) => {
18
- const {
19
- leftIcon,
20
- rightIcon,
21
- iconDisplace,
22
- height,
23
- textLineHeight,
24
- fontSize,
25
- ...otherTokens
26
- } = getChevronTokens(linkState)
18
+ const { leftIcon, rightIcon, iconDisplace, height, fontSize, ...otherTokens } =
19
+ getChevronTokens(linkState)
20
+
27
21
  const linkTokens = selectTokens('Link', otherTokens)
28
22
 
29
23
  return {
30
24
  ...linkTokens,
31
25
  height,
32
26
  blockFontSize: tokens.fontSize ?? fontSize,
33
- textLineHeight,
34
27
  icon: direction === 'right' ? rightIcon : leftIcon,
35
28
  iconTranslateX: iconDisplace * (direction === 'right' ? 1 : -1) || 0
36
29
  }
@@ -42,10 +42,10 @@ const selectOuterBorderStyles = ({
42
42
  }
43
43
  : {}
44
44
 
45
- const selectTextStyles = ({ color, textLineHeight, blockFontSize }) => {
45
+ const selectTextStyles = ({ color, blockFontSize }) => {
46
46
  return {
47
47
  color,
48
- ...applyTextStyles({ lineHeight: textLineHeight, blockFontSize }),
48
+ ...applyTextStyles({ blockFontSize }),
49
49
  ...Platform.select({
50
50
  web: {
51
51
  // TODO: https://github.com/telus/universal-design-system/issues/487
@@ -168,7 +168,6 @@ const LinkBase = forwardRef(
168
168
  const themeTokens = resolveLinkTokens(linkState)
169
169
  const textStyles = selectTextStyles(themeTokens)
170
170
  const iconTokens = selectIconTokens(themeTokens)
171
-
172
171
  // TODO: may need to apply some smarter text inheritance here if inline to avoid native
173
172
  // issues like double-application of line heights breaking align-items: baseline
174
173
  const blockTextStyles = selectBlockStyles(themeTokens, themeOptions)
@@ -81,9 +81,8 @@ const Search = forwardRef(
81
81
  onChange
82
82
  })
83
83
 
84
- const themeTokens = useThemeTokens('Search', tokens, variant)
84
+ const themeTokens = useThemeTokens('Search', tokens, { inactive, ...variant })
85
85
  const buttonTokens = useThemeTokens('SearchButton', tokens, variant)
86
-
87
86
  const getThemeTokens = useThemeTokensCallback('Search', tokens, variant)
88
87
  const getButtonTokens = useThemeTokensCallback('SearchButton', tokens, variant)
89
88
 
@@ -63,10 +63,17 @@ const Skeleton = forwardRef(
63
63
  : // Size by an index on the spacing scale (getting default index from theme if none provided)
64
64
  sizeIndex || themeTokens.size
65
65
  const skeletonHeight = useSpacingScale(spacingScaleValue)
66
- const nativeAnimation = useSkeletonNativeAnimation()
66
+
67
+ // Animation color and animation duration
68
+ const { secondColor, animationDuration } = themeTokens
69
+
70
+ const nativeAnimation = useSkeletonNativeAnimation({ animationDuration })
67
71
 
68
72
  const getAnimationBasedOnPlatform = () => {
69
- const animation = Platform.OS === 'web' ? skeletonWebAnimation : nativeAnimation
73
+ const animation =
74
+ Platform.OS === 'web'
75
+ ? skeletonWebAnimation(secondColor, animationDuration)
76
+ : nativeAnimation
70
77
  // We must pass the animation styles through `StyleSheet.create`
71
78
  // @see https://github.com/necolas/react-native-web/issues/2387
72
79
  const styles = StyleSheet.create({ animation })
@@ -1,3 +1,2 @@
1
1
  export const DEFAULT_OPACITY = 1
2
2
  export const OPACITY_STOP = 0.4
3
- export const ANIMATION_DURATION = 1500
@@ -1,13 +1,13 @@
1
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
2
-
3
- export default {
4
- animationDuration: `${ANIMATION_DURATION}ms`,
5
- animationTimingFunction: 'ease-in-out',
6
- animationDelay: '0.5s',
7
- animationIterationCount: 'infinite',
8
- animationKeyframes: {
9
- '0%': { opacity: DEFAULT_OPACITY },
10
- '50%': { opacity: OPACITY_STOP },
11
- '100%': { opacity: DEFAULT_OPACITY }
1
+ const skeletonWebAnimation = (secondColor, animationTime) => {
2
+ return {
3
+ animationDuration: `${animationTime}ms`,
4
+ animationTimingFunction: 'ease-in-out',
5
+ animationDelay: '0.5s',
6
+ animationIterationCount: 'infinite',
7
+ animationKeyframes: {
8
+ '50%': { backgroundColor: secondColor }
9
+ }
12
10
  }
13
11
  }
12
+
13
+ export default skeletonWebAnimation
@@ -1,20 +1,21 @@
1
1
  import { useEffect, useRef } from 'react'
2
2
  import { Animated, Platform } from 'react-native'
3
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
3
+ import { DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
4
4
 
5
- const useSkeletonNativeAnimation = () => {
5
+ const useSkeletonNativeAnimation = ({ animationDuration }) => {
6
6
  const fadeAnimation = useRef(new Animated.Value(DEFAULT_OPACITY)).current
7
7
 
8
+ /* eslint-disable react-hooks/exhaustive-deps */
8
9
  useEffect(() => {
9
10
  const fade = Animated.sequence([
10
11
  Animated.timing(fadeAnimation, {
11
12
  toValue: OPACITY_STOP,
12
- duration: ANIMATION_DURATION,
13
+ duration: animationDuration,
13
14
  useNativeDriver: Platform.OS !== 'web'
14
15
  }),
15
16
  Animated.timing(fadeAnimation, {
16
17
  toValue: DEFAULT_OPACITY,
17
- duration: ANIMATION_DURATION,
18
+ duration: animationDuration,
18
19
  useNativeDriver: Platform.OS !== 'web'
19
20
  })
20
21
  ])