Added a tab view.

master
Sander Vocke 6 years ago
parent bcbc51ba5d
commit 114faf6571
  1. 63
      src/resultsview.js

@ -5,6 +5,9 @@ import Box from '@material-ui/core/Box';
import ImportContactsIcon from '@material-ui/icons/ImportContacts';
import Button from '@material-ui/core/Button';
import LabelIcon from '@material-ui/icons/Label';
import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import { GridGallery } from './gridgallery.js';
@ -90,21 +93,57 @@ export function ImagesView(props) {
return <GridGallery {...props} />;
}
function TabPanel(props) {
const { children, activeIndex, myIndex } = props;
return (
<>
{activeIndex === myIndex && <Box>{children}</Box>}
</>
);
}
export function ResultsView(props) {
const classes = useStyles();
const { photos, albums, tags } = props;
const [ activeIndex, setActiveIndex ] = React.useState(0);
var _ = require('lodash');
function tabProps(index) {
return {
id: _.uniqueId("tab_"),
};
}
const handleChange = (e, newindex) => {
setActiveIndex(newindex);
}
return (
<Box className={classes.root}>
<Box className={classes.root}>
<ImagesView className={classes.root} photos={photos} />
</Box>
<Box className={classes.root}>
<AlbumsView className={classes.root} albums={albums} />
</Box>
<Box className={classes.root}>
<TagsView className={classes.root} tags={tags} />
</Box>
</Box>
)
<div className={classes.root}>
<AppBar position="static">
<Tabs value={activeIndex} onChange={handleChange}>
<Tab label="Images" {...tabProps(0)} />
<Tab label="Albums" {...tabProps(1)} />
<Tab label="Tags" {...tabProps(2)} />
</Tabs>
</AppBar>
<TabPanel activeIndex={activeIndex} myIndex={0}>
<Box className={classes.root}>
<ImagesView className={classes.root} photos={photos} />
</Box>
</TabPanel>
<TabPanel activeIndex={activeIndex} myIndex={1}>
<Box className={classes.root}>
<AlbumsView className={classes.root} albums={albums} />
</Box>
</TabPanel>
<TabPanel activeIndex={activeIndex} myIndex={2}>
<Box className={classes.root}>
<TagsView className={classes.root} tags={tags} />
</Box>
</TabPanel>
</div>
);
}
Loading…
Cancel
Save