This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(taboule): display many Taboule instances in tabs
- Loading branch information
1 parent
e99f6b8
commit da27e81
Showing
43 changed files
with
1,109 additions
and
702 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file removed
BIN
-171 KB
.yarn/cache/@material-ui-utils-npm-5.0.0-beta.5-3a2f71beeb-397d318861.zip
Binary file not shown.
Binary file removed
BIN
-15.7 KB
.yarn/cache/@material-ui-x-license-npm-4.0.0-alpha.37-0a3717b097-71861879e4.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+9.46 KB
.yarn/cache/regenerator-runtime-npm-0.13.11-90bf536060-27481628d2.zip
Binary file not shown.
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,36 @@ | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import * as React from 'react'; | ||
|
||
interface TabPanelProps { | ||
children?: React.ReactNode; | ||
index: number; | ||
value: number; | ||
} | ||
|
||
export const TabPanel: React.FC<TabPanelProps> = (props) => { | ||
const { children, value, index, ...other } = props; | ||
|
||
return ( | ||
<div | ||
role="tabpanel" | ||
hidden={value !== index} | ||
id={`simple-tabpanel-${index}`} | ||
aria-labelledby={`simple-tab-${index}`} | ||
{...other} | ||
> | ||
{value === index && ( | ||
<Box sx={{ p: 3 }}> | ||
<Typography>{children}</Typography> | ||
</Box> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export function a11yProps(index: number): any { | ||
return { | ||
id: `simple-tab-${index}`, | ||
'aria-controls': `simple-tabpanel-${index}`, | ||
}; | ||
} |
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,55 @@ | ||
import Box from '@mui/material/Box'; | ||
import Tab from '@mui/material/Tab'; | ||
import Tabs from '@mui/material/Tabs'; | ||
import * as React from 'react'; | ||
import { TabouleQueries } from '../state/queries'; | ||
import { Taboule, TabouleProps } from './Taboule'; | ||
import { a11yProps, TabPanel } from './TabPanel'; | ||
|
||
interface TabbedTabouleProps<Q extends keyof TabouleQueries> | ||
extends Omit<TabouleProps<Q>, 'query'> { | ||
queries: Array<{ | ||
label: string; | ||
value: Q; | ||
}>; | ||
} | ||
|
||
export const TabbedTaboule: React.FC< | ||
TabbedTabouleProps<keyof TabouleQueries> | ||
> = ({ queries: tabs, ...props }) => { | ||
const [value, setValue] = React.useState(0); | ||
|
||
const handleChange = ( | ||
event: React.SyntheticEvent, | ||
newValue: number | ||
): void => { | ||
setValue(newValue); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ width: '100%' }}> | ||
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}> | ||
<Tabs | ||
value={value} | ||
onChange={handleChange} | ||
aria-label="basic tabs example" | ||
> | ||
{tabs.map((t, i) => ( | ||
<Tab | ||
key={t.value} | ||
label={t.label} | ||
{...a11yProps(i)} | ||
style={{ marginLeft: 10, marginR: 10 }} | ||
/> | ||
))} | ||
</Tabs> | ||
</Box> | ||
|
||
{tabs.map((t, i) => ( | ||
<TabPanel key={t.value} value={value} index={i}> | ||
<Taboule {...props} query={t.value} /> | ||
</TabPanel> | ||
))} | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.