responsively-app/desktop-app-legacy/app/components/PreviewerLayoutSelector/index.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-08-31 01:41:01 +00:00
import React, {useMemo} from 'react';
import {useTheme} from '@material-ui/core/styles';
2019-09-14 07:02:03 +00:00
import LayoutIcon from '../icons/Layout';
2019-08-25 17:17:20 +00:00
import {
2020-03-14 08:05:02 +00:00
HORIZONTAL_LAYOUT,
FLEXIGRID_LAYOUT,
INDIVIDUAL_LAYOUT,
2019-08-25 17:17:20 +00:00
} from '../../constants/previewerLayouts';
2020-08-31 01:41:01 +00:00
import Select from '../Select';
import useCommonStyles from '../useCommonStyles';
2019-08-25 17:17:20 +00:00
2020-08-31 01:41:01 +00:00
function PreviewerLayoutSelector(props) {
const theme = useTheme();
const commonClasses = useCommonStyles();
const selectedOption = useMemo(
() => options.find(option => option.value === props.value),
[props.value]
);
2019-08-25 17:17:20 +00:00
2020-03-14 08:05:02 +00:00
return (
2020-08-31 01:41:01 +00:00
<div className={commonClasses.sidebarContentSection}>
<div className={commonClasses.sidebarContentSectionTitleBar}>
<LayoutIcon height={18} margin={6} color={theme.palette.text.primary} />
2020-03-14 08:05:02 +00:00
Layout
</div>
2020-08-31 01:41:01 +00:00
<div className={commonClasses.sidebarContentSectionContainer}>
2020-03-14 08:05:02 +00:00
<Select
options={options}
2020-08-31 01:41:01 +00:00
value={selectedOption}
2020-03-14 08:05:02 +00:00
onChange={props.onChange}
/>
</div>
</div>
);
2019-08-25 17:17:20 +00:00
}
2020-08-31 01:41:01 +00:00
const options = [
{value: HORIZONTAL_LAYOUT, label: 'Horizontal'},
{value: FLEXIGRID_LAYOUT, label: 'FlexiGrid'},
{value: INDIVIDUAL_LAYOUT, label: 'Individual'},
];
export default PreviewerLayoutSelector;