-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2ca768
commit adfbc2f
Showing
14 changed files
with
260 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Meta, Canvas, ArgTypes } from '@storybook/blocks'; | ||
import TabPanel from './TabPanel'; | ||
|
||
<Meta title="Updated Components/Tabs/Components/TabPanel" /> | ||
|
||
<SectionHeader | ||
title={'TabPanel'} | ||
sections={[ | ||
{ title: 'Overview', href: '#overview' }, | ||
{ title: 'Props', href: '#props' }, | ||
{ title: 'Usage', href: '#usage' }, | ||
]} | ||
/> | ||
|
||
## Overview | ||
|
||
TabPanel component is used to conditionally render the content that corresponds to the selected tab. | ||
|
||
## Props | ||
|
||
<ArgTypes of={TabPanel} /> | ||
|
||
## Usage | ||
|
||
Use TabPanels as children of (monolith) Tabs or under Tab components in a composition to toggle content when selecting tabs. | ||
|
||
<Tip>The tabId should be the same as in the Tab component that the TabPanel corresponds to</Tip> | ||
|
||
```js | ||
const [selectedKey, setSelectedKey] = React.useState<TabKey>('tab_1'); | ||
|
||
return ( | ||
// <TabsContainer | ||
// orientation="horizontal" | ||
// selectedKey={selectedKey} | ||
// onSelectionChange={setSelectedKey} | ||
// > | ||
// <TabList aria-label="My Tabs" sx={styleOverrides}> | ||
// <Tab key="tab_1" tabId="tab_1"> | ||
// Tab 1 | ||
// </Tab> | ||
// <Tab key="tab_2" tabId="tab_2"> | ||
// Tab 2 | ||
// </Tab> | ||
// <Tab key="tab_3" tabId="tab_3"> | ||
// Tab 3 | ||
// </Tab> | ||
<TabPanel tabId="tab_1">This is Tab 1 content</TabPanel> | ||
<TabPanel tabId="tab_2">This is Tab 2 content</TabPanel> | ||
<TabPanel tabId="tab_3">This is Tab 3 content</TabPanel> | ||
// </TabList> | ||
// </TabsContainer> | ||
|
||
``` |
13 changes: 13 additions & 0 deletions
13
src/components/Tabs/components/TabPanel/TabPanel.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import TabPanel from '.'; | ||
|
||
export default { | ||
title: 'Updated Components/Tabs/Components/TabPanel', | ||
component: TabPanel, | ||
|
||
parameters: { | ||
storyshots: { | ||
disable: true, | ||
}, | ||
controls: { disable: true }, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { TabPanel as ReactAriaTabPanel } from 'react-aria-components'; | ||
|
||
import type { TabPanelProps } from '../../types'; | ||
|
||
const TabPanel = React.forwardRef<HTMLDivElement, TabPanelProps>((props, ref) => { | ||
const { children, tabId, ...rest } = props; | ||
|
||
return ( | ||
<ReactAriaTabPanel id={tabId} {...rest} ref={ref}> | ||
{children} | ||
</ReactAriaTabPanel> | ||
); | ||
}); | ||
|
||
TabPanel.displayName = 'TabPanel'; | ||
|
||
export default TabPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './TabPanel'; |
9 changes: 9 additions & 0 deletions
9
src/components/Tabs/components/TabsContainer/TabsContainer.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { css } from '@emotion/react'; | ||
|
||
import type { TabOrientation } from '../../types'; | ||
|
||
export const tabsContainerStyles = (orientation: TabOrientation) => css` | ||
width: fit-content; | ||
display: flex; | ||
flex-direction: ${orientation === 'horizontal' ? 'column' : 'row'}; | ||
`; |
5 changes: 3 additions & 2 deletions
5
src/components/Tabs/components/TabsContainer/TabsContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as Tab } from './Tab'; | ||
export { default as TabList } from './TabList'; | ||
export { default as TabsContainer } from './TabsContainer'; | ||
export { default as TabPanel } from './TabPanel'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.