@telus-uds/components-base 1.15.0 → 1.17.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 (54) hide show
  1. package/CHANGELOG.md +36 -2
  2. package/component-docs.json +1322 -346
  3. package/lib/BaseProvider/index.js +5 -1
  4. package/lib/Button/ButtonBase.js +2 -1
  5. package/lib/Carousel/Carousel.js +18 -2
  6. package/lib/Carousel/CarouselTabs/CarouselTabs.js +6 -7
  7. package/lib/List/List.js +11 -8
  8. package/lib/List/PressableListItemBase.js +5 -9
  9. package/lib/QuickLinks/QuickLinks.js +91 -0
  10. package/lib/QuickLinks/QuickLinksCard.js +47 -0
  11. package/lib/QuickLinks/QuickLinksItem.js +73 -0
  12. package/lib/QuickLinks/index.js +16 -0
  13. package/lib/Skeleton/Skeleton.js +18 -13
  14. package/lib/Skeleton/useSkeletonNativeAnimation.js +4 -2
  15. package/lib/Timeline/Timeline.js +193 -0
  16. package/lib/Timeline/index.js +13 -0
  17. package/lib/ToggleSwitch/ToggleSwitch.js +24 -19
  18. package/lib/index.js +28 -1
  19. package/lib/utils/props/a11yProps.js +50 -47
  20. package/lib-module/BaseProvider/index.js +4 -1
  21. package/lib-module/Button/ButtonBase.js +2 -1
  22. package/lib-module/Carousel/Carousel.js +16 -2
  23. package/lib-module/Carousel/CarouselTabs/CarouselTabs.js +7 -6
  24. package/lib-module/List/List.js +12 -8
  25. package/lib-module/List/PressableListItemBase.js +6 -10
  26. package/lib-module/QuickLinks/QuickLinks.js +71 -0
  27. package/lib-module/QuickLinks/QuickLinksCard.js +33 -0
  28. package/lib-module/QuickLinks/QuickLinksItem.js +50 -0
  29. package/lib-module/QuickLinks/index.js +4 -0
  30. package/lib-module/Skeleton/Skeleton.js +15 -13
  31. package/lib-module/Skeleton/useSkeletonNativeAnimation.js +3 -2
  32. package/lib-module/Timeline/Timeline.js +174 -0
  33. package/lib-module/Timeline/index.js +2 -0
  34. package/lib-module/ToggleSwitch/ToggleSwitch.js +24 -19
  35. package/lib-module/index.js +4 -1
  36. package/lib-module/utils/props/a11yProps.js +50 -47
  37. package/package.json +8 -7
  38. package/src/BaseProvider/index.jsx +2 -1
  39. package/src/Button/ButtonBase.jsx +2 -2
  40. package/src/Carousel/Carousel.jsx +15 -2
  41. package/src/Carousel/CarouselTabs/CarouselTabs.jsx +5 -3
  42. package/src/List/List.jsx +9 -13
  43. package/src/List/PressableListItemBase.jsx +7 -9
  44. package/src/QuickLinks/QuickLinks.jsx +61 -0
  45. package/src/QuickLinks/QuickLinksCard.jsx +26 -0
  46. package/src/QuickLinks/QuickLinksItem.jsx +46 -0
  47. package/src/QuickLinks/index.js +6 -0
  48. package/src/Skeleton/Skeleton.jsx +25 -19
  49. package/src/Skeleton/useSkeletonNativeAnimation.js +3 -3
  50. package/src/Timeline/Timeline.jsx +148 -0
  51. package/src/Timeline/index.js +3 -0
  52. package/src/ToggleSwitch/ToggleSwitch.jsx +3 -3
  53. package/src/index.js +3 -0
  54. package/src/utils/props/a11yProps.js +61 -68
@@ -36,54 +36,57 @@ const nativeA11yPropTypes = {
36
36
  onAccessibilityEscape: PropTypes.func,
37
37
  onAccessibilityTap: PropTypes.func
38
38
  };
39
- const a11yPropTypes = Platform.select({
39
+ const a11yPropTypes = { ...nativeA11yPropTypes,
40
40
  // React Native Web adds many a11y props that alias aria-* attributes
41
41
  // Types based on https://necolas.github.io/react-native-web/docs/accessibility/
42
- web: { ...nativeA11yPropTypes,
43
- accessibilityActiveDescendant: PropTypes.string,
44
- accessibilityAtomic: PropTypes.bool,
45
- accessibilityAutoComplete: PropTypes.string,
46
- accessibilityBusy: PropTypes.bool,
47
- accessibilityChecked: PropTypes.oneOf([true, false, 'mixed']),
48
- accessibilityColumnCount: PropTypes.number,
49
- accessibilityColumnIndex: PropTypes.number,
50
- accessibilityColumnSpan: PropTypes.number,
51
- accessibilityControls: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
52
- accessibilityCurrent: PropTypes.oneOf([true, false, 'page', 'step', 'location', 'date', 'time']),
53
- accessibilityDescribedBy: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
54
- accessibilityDetails: PropTypes.string,
55
- accessibilityDisabled: PropTypes.bool,
56
- accessibilityErrorMessage: PropTypes.string,
57
- accessibilityExpanded: PropTypes.bool,
58
- accessibilityFlowTo: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
59
- accessibilityHasPopup: PropTypes.string,
60
- accessibilityHidden: PropTypes.bool,
61
- accessibilityInvalid: PropTypes.bool,
62
- accessibilityKeyShortcuts: PropTypes.string,
63
- accessibilityLabelledBy: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
64
- accessibilityLevel: PropTypes.number,
65
- accessibilityModal: PropTypes.bool,
66
- accessibilityMultiline: PropTypes.bool,
67
- accessibilityMultiSelectable: PropTypes.bool,
68
- accessibilityOrientation: PropTypes.oneOf(['horizontal', 'vertical']),
69
- accessibilityOwns: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
70
- accessibilityPlaceholder: PropTypes.string,
71
- accessibilityPosInSet: PropTypes.number,
72
- accessibilityPressed: PropTypes.bool,
73
- accessibilityReadOnly: PropTypes.bool,
74
- accessibilityRequired: PropTypes.bool,
75
- accessibilityRoleDescription: PropTypes.string,
76
- accessibilityRowCount: PropTypes.number,
77
- accessibilityRowIndex: PropTypes.number,
78
- accessibilityRowSpan: PropTypes.number,
79
- accessibilitySelected: PropTypes.bool,
80
- accessibilitySetSize: PropTypes.number,
81
- accessibilitySort: PropTypes.oneOf(['ascending', 'descending', 'none', 'other']),
82
- accessibilityValueMax: PropTypes.number,
83
- accessibilityValueMin: PropTypes.number,
84
- accessibilityValueNow: PropTypes.number,
85
- accessibilityValueText: PropTypes.string
86
- },
42
+ accessibilityActiveDescendant: PropTypes.string,
43
+ accessibilityAtomic: PropTypes.bool,
44
+ accessibilityAutoComplete: PropTypes.string,
45
+ accessibilityBusy: PropTypes.bool,
46
+ accessibilityChecked: PropTypes.oneOf([true, false, 'mixed']),
47
+ accessibilityColumnCount: PropTypes.number,
48
+ accessibilityColumnIndex: PropTypes.number,
49
+ accessibilityColumnSpan: PropTypes.number,
50
+ accessibilityControls: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
51
+ accessibilityCurrent: PropTypes.oneOf([true, false, 'page', 'step', 'location', 'date', 'time']),
52
+ accessibilityDescribedBy: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
53
+ accessibilityDetails: PropTypes.string,
54
+ accessibilityDisabled: PropTypes.bool,
55
+ accessibilityErrorMessage: PropTypes.string,
56
+ accessibilityExpanded: PropTypes.bool,
57
+ accessibilityFlowTo: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
58
+ accessibilityHasPopup: PropTypes.string,
59
+ accessibilityHidden: PropTypes.bool,
60
+ accessibilityInvalid: PropTypes.bool,
61
+ accessibilityKeyShortcuts: PropTypes.string,
62
+ accessibilityLabelledBy: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
63
+ accessibilityLevel: PropTypes.number,
64
+ accessibilityModal: PropTypes.bool,
65
+ accessibilityMultiline: PropTypes.bool,
66
+ accessibilityMultiSelectable: PropTypes.bool,
67
+ accessibilityOrientation: PropTypes.oneOf(['horizontal', 'vertical']),
68
+ accessibilityOwns: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
69
+ accessibilityPlaceholder: PropTypes.string,
70
+ accessibilityPosInSet: PropTypes.number,
71
+ accessibilityPressed: PropTypes.bool,
72
+ accessibilityReadOnly: PropTypes.bool,
73
+ accessibilityRequired: PropTypes.bool,
74
+ accessibilityRoleDescription: PropTypes.string,
75
+ accessibilityRowCount: PropTypes.number,
76
+ accessibilityRowIndex: PropTypes.number,
77
+ accessibilityRowSpan: PropTypes.number,
78
+ accessibilitySelected: PropTypes.bool,
79
+ accessibilitySetSize: PropTypes.number,
80
+ accessibilitySort: PropTypes.oneOf(['ascending', 'descending', 'none', 'other']),
81
+ accessibilityValueMax: PropTypes.number,
82
+ accessibilityValueMin: PropTypes.number,
83
+ accessibilityValueNow: PropTypes.number,
84
+ accessibilityValueText: PropTypes.string
85
+ };
86
+ const a11yPropTypesByPlatform = Platform.select({
87
+ // React Native Web adds many a11y props that alias aria-* attributes
88
+ // Types based on https://necolas.github.io/react-native-web/docs/accessibility/
89
+ web: a11yPropTypes,
87
90
  // Ignore web-only props in native builds
88
91
  default: nativeA11yPropTypes
89
92
  }); // These RNW-only props only exist in RNW >=0.18. Catch them and map them according to platform
@@ -255,7 +258,7 @@ export default {
255
258
  * then spread the returned object into the component's props (usually its outer container).
256
259
  */
257
260
  select: getPropSelector( // Allow all React Native accessibility props
258
- a11yPropTypes, // Allow any `aria-*` attribute on web; ignore them on native
261
+ a11yPropTypesByPlatform, // Allow any `aria-*` attribute on web; ignore them on native
259
262
  Platform.OS === 'web' && /^aria-/, // For the props added and deprecated in React Native Web 0.18, convert them to
260
263
  // a form that is platform-appropriate and RNW-version safe
261
264
  (key, value) => {
package/package.json CHANGED
@@ -7,9 +7,10 @@
7
7
  "url": "https://github.com/telus/universal-design-system/issues"
8
8
  },
9
9
  "dependencies": {
10
- "airbnb-prop-types": "^2.16.0",
10
+ "@gorhom/portal": "^1.0.14",
11
11
  "@telus-uds/system-constants": "^1.0.4",
12
- "@telus-uds/system-theme-tokens": "^2.4.0",
12
+ "@telus-uds/system-theme-tokens": "^2.6.0",
13
+ "airbnb-prop-types": "^2.16.0",
13
14
  "lodash.debounce": "^4.0.8",
14
15
  "lodash.merge": "^4.6.2",
15
16
  "prop-types": "^15.7.2",
@@ -21,10 +22,10 @@
21
22
  "@telus-uds/browserslist-config": "^1.0.4",
22
23
  "@testing-library/jest-native": "^4.0.1",
23
24
  "@testing-library/react": "^13.3.0",
24
- "@testing-library/react-native": "11.0.0",
25
- "react-test-renderer": "~18.0.0",
26
25
  "@testing-library/react-hooks": "~7.0.1",
26
+ "@testing-library/react-native": "11.0.0",
27
27
  "@testing-library/react-native-17": "npm:@testing-library/react-native@7.2.0",
28
+ "react-test-renderer": "~18.0.0",
28
29
  "react-test-renderer-17": "npm:react-test-renderer@17.0.2",
29
30
  "webpack": "5.x"
30
31
  },
@@ -41,8 +42,8 @@
41
42
  "module": "lib-module/index.js",
42
43
  "name": "@telus-uds/components-base",
43
44
  "peerDependencies": {
44
- "react": "^17.0.2 || ~18.0.0",
45
- "react-dom": "^17.0.2 || ~18.0.0",
45
+ "react": "^17.0.2 || ^18.0.0",
46
+ "react-dom": "^17.0.2 || ^18.0.0",
46
47
  "react-native": "*",
47
48
  "react-native-web": "~0.17.7 || ~0.18.7"
48
49
  },
@@ -66,5 +67,5 @@
66
67
  "standard-engine": {
67
68
  "skip": true
68
69
  },
69
- "version": "1.15.0"
70
+ "version": "1.17.0"
70
71
  }
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
+ import { PortalProvider } from '@gorhom/portal'
3
4
  import A11yInfoProvider from '../A11yInfoProvider'
4
5
  import ViewportProvider from '../ViewportProvider'
5
6
  import ThemeProvider from '../ThemeProvider'
@@ -8,7 +9,7 @@ const BaseProvider = ({ defaultTheme, children, themeOptions }) => (
8
9
  <A11yInfoProvider>
9
10
  <ViewportProvider>
10
11
  <ThemeProvider defaultTheme={defaultTheme} themeOptions={themeOptions}>
11
- {children}
12
+ <PortalProvider>{children}</PortalProvider>
12
13
  </ThemeProvider>
13
14
  </ViewportProvider>
14
15
  </A11yInfoProvider>
@@ -148,9 +148,9 @@ const selectWebOnlyStyles = (inactive, themeTokens, { accessibilityRole }) => {
148
148
  })
149
149
  }
150
150
 
151
- const selectItemIconTokens = ({ color, iconSize }) => ({
151
+ const selectItemIconTokens = ({ color, iconColor, iconSize }) => ({
152
152
  size: iconSize,
153
- color
153
+ color: iconColor || color
154
154
  })
155
155
 
156
156
  const ButtonBase = forwardRef(
@@ -22,6 +22,8 @@ import SkipLink from '../SkipLink'
22
22
  import A11yText from '../A11yText'
23
23
  import CarouselStepTracker from './CarouselStepTracker'
24
24
  import CarouselThumbnailNavigation from './CarouselThumbnailNavigation'
25
+ import CarouselTabsPanel from './CarouselTabs/CarouselTabsPanel'
26
+ import CarouselTabsPanelItem from './CarouselTabs/CarouselTabsPanelItem'
25
27
  import dictionary from './dictionary'
26
28
 
27
29
  const staticStyles = StyleSheet.create({
@@ -150,7 +152,8 @@ const Carousel = React.forwardRef(
150
152
  onAnimationEnd,
151
153
  onIndexChanged,
152
154
  skipLinkHref,
153
- refocus,
155
+ tabs,
156
+ refocus = Boolean(tabs),
154
157
  title = 'carousel',
155
158
  springConfig = undefined,
156
159
  thumbnails = undefined,
@@ -177,6 +180,7 @@ const Carousel = React.forwardRef(
177
180
  nextIcon,
178
181
  showPreviousNextNavigation,
179
182
  showPanelNavigation,
183
+ showPanelTabs,
180
184
  spaceBetweenSlideAndPreviousNextNavigation
181
185
  } = themeTokens
182
186
  const [activeIndex, setActiveIndex] = React.useState(0)
@@ -415,6 +419,9 @@ const Carousel = React.forwardRef(
415
419
  [activeIndex, childrenArray.length, itemLabel, getCopy, title]
416
420
  )
417
421
 
422
+ const activePanelNavigation =
423
+ tabs && showPanelTabs ? <CarouselTabsPanel items={tabs} /> : panelNavigation
424
+
418
425
  return (
419
426
  <CarouselProvider
420
427
  activeIndex={activeIndex}
@@ -511,7 +518,7 @@ const Carousel = React.forwardRef(
511
518
  </View>
512
519
  )}
513
520
  </View>
514
- {showPanelNavigation ? panelNavigation : null}
521
+ {showPanelNavigation ? activePanelNavigation : null}
515
522
  </CarouselProvider>
516
523
  )
517
524
  }
@@ -587,6 +594,12 @@ Carousel.propTypes = {
587
594
  * with the ID of a focusable element immediately after the Carousel, e.g. `'#section-2-heading'`.
588
595
  */
589
596
  skipLinkHref: PropTypes.string,
597
+ /**
598
+ * If provided, defaults the navigation panel to a CarouselTabsPanel element passing each item as props for one tab.
599
+ *
600
+ * Be careful to ensure that the order of each element in the items array matches the order of each child in the Carousel.
601
+ */
602
+ tabs: PropTypes.arrayOf(PropTypes.shape(CarouselTabsPanelItem.propTypes || {})),
590
603
  /**
591
604
  * If true, whenever a new slide comes into view, the focus of the Carousel switches to the start.
592
605
  *
@@ -3,13 +3,15 @@ import PropTypes from 'prop-types'
3
3
 
4
4
  import { useResponsiveProp } from '../../utils'
5
5
  import Carousel from '../Carousel'
6
- import CarouselTabsPanel from './CarouselTabsPanel'
7
6
 
7
+ /**
8
+ * @deprecated Please use Carousel and pass the `tabs` prop.
9
+ */
8
10
  const CarouselTabs = forwardRef(({ items, refocus = true, ...carouselProps }, ref) => {
9
- const panelNavigation = useResponsiveProp({ md: <CarouselTabsPanel items={items} /> })
11
+ const tabs = useResponsiveProp({ md: items })
10
12
 
11
13
  return (
12
- <Carousel refocus={refocus} {...carouselProps} ref={ref} panelNavigation={panelNavigation}>
14
+ <Carousel refocus={refocus} {...carouselProps} ref={ref} tabs={tabs}>
13
15
  {items.map(({ title, content }) => (
14
16
  <React.Fragment key={title}>{content}</React.Fragment>
15
17
  ))}
package/src/List/List.jsx CHANGED
@@ -1,18 +1,16 @@
1
1
  import React, { cloneElement, forwardRef, Children } from 'react'
2
2
  import { View, Platform } from 'react-native'
3
3
  import PropTypes from 'prop-types'
4
- import {
5
- a11yProps,
6
- componentPropType,
7
- getTokensPropType,
8
- selectSystemProps,
9
- variantProp,
10
- viewProps
11
- } from '../utils'
12
- import ListItem from './ListItem'
4
+ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils'
13
5
 
14
6
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
15
7
 
8
+ const isListItem = (element) => {
9
+ const elementName = element?.type?.displayName || element?.type?.name
10
+ // Match our own ListItem, and also, custom list items
11
+ return Boolean(elementName.match(/Item/))
12
+ }
13
+
16
14
  /**
17
15
  * An unordered List component has a child a ListItem that
18
16
  * allows icon, dividers and customized typography
@@ -31,9 +29,7 @@ const List = forwardRef(
31
29
  ) => {
32
30
  const items = Children.map(children, (child, index) => {
33
31
  // Pass ListItem-specific props to children (by name so teams can add their own ListItems)
34
- const isListItem = (componentName) => Boolean(componentName === ListItem.displayName)
35
-
36
- if (isListItem(child?.type?.displayName) || isListItem(child?.type?.name)) {
32
+ if (isListItem(child)) {
37
33
  return cloneElement(child, {
38
34
  showDivider,
39
35
  isLastItem: index + 1 === Children.count(children),
@@ -58,7 +54,7 @@ List.propTypes = {
58
54
  ...selectedSystemPropTypes,
59
55
  tokens: getTokensPropType('List'),
60
56
  variant: variantProp.propType,
61
- children: componentPropType('ListItem'),
57
+ children: PropTypes.node,
62
58
  /**
63
59
  * In case it is not the last item allow display divider
64
60
  */
@@ -9,12 +9,13 @@ import {
9
9
  clickProps,
10
10
  linkProps,
11
11
  hrefAttrsProp,
12
+ selectTokens,
12
13
  withLinkRouter
13
14
  } from '../utils'
14
15
 
15
16
  import ListItemBase from './ListItemBase'
16
- import ListItemContent, { tokenTypes as contentTokenTypes } from './ListItemContent'
17
- import ListItemMark, { tokenTypes as markTokenTypes } from './ListItemMark'
17
+ import ListItemContent from './ListItemContent'
18
+ import ListItemMark from './ListItemMark'
18
19
 
19
20
  const selectPressableStyles = ({
20
21
  backgroundColor,
@@ -39,8 +40,10 @@ const PressableListItemBase = forwardRef(
39
40
  const { hrefAttrs, rest: listItemProps } = hrefAttrsProp.bundle(props)
40
41
  const handlePress = linkProps.handleHref({ href, onPress })
41
42
 
43
+ const listItemTokens = selectTokens('List', typeof tokens === 'function' ? tokens() : tokens)
44
+
42
45
  return (
43
- <ListItemBase ref={listItemRef} tokens={tokens()} {...listItemProps}>
46
+ <ListItemBase ref={listItemRef} tokens={listItemTokens} {...listItemProps}>
44
47
  {({ isLastItem }) => {
45
48
  const getTokens = (pressableState) =>
46
49
  resolvePressableTokens(tokens, pressableState, { last: isLastItem })
@@ -81,18 +84,13 @@ const staticStyles = StyleSheet.create({
81
84
  itemContainer: {
82
85
  flexDirection: 'row',
83
86
  flex: 1
84
- },
85
- tokens: {
86
- ...contentTokenTypes,
87
- ...markTokenTypes
88
87
  }
89
88
  })
90
89
 
91
90
  PressableListItemBase.propTypes = {
91
+ ...withLinkRouter.propTypes,
92
92
  href: PropTypes.string,
93
93
  onPress: PropTypes.func,
94
- // TODO - type this better, maybe import the subcomponent token types and run it through util
95
- // eslint-disable-next-line react/forbid-prop-types
96
94
  tokens: PropTypes.any,
97
95
  icon: PropTypes.elementType,
98
96
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
@@ -0,0 +1,61 @@
1
+ import React, { forwardRef } from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import { useThemeTokens } from '../ThemeProvider'
5
+ import { useViewport } from '../ViewportProvider'
6
+ import { getTokensPropType, variantProp } from '../utils'
7
+
8
+ import List from '../List'
9
+ import StackWrap from '../StackView/StackWrap'
10
+ import QuickLinksCard from './QuickLinksCard'
11
+
12
+ /**
13
+ * QuickLinks renders a list of interactive items. How it renders these items depends on theme options:
14
+ * - If the theme returns `list` token as true, it renders an ordered list based on List
15
+ * - If the theme returns `button` token as true and `list` as false, it renders a wrapping horizontal bar of buttons
16
+ * - If the theme returns `card` token as true, it wraps the above with a `Card`.
17
+ */
18
+ const QuickLinks = forwardRef(
19
+ ({ tokens, variant, listTokens, cardTokens, children, tag = 'ul', ...rest }, ref) => {
20
+ const viewport = useViewport()
21
+ const { dividers, list, card, stackSpace, stackGap, stackJustify } = useThemeTokens(
22
+ 'QuickLinks',
23
+ tokens,
24
+ variant,
25
+ {
26
+ viewport
27
+ }
28
+ )
29
+
30
+ const content = (list && (
31
+ <List ref={ref} tokens={listTokens} showDivider={dividers} tag={tag} {...rest}>
32
+ {children}
33
+ </List>
34
+ )) || (
35
+ <StackWrap
36
+ space={stackSpace}
37
+ gap={stackGap}
38
+ tokens={{ justifyContent: stackJustify }}
39
+ tag={tag}
40
+ {...rest}
41
+ >
42
+ {children}
43
+ </StackWrap>
44
+ )
45
+
46
+ return card ? <QuickLinksCard tokens={cardTokens}>{content}</QuickLinksCard> : content
47
+ }
48
+ )
49
+
50
+ QuickLinks.displayName = 'QuickLinks'
51
+
52
+ QuickLinks.propTypes = {
53
+ tokens: getTokensPropType('QuickLinks'),
54
+ cardTokens: getTokensPropType('Card'),
55
+ listTokens: getTokensPropType('QuickLinksList'),
56
+ tag: PropTypes.string,
57
+ variant: variantProp.propType,
58
+ children: PropTypes.node
59
+ }
60
+
61
+ export default QuickLinks
@@ -0,0 +1,26 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import { useThemeTokens } from '../ThemeProvider'
5
+ import { getTokensPropType, variantProp } from '../utils'
6
+ import CardBase from '../Card/CardBase'
7
+
8
+ /**
9
+ * Private subcomponent for use within QuickLinks.
10
+ *
11
+ * Restyled Card with identical behaviour to Card, but themed according to the
12
+ * QuickLinksCard theme rather than the Card theme.
13
+ */
14
+ const QuickLinksList = ({ tokens, variant, children }) => {
15
+ const themeTokens = useThemeTokens('QuickLinksCard', tokens, variant)
16
+
17
+ return <CardBase tokens={themeTokens}>{children}</CardBase>
18
+ }
19
+
20
+ QuickLinksList.propTypes = {
21
+ tokens: getTokensPropType('QuickLinksCard'),
22
+ variant: variantProp.propType,
23
+ children: PropTypes.node
24
+ }
25
+
26
+ export default QuickLinksList
@@ -0,0 +1,46 @@
1
+ import React, { forwardRef } from 'react'
2
+ import PropTypes from 'prop-types'
3
+
4
+ import { getTokensPropType, variantProp, withLinkRouter } from '../utils'
5
+ import { useViewport } from '../ViewportProvider'
6
+ import { useThemeTokens, useThemeTokensCallback } from '../ThemeProvider'
7
+
8
+ import PressableListItemBase from '../List/PressableListItemBase'
9
+ import ButtonBase from '../Button/ButtonBase'
10
+
11
+ /**
12
+ * Public component exported as QuickLinks.Item, for use as children of QuickLinks.
13
+ *
14
+ * Receives props injected by QuickLinks and renders the appropriate child component.
15
+ */
16
+ const QuickLinksItem = forwardRef(({ tokens, variant, children, ...rest }, ref) => {
17
+ const viewport = useViewport()
18
+ const { list } = useThemeTokens('QuickLinks', tokens, variant, { viewport })
19
+
20
+ const themeName = list ? 'QuickLinksList' : 'QuickLinksButton'
21
+
22
+ const getTokens = useThemeTokensCallback(themeName, tokens, variant)
23
+
24
+ return list ? (
25
+ <PressableListItemBase ref={ref} tokens={getTokens} {...rest}>
26
+ {children}
27
+ </PressableListItemBase>
28
+ ) : (
29
+ <ButtonBase ref={ref} tokens={getTokens} {...rest}>
30
+ {children}
31
+ </ButtonBase>
32
+ )
33
+ })
34
+
35
+ QuickLinksItem.displayName = 'QuickLinksItem'
36
+
37
+ QuickLinksItem.propTypes = {
38
+ ...withLinkRouter.propTypes,
39
+ ...PressableListItemBase.propTypes,
40
+ ...ButtonBase.propTypes,
41
+ tokens: getTokensPropType('QuickLinksList', 'QuickLinksButton'),
42
+ variant: variantProp.propType,
43
+ children: PropTypes.node
44
+ }
45
+
46
+ export default withLinkRouter(QuickLinksItem)
@@ -0,0 +1,6 @@
1
+ import QuickLinks from './QuickLinks'
2
+ import QuickLinksItem from './QuickLinksItem'
3
+
4
+ QuickLinks.Item = QuickLinksItem
5
+
6
+ export default QuickLinks
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef } from 'react'
2
- import { Animated, Platform } from 'react-native'
2
+ import { Animated, Platform, StyleSheet, View } from 'react-native'
3
3
  import propTypes from 'prop-types'
4
4
  import StackView from '../StackView'
5
5
  import { useThemeTokens } from '../ThemeProvider'
@@ -19,11 +19,10 @@ import skeletonWebAnimation from './skeletonWebAnimation'
19
19
 
20
20
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
21
21
 
22
- const selectSkeletonStyles = ({ color, radius, fadeAnimation }) => ({
22
+ const selectSkeletonStyles = ({ color, radius }) => ({
23
23
  backgroundColor: color,
24
24
  borderRadius: radius,
25
- maxWidth: '100%',
26
- ...fadeAnimation
25
+ maxWidth: '100%'
27
26
  })
28
27
 
29
28
  const selectLineStyles = ({ skeletonHeight, lineWidth }) => ({
@@ -66,12 +65,13 @@ const Skeleton = forwardRef(
66
65
  const skeletonHeight = useSpacingScale(spacingScaleValue)
67
66
  const nativeAnimation = useSkeletonNativeAnimation()
68
67
 
69
- const getAnimationBaseOnPlatform = () => {
70
- if (Platform.OS !== 'web') {
71
- return nativeAnimation
72
- }
68
+ const getAnimationBasedOnPlatform = () => {
69
+ const animation = Platform.OS === 'web' ? skeletonWebAnimation : nativeAnimation
70
+ // We must pass the animation styles through `StyleSheet.create`
71
+ // @see https://github.com/necolas/react-native-web/issues/2387
72
+ const styles = StyleSheet.create({ animation })
73
73
 
74
- return skeletonWebAnimation
74
+ return styles.animation
75
75
  }
76
76
 
77
77
  const getLineWidth = () => {
@@ -97,16 +97,22 @@ const Skeleton = forwardRef(
97
97
  return selectLineStyles({ skeletonHeight, lineWidth: getLineWidth() })
98
98
  }
99
99
 
100
- const renderSkeleton = (index = 0) => (
101
- <Animated.View
102
- testID="skeleton"
103
- key={`skeleton-${index + 1}`}
104
- style={[
105
- selectSkeletonStyles({ ...themeTokens, fadeAnimation: getAnimationBaseOnPlatform() }),
106
- getStyledBasedOnShape()
107
- ]}
108
- />
109
- )
100
+ const renderSkeleton = (index = 0) => {
101
+ // @see https://github.com/necolas/react-native-web/issues/2387
102
+ const Component = Platform.OS === 'web' ? View : Animated.View
103
+
104
+ return (
105
+ <Component
106
+ testID="skeleton"
107
+ key={`skeleton-${index + 1}`}
108
+ style={[
109
+ selectSkeletonStyles(themeTokens),
110
+ getAnimationBasedOnPlatform(),
111
+ getStyledBasedOnShape()
112
+ ]}
113
+ />
114
+ )
115
+ }
110
116
 
111
117
  return (
112
118
  <StackView space={themeTokens.spaceBetweenLines} ref={ref} {...selectProps(rest)}>
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef } from 'react'
2
- import { Animated } from 'react-native'
2
+ import { Animated, Platform } from 'react-native'
3
3
  import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
4
4
 
5
5
  const useSkeletonNativeAnimation = () => {
@@ -10,12 +10,12 @@ const useSkeletonNativeAnimation = () => {
10
10
  Animated.timing(fadeAnimation, {
11
11
  toValue: OPACITY_STOP,
12
12
  duration: ANIMATION_DURATION,
13
- useNativeDriver: true
13
+ useNativeDriver: Platform.OS !== 'web'
14
14
  }),
15
15
  Animated.timing(fadeAnimation, {
16
16
  toValue: DEFAULT_OPACITY,
17
17
  duration: ANIMATION_DURATION,
18
- useNativeDriver: true
18
+ useNativeDriver: Platform.OS !== 'web'
19
19
  })
20
20
  ])
21
21
  Animated.loop(fade).start()