Skip to content

Commit

Permalink
fix build fail
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 13, 2019
1 parent 8aee9f7 commit 8141a0e
Show file tree
Hide file tree
Showing 4 changed files with 319 additions and 319 deletions.
35 changes: 26 additions & 9 deletions docs/src/pages/components/tabs/SimpleTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,38 @@ import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';

function TabPanel(props) {
const { children, ...other } = props;
const { children, value, index, ...other } = props;

return (
<Typography component="div" role="tabpanel" style={{ padding: 8 * 3 }} {...other}>
{children}
<Typography
component="div"
role="tabpanel"
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
{...other}
>
<Box p={3}>{children}</Box>
</Typography>
);
}

TabPanel.propTypes = {
children: PropTypes.node.isRequired,
index: PropTypes.number.isRequired,
value: PropTypes.number.isRequired,
};

function a11yProps(index) {
return {
id: `simple-tab-${index}`,
'aria-controls': `simple-tabpanel-${index}`,
};
}

const useStyles = makeStyles(theme => ({
root: {
flexGrow: 1,
Expand All @@ -39,18 +56,18 @@ export default function SimpleTabs() {
<div className={classes.root}>
<AppBar position="static" aria-label="Simple tabs example">
<Tabs value={value} onChange={handleChange}>
<Tab label="Item One" id="simple-tab-1" aria-controls="simple-tabpanel-1" />
<Tab label="Item Two" id="simple-tab-2" aria-controls="simple-tabpanel-2" />
<Tab label="Item Three" id="simple-tab-3" aria-controls="simple-tabpanel-3" />
<Tab label="Item One" {...a11yProps(0)} />
<Tab label="Item Two" {...a11yProps(1)} />
<Tab label="Item Three" {...a11yProps(2)} />
</Tabs>
</AppBar>
<TabPanel hidden={value !== 0} id="simple-tabpanel-1" aria-labelledby="simple-tab-1">
<TabPanel value={value} index={0}>
Item One
</TabPanel>
<TabPanel hidden={value !== 1} id="simple-tabpanel-2" aria-labelledby="simple-tab-2">
<TabPanel value={value} index={1}>
Item Two
</TabPanel>
<TabPanel hidden={value !== 2} id="simple-tabpanel-3" aria-labelledby="simple-tab-3">
<TabPanel value={value} index={2}>
Item Three
</TabPanel>
</div>
Expand Down
37 changes: 28 additions & 9 deletions docs/src/pages/components/tabs/SimpleTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,44 @@ import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';

interface TabPanelProps {
children?: React.ReactNode;
index: number;
value: number;
}

function TabPanel(props: TabPanelProps) {
const { children, ...other } = props;
const { children, value, index, ...other } = props;

return (
<Typography component="div" role="tabpanel" style={{ padding: 8 * 3 }} {...other}>
{children}
<Typography
component="div"
role="tabpanel"
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
{...other}
>
<Box p={3}>{children}</Box>
</Typography>
);
}

TabPanel.propTypes = {
children: PropTypes.node.isRequired,
index: PropTypes.number.isRequired,
value: PropTypes.number.isRequired,
};

function a11yProps(index: number) {
return {
id: `simple-tab-${index}`,
'aria-controls': `simple-tabpanel-${index}`,
};
}

const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
Expand All @@ -45,18 +64,18 @@ export default function SimpleTabs() {
<div className={classes.root}>
<AppBar position="static" aria-label="Simple tabs example">
<Tabs value={value} onChange={handleChange}>
<Tab label="Item One" id="simple-tab-1" aria-controls="simple-tabpanel-1" />
<Tab label="Item Two" id="simple-tab-2" aria-controls="simple-tabpanel-2" />
<Tab label="Item Three" id="simple-tab-3" aria-controls="simple-tabpanel-3" />
<Tab label="Item One" {...a11yProps(0)} />
<Tab label="Item Two" {...a11yProps(1)} />
<Tab label="Item Three" {...a11yProps(2)} />
</Tabs>
</AppBar>
<TabPanel hidden={value !== 0} id="simple-tabpanel-1" aria-labelledby="simple-tab-1">
<TabPanel value={value} index={0}>
Item One
</TabPanel>
<TabPanel hidden={value !== 1} id="simple-tabpanel-2" aria-labelledby="simple-tab-2">
<TabPanel value={value} index={1}>
Item Two
</TabPanel>
<TabPanel hidden={value !== 2} id="simple-tabpanel-3" aria-labelledby="simple-tab-3">
<TabPanel value={value} index={2}>
Item Three
</TabPanel>
</div>
Expand Down
Loading

0 comments on commit 8141a0e

Please sign in to comment.