@planningcenter/tapestry-react 2.1.2 → 2.2.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 (85) hide show
  1. package/dist/cjs/Badge/Badge.js +5 -1
  2. package/dist/cjs/Card/Card.js +5 -2
  3. package/dist/cjs/Combobox/Combobox.js +16 -43
  4. package/dist/cjs/Combobox/ComboboxInput.js +112 -146
  5. package/dist/cjs/Combobox/ComboboxItem.js +38 -53
  6. package/dist/cjs/Combobox/ComboboxItems.js +41 -58
  7. package/dist/cjs/Combobox/index.js +12 -0
  8. package/dist/cjs/DateField/DateField.js +109 -128
  9. package/dist/cjs/Field/Field.js +80 -106
  10. package/dist/cjs/Menu/Item.js +1 -0
  11. package/dist/cjs/Popover/utils.js +1 -0
  12. package/dist/cjs/SegmentedControl/SegmentedControl.js +89 -111
  13. package/dist/cjs/SegmentedTabs/SegmentedTabs.js +54 -84
  14. package/dist/cjs/Tabs/Tab.js +9 -6
  15. package/dist/cjs/Tabs/TabList.js +49 -64
  16. package/dist/cjs/Tabs/TabPanel.js +6 -2
  17. package/dist/cjs/Tabs/TabPanels.js +14 -27
  18. package/dist/cjs/Tabs/Tabs.js +72 -106
  19. package/dist/cjs/Tabs/index.js +12 -0
  20. package/dist/cjs/ThemeProvider/ThemeProvider.js +1 -1
  21. package/dist/cjs/Tooltip/Tooltip.js +158 -182
  22. package/dist/cjs/Wizard/Wizard.js +143 -193
  23. package/dist/cjs/Wizard/index.js +3 -0
  24. package/dist/esm/Badge/Badge.js +5 -1
  25. package/dist/esm/Card/Card.js +5 -2
  26. package/dist/esm/Combobox/Combobox.js +18 -43
  27. package/dist/esm/Combobox/ComboboxInput.js +111 -149
  28. package/dist/esm/Combobox/ComboboxItem.js +38 -52
  29. package/dist/esm/Combobox/ComboboxItems.js +38 -56
  30. package/dist/esm/Combobox/index.js +8 -0
  31. package/dist/esm/DateField/DateField.js +106 -133
  32. package/dist/esm/Field/Field.js +76 -103
  33. package/dist/esm/Menu/Item.js +1 -0
  34. package/dist/esm/Popover/utils.js +1 -0
  35. package/dist/esm/SegmentedControl/SegmentedControl.js +90 -114
  36. package/dist/esm/SegmentedTabs/SegmentedTabs.js +51 -83
  37. package/dist/esm/Tabs/Tab.js +8 -6
  38. package/dist/esm/Tabs/TabList.js +49 -66
  39. package/dist/esm/Tabs/TabPanel.js +4 -2
  40. package/dist/esm/Tabs/TabPanels.js +14 -28
  41. package/dist/esm/Tabs/Tabs.js +76 -120
  42. package/dist/esm/Tabs/index.js +8 -0
  43. package/dist/esm/ThemeProvider/ThemeProvider.js +1 -1
  44. package/dist/esm/Tooltip/Tooltip.js +154 -195
  45. package/dist/esm/Wizard/Wizard.js +144 -201
  46. package/dist/esm/Wizard/index.js +2 -0
  47. package/dist/types/Popover/utils.d.ts +3 -0
  48. package/package.json +1 -1
  49. package/src/.DS_Store +0 -0
  50. package/src/Badge/Badge.js +5 -0
  51. package/src/Card/Card.tsx +22 -1
  52. package/src/Combobox/Combobox.js +18 -32
  53. package/src/Combobox/Combobox.mdx +1 -0
  54. package/src/Combobox/Combobox.test.js +1 -1
  55. package/src/Combobox/ComboboxInput.js +111 -105
  56. package/src/Combobox/ComboboxItem.js +27 -27
  57. package/src/Combobox/ComboboxItems.js +38 -60
  58. package/src/Combobox/index.js +8 -0
  59. package/src/DateField/DateField.js +109 -105
  60. package/src/DateField/DateField.mdx +1 -0
  61. package/src/Field/Field.js +85 -93
  62. package/src/Field/Field.mdx +1 -0
  63. package/src/Menu/Heading.js +5 -1
  64. package/src/Menu/Heading.mdx +20 -0
  65. package/src/Menu/Item.js +13 -1
  66. package/src/Menu/Item.mdx +18 -0
  67. package/src/Menu/Menu.mdx +1 -0
  68. package/src/Popover/utils.ts +1 -0
  69. package/src/SegmentedControl/SegmentedControl.js +88 -92
  70. package/src/SegmentedControl/SegmentedControl.mdx +1 -0
  71. package/src/SegmentedTabs/SegmentedTabs.js +51 -71
  72. package/src/SegmentedTabs/SegmentedTabs.mdx +1 -0
  73. package/src/Tabs/Tab.js +3 -1
  74. package/src/Tabs/TabList.js +56 -62
  75. package/src/Tabs/TabPanel.js +2 -1
  76. package/src/Tabs/TabPanels.js +14 -15
  77. package/src/Tabs/Tabs.js +63 -84
  78. package/src/Tabs/Tabs.mdx +16 -17
  79. package/src/Tabs/index.js +8 -0
  80. package/src/ThemeProvider/ThemeProvider.tsx +1 -1
  81. package/src/Tooltip/Tooltip.js +142 -160
  82. package/src/Tooltip/Tooltip.mdx +1 -0
  83. package/src/Wizard/Wizard.js +141 -170
  84. package/src/Wizard/Wizard.mdx +3 -2
  85. package/src/Wizard/index.js +2 -0
@@ -1,8 +1,9 @@
1
1
  // @flow
2
- import React, { Component } from 'react'
2
+ import React, { useCallback, useState, useEffect } from 'react'
3
3
 
4
4
  import Text from '../Text'
5
5
  import StackView from '../StackView'
6
+ import { useThemeProps } from '../system'
6
7
 
7
8
  function Tab({ isSelected, selectedColor, onSelect, ...restProps }) {
8
9
  return (
@@ -37,33 +38,17 @@ type Props = {
37
38
  tabProps: object,
38
39
  }
39
40
 
40
- class SegmentedTabs extends Component<Props> {
41
- static defaultProps = {
42
- color: 'primary',
43
- getTabLabel: (tab) => tab,
44
- }
45
-
46
- constructor(props: Props) {
47
- super(props)
48
- this.state = {
49
- activeIndex: this.getActiveIndex(props),
50
- }
51
- }
52
-
53
- componentDidUpdate(lastProps) {
54
- if (this.props.activeTab) {
55
- const lastActiveIndex = this.getActiveIndex(lastProps)
56
- const nextActiveIndex = this.getActiveIndex(this.props)
57
- if (
58
- lastActiveIndex !== nextActiveIndex ||
59
- this.state.activeIndex !== nextActiveIndex
60
- ) {
61
- this.setState({ activeIndex: nextActiveIndex })
62
- }
63
- }
64
- }
65
-
66
- getActiveIndex({ activeTab, tabs }) {
41
+ function SegmentedTabs(props: Props) {
42
+ const {
43
+ activeTab,
44
+ color = 'primary',
45
+ getTabLabel = (tab) => tab,
46
+ onChange,
47
+ tabs,
48
+ tabProps,
49
+ ...restProps
50
+ } = useThemeProps('segmentedTabs', props)
51
+ const getActiveIndex = useCallback(({ activeTab, tabs }) => {
67
52
  let index
68
53
  if (typeof activeTab === 'function') {
69
54
  index = tabs.reduce((searchIndex, tab, index) => {
@@ -76,53 +61,48 @@ class SegmentedTabs extends Component<Props> {
76
61
  index = activeTab === undefined ? 0 : tabs.indexOf(activeTab)
77
62
  }
78
63
  return index
79
- }
64
+ })
65
+ const [activeIndex, setActiveIndex] = useState(getActiveIndex(props))
80
66
 
81
- setIndex = (index) => {
82
- if (this.props.activeTab === undefined) {
83
- this.setState({
84
- activeIndex: index,
85
- })
67
+ const setIndex = useCallback((index) => {
68
+ if (activeTab === undefined) {
69
+ setActiveIndex(index)
70
+ }
71
+ if (onChange) {
72
+ onChange(tabs[index])
86
73
  }
87
- if (this.props.onChange) {
88
- this.props.onChange(this.props.tabs[index])
74
+ })
75
+
76
+ useEffect(() => {
77
+ const newActiveIndex = getActiveIndex(props)
78
+
79
+ if (activeIndex !== newActiveIndex) {
80
+ setActiveIndex(newActiveIndex)
89
81
  }
90
- }
82
+ }, [activeTab])
91
83
 
92
- render() {
93
- const {
94
- activeTab,
95
- color,
96
- getTabLabel,
97
- onChange,
98
- tabs,
99
- tabProps,
100
- ...restProps
101
- } = this.props
102
- const { activeIndex } = this.state
103
- return (
104
- <StackView
105
- role="group"
106
- axis="horizontal"
107
- distribution="fill"
108
- position="relative"
109
- {...restProps}
110
- >
111
- {tabs.map((tab, index) => (
112
- <Tab
113
- key={index}
114
- index={index}
115
- isSelected={index === activeIndex}
116
- selectedColor={color}
117
- onSelect={() => this.setIndex(index)}
118
- {...tabProps}
119
- >
120
- {getTabLabel(tab)}
121
- </Tab>
122
- ))}
123
- </StackView>
124
- )
125
- }
84
+ return (
85
+ <StackView
86
+ role="group"
87
+ axis="horizontal"
88
+ distribution="fill"
89
+ position="relative"
90
+ {...restProps}
91
+ >
92
+ {tabs.map((tab, index) => (
93
+ <Tab
94
+ key={index}
95
+ index={index}
96
+ isSelected={index === activeIndex}
97
+ selectedColor={color}
98
+ onSelect={() => setIndex(index)}
99
+ {...tabProps}
100
+ >
101
+ {getTabLabel(tab)}
102
+ </Tab>
103
+ ))}
104
+ </StackView>
105
+ )
126
106
  }
127
107
 
128
108
  export default SegmentedTabs
@@ -2,6 +2,7 @@
2
2
  title: SegmentedTabs
3
3
  category: General
4
4
  propsSummary: Accepts [StackView](/stackview) props.
5
+ themeKey: segmentedTabs
5
6
  ---
6
7
 
7
8
  ```jsx live
package/src/Tabs/Tab.js CHANGED
@@ -3,11 +3,13 @@ import React from 'react'
3
3
 
4
4
  import StackView from '../StackView'
5
5
  import { useHover } from '../hooks'
6
+ import { useThemeProps } from '../system'
6
7
 
7
8
  export type Props = { isActive?: boolean }
8
9
 
9
10
  function Tab(props: Props) {
10
- const { axis, children, disabled, id, isActive, ...restProps } = props
11
+ const { axis, children, disabled, id, isActive, ...restProps } =
12
+ useThemeProps('tabs.tab', props)
11
13
  const { hover, hoverProps } = useHover()
12
14
  const hovered = !disabled && hover
13
15
  const borderSize = 2
@@ -1,73 +1,67 @@
1
1
  // @flow
2
- import React, { Component, Children, cloneElement } from 'react'
2
+ import React, { Children, cloneElement } from 'react'
3
3
 
4
4
  import StackView from '../StackView'
5
+ import { useThemeProps } from '../system'
5
6
 
6
7
  export const TABLIST_DISPLAY_NAME = 'TabList'
7
8
 
8
9
  type Props = { activeIndex?: number }
9
10
 
10
- class TabList extends Component<Props> {
11
- static displayName = TABLIST_DISPLAY_NAME
12
-
13
- static defaultProps = {
14
- axis: 'horizontal',
15
- }
16
-
17
- render() {
18
- const {
19
- activeIndex,
20
- axis,
21
- children,
22
- id,
23
- moveTabFocus,
24
- setActiveIndex,
25
- ...restProps
26
- } = this.props
27
- const backwardKey = axis === 'horizontal' ? 'ArrowLeft' : 'ArrowUp'
28
- const forwardKey = axis === 'horizontal' ? 'ArrowRight' : 'ArrowDown'
29
- return (
30
- <StackView
31
- role="tablist"
32
- aria-orientation={axis}
33
- axis={axis}
34
- distribution="fill"
35
- {...restProps}
36
- >
37
- {Children.map(children, (child, index) =>
38
- cloneElement(child, {
39
- axis,
40
- id: `${id}-${index}`,
41
- isActive: index === activeIndex,
42
- tabIndex: child.props.disabled
43
- ? undefined
44
- : index !== activeIndex
45
- ? -1
46
- : 0,
47
- onFocus: () => setActiveIndex(index),
48
- onKeyDown: (event) => {
49
- if (event.key === backwardKey) {
50
- event.preventDefault()
51
- moveTabFocus(-1)
52
- }
53
- if (event.key === forwardKey) {
54
- event.preventDefault()
55
- moveTabFocus(1)
56
- }
57
- if (event.key === 'Home') {
58
- event.preventDefault()
59
- moveTabFocus(0)
60
- }
61
- if (event.key === 'End') {
62
- event.preventDefault()
63
- moveTabFocus(Children.count(children) - 1)
64
- }
65
- },
66
- })
67
- )}
68
- </StackView>
69
- )
70
- }
11
+ function TabList(props: Props) {
12
+ const {
13
+ activeIndex,
14
+ axis = 'horizontal',
15
+ children,
16
+ id,
17
+ moveTabFocus,
18
+ setActiveIndex,
19
+ ...restProps
20
+ } = useThemeProps('tabs.tabList', props)
21
+ const backwardKey = axis === 'horizontal' ? 'ArrowLeft' : 'ArrowUp'
22
+ const forwardKey = axis === 'horizontal' ? 'ArrowRight' : 'ArrowDown'
23
+ return (
24
+ <StackView
25
+ role="tablist"
26
+ aria-orientation={axis}
27
+ axis={axis}
28
+ distribution="fill"
29
+ {...restProps}
30
+ >
31
+ {Children.map(children, (child, index) =>
32
+ cloneElement(child, {
33
+ axis,
34
+ id: `${id}-${index}`,
35
+ isActive: index === activeIndex,
36
+ tabIndex: child.props.disabled
37
+ ? undefined
38
+ : index !== activeIndex
39
+ ? -1
40
+ : 0,
41
+ onFocus: () => setActiveIndex(index),
42
+ onKeyDown: (event) => {
43
+ if (event.key === backwardKey) {
44
+ event.preventDefault()
45
+ moveTabFocus(-1)
46
+ }
47
+ if (event.key === forwardKey) {
48
+ event.preventDefault()
49
+ moveTabFocus(1)
50
+ }
51
+ if (event.key === 'Home') {
52
+ event.preventDefault()
53
+ moveTabFocus(0)
54
+ }
55
+ if (event.key === 'End') {
56
+ event.preventDefault()
57
+ moveTabFocus(Children.count(children) - 1)
58
+ }
59
+ },
60
+ })
61
+ )}
62
+ </StackView>
63
+ )
71
64
  }
72
65
 
66
+ TabList.displayName = TABLIST_DISPLAY_NAME
73
67
  export default TabList
@@ -2,11 +2,12 @@
2
2
  import React from 'react'
3
3
 
4
4
  import Box from '../Box'
5
+ import { useThemeProps } from '../system'
5
6
 
6
7
  export type Props = { activeId?: any }
7
8
 
8
9
  function TabPanel(props: Props) {
9
- const { activeId, ...restProps } = props
10
+ const { activeId, ...restProps } = useThemeProps('tabs.tabPanel', props)
10
11
  return (
11
12
  <Box
12
13
  role="tabpanel"
@@ -1,26 +1,25 @@
1
1
  // @flow
2
- import React, { Component, cloneElement } from 'react'
2
+ import React, { cloneElement } from 'react'
3
3
 
4
4
  import Box from '../Box'
5
+ import { useThemeProps } from '../system'
5
6
 
6
7
  export const TABPANELS_DISPLAY_NAME = 'TabPanels'
7
8
 
8
9
  type Props = { activeIndex?: number }
9
10
 
10
- class TabPanels extends Component<Props> {
11
- static displayName = TABPANELS_DISPLAY_NAME
12
-
13
- render() {
14
- const { activeIndex, children, id, ...restProps } = this.props
15
- const child = children[activeIndex]
16
- return (
17
- <Box {...restProps}>
18
- {child
19
- ? cloneElement(child, { activeId: `${id}-${activeIndex}` })
20
- : null}
21
- </Box>
22
- )
23
- }
11
+ function TabPanels(props: Props) {
12
+ const { activeIndex, children, id, ...restProps } = useThemeProps(
13
+ 'tabs.tabPanels',
14
+ props
15
+ )
16
+ const child = children[activeIndex]
17
+ return (
18
+ <Box {...restProps}>
19
+ {child ? cloneElement(child, { activeId: `${id}-${activeIndex}` }) : null}
20
+ </Box>
21
+ )
24
22
  }
25
23
 
24
+ TabPanels.displayName = TABPANELS_DISPLAY_NAME
26
25
  export default TabPanels
package/src/Tabs/Tabs.js CHANGED
@@ -1,13 +1,12 @@
1
1
  // @flow
2
- import React, { Component, Children } from 'react'
2
+ import React, { useState, useRef, useCallback, Children } from 'react'
3
3
 
4
4
  import StackView from '../StackView'
5
5
  import { generateId } from '../utils'
6
+ import { useThemeProps } from '../system'
6
7
 
7
- import Tab from './Tab'
8
- import TabList, { TABLIST_DISPLAY_NAME } from './TabList'
9
- import TabPanel from './TabPanel'
10
- import TabPanels, { TABPANELS_DISPLAY_NAME } from './TabPanels'
8
+ import { TABLIST_DISPLAY_NAME } from './TabList'
9
+ import { TABPANELS_DISPLAY_NAME } from './TabPanels'
11
10
 
12
11
  type Props = {
13
12
  /**
@@ -31,103 +30,83 @@ type Props = {
31
30
  onChange?: Function,
32
31
  }
33
32
 
34
- class Tabs extends Component<Props> {
35
- static Tab = Tab
36
-
37
- static TabList = TabList
38
-
39
- static TabPanel = TabPanel
40
-
41
- static TabPanels = TabPanels
42
-
43
- static defaultProps = {
44
- activeIndex: null,
45
- defaultActiveIndex: 0,
46
- }
47
-
48
- id = generateId('tabs')
49
-
50
- state = {
51
- activeIndex: this.props.defaultActiveIndex,
52
- }
53
-
54
- setTabList = (node) => {
55
- if (node) {
56
- this.tabList = node.querySelector('[role="tablist"]')
33
+ function Tabs(props: Props) {
34
+ const {
35
+ activeIndex = null,
36
+ children,
37
+ defaultActiveIndex = 0,
38
+ onChange,
39
+ ...restProps
40
+ } = useThemeProps('tabs', props)
41
+
42
+ const id = generateId('tabs')
43
+ const [localActiveIndex, setLocalActiveIndex] = useState(defaultActiveIndex)
44
+ const tabListRef = useRef(null)
45
+
46
+ const setActiveIndex = useCallback((index) => {
47
+ if (onChange) {
48
+ onChange(index)
57
49
  }
58
- }
59
-
60
- setActiveIndex = (activeIndex) => {
61
- if (this.props.onChange) {
62
- this.props.onChange(activeIndex)
50
+ if (activeIndex === null) {
51
+ setLocalActiveIndex(index)
63
52
  }
64
- if (this.props.activeIndex === null) {
65
- this.setState({ activeIndex })
66
- }
67
- }
53
+ })
68
54
 
69
- getActiveIndex = () => {
70
- return this.props.activeIndex === null
71
- ? this.state.activeIndex
72
- : this.props.activeIndex
73
- }
55
+ const getActiveIndex = useCallback(() => {
56
+ return activeIndex === null ? localActiveIndex : activeIndex
57
+ })
74
58
 
75
- getNextTab = (startIndex, direction) => {
76
- const tabCount = this.tabList.children.length
59
+ const getNextTab = useCallback((startIndex, direction) => {
60
+ const tabCount = tabListRef.current.children.length
77
61
  let nextIndex = startIndex + direction
78
62
  if (nextIndex < 0) {
79
63
  nextIndex = tabCount - 1
80
64
  } else if (nextIndex >= tabCount) {
81
65
  nextIndex = 0
82
66
  }
83
- const nextTab = this.tabList.children[nextIndex]
67
+ const nextTab = tabListRef.current.children[nextIndex]
84
68
  if (nextTab.getAttribute('aria-disabled') === 'true') {
85
- return this.getNextTab(nextIndex, direction)
69
+ return getNextTab(nextIndex, direction)
86
70
  } else {
87
71
  return nextTab
88
72
  }
89
- }
73
+ })
90
74
 
91
- moveTabFocus = (direction) => {
92
- const nextTab = this.getNextTab(this.getActiveIndex(), direction)
75
+ const moveTabFocus = useCallback((direction) => {
76
+ const nextTab = getNextTab(getActiveIndex(), direction)
93
77
  if (nextTab) {
94
78
  nextTab.focus()
95
79
  }
96
- }
97
-
98
- render() {
99
- const {
100
- activeIndex,
101
- children,
102
- defaultActiveIndex,
103
- onChange,
104
- ...restProps
105
- } = this.props
106
- return (
107
- <StackView innerRef={this.setTabList} {...restProps}>
108
- {Children.map(children, (child, index) => {
109
- if (child && child.type.displayName === TABLIST_DISPLAY_NAME) {
110
- return React.cloneElement(child, {
111
- id: this.id,
112
- activeIndex: this.getActiveIndex(),
113
- moveTabFocus: this.moveTabFocus,
114
- setActiveIndex: this.setActiveIndex,
115
- })
116
- } else if (
117
- child &&
118
- child.type.displayName === TABPANELS_DISPLAY_NAME
119
- ) {
120
- return React.cloneElement(child, {
121
- id: this.id,
122
- activeIndex: this.getActiveIndex(),
123
- })
124
- } else {
125
- return child
126
- }
127
- })}
128
- </StackView>
129
- )
130
- }
80
+ })
81
+
82
+ return (
83
+ <StackView
84
+ innerRef={(node) => {
85
+ if (node) {
86
+ tabListRef.current = node.querySelector('[role="tablist"]')
87
+ }
88
+ }}
89
+ {...restProps}
90
+ >
91
+ {Children.map(children, (child, index) => {
92
+ if (child && child.type.displayName === TABLIST_DISPLAY_NAME) {
93
+ return React.cloneElement(child, {
94
+ id,
95
+ activeIndex: getActiveIndex(),
96
+ moveTabFocus,
97
+ setActiveIndex,
98
+ })
99
+ } else if (child && child.type.displayName === TABPANELS_DISPLAY_NAME) {
100
+ return React.cloneElement(child, {
101
+ id,
102
+ activeIndex: getActiveIndex(),
103
+ })
104
+ } else {
105
+ return child
106
+ }
107
+ })}
108
+ </StackView>
109
+ )
131
110
  }
132
111
 
133
112
  export default Tabs
package/src/Tabs/Tabs.mdx CHANGED
@@ -3,48 +3,47 @@ title: Tabs
3
3
  category: General
4
4
  summary: A single content area with multiple panels, each associated with a header in a list.
5
5
  propsSummary: Accepts [StackView](/stackview) props.
6
+ themeKey: tabs
6
7
  ---
7
8
 
8
9
  ```jsx live
9
- const { Tab, TabList, TabPanel, TabPanels } = Tabs
10
10
  const tabs = [1, 2, 3, 4]
11
11
  render(
12
12
  <Tabs>
13
- <TabList minWidth={60}>
13
+ <Tabs.TabList minWidth={60}>
14
14
  {tabs.map((tab, index) => (
15
- <Tab key={tab} disabled={index === 2}>
15
+ <Tabs.Tab key={tab} disabled={index === 2}>
16
16
  Tab {tab}
17
- </Tab>
17
+ </Tabs.Tab>
18
18
  ))}
19
- </TabList>
20
- <TabPanels>
19
+ </Tabs.TabList>
20
+ <Tabs.TabPanels>
21
21
  {tabs.map((tab) => (
22
- <TabPanel key={tab} padding={2}>
22
+ <Tabs.TabPanel key={tab} padding={2}>
23
23
  Content for tab {tab}
24
- </TabPanel>
24
+ </Tabs.TabPanel>
25
25
  ))}
26
- </TabPanels>
26
+ </Tabs.TabPanels>
27
27
  </Tabs>
28
28
  )
29
29
  ```
30
30
 
31
31
  ```jsx live
32
- const { Tab, TabList, TabPanel, TabPanels } = Tabs
33
32
  const tabs = [1, 2, 3, 4]
34
33
  render(
35
34
  <Card as={Tabs} axis="horizontal">
36
- <TabList axis="vertical" distribution="start" minWidth={20}>
35
+ <Tabs.TabList axis="vertical" distribution="start" minWidth={20}>
37
36
  {tabs.map((tab) => (
38
- <Tab key={tab}>Tab {tab}</Tab>
37
+ <Tabs.Tab key={tab}>Tab {tab}</Tabs.Tab>
39
38
  ))}
40
- </TabList>
41
- <TabPanels>
39
+ </Tabs.TabList>
40
+ <Tabs.TabPanels>
42
41
  {tabs.map((tab) => (
43
- <TabPanel key={tab} padding={2}>
42
+ <Tabs.TabPanel key={tab} padding={2}>
44
43
  Content for tab {tab}
45
- </TabPanel>
44
+ </Tabs.TabPanel>
46
45
  ))}
47
- </TabPanels>
46
+ </Tabs.TabPanels>
48
47
  </Card>
49
48
  )
50
49
  ```
package/src/Tabs/index.js CHANGED
@@ -1,2 +1,10 @@
1
1
  import Tabs from './Tabs'
2
+ import Tab from './Tab'
3
+ import TabList from './TabList'
4
+ import TabPanel from './TabPanel'
5
+ import TabPanels from './TabPanels'
6
+ Tabs.Tab = Tab
7
+ Tabs.TabList = TabList
8
+ Tabs.TabPanel = TabPanel
9
+ Tabs.TabPanels = TabPanels
2
10
  export default Tabs
@@ -25,7 +25,7 @@ export const themeInitializerScript = `
25
25
  try {
26
26
  var theme = window.localStorage.getItem('${STORAGE_KEY}')
27
27
  if (theme) {
28
- document.body.dataset.theme = theme
28
+ document.documentElement.dataset.theme = theme
29
29
  }
30
30
  } catch (e) {}
31
31
  `