♻️ create option creators, improve header transparency
This commit is contained in:
parent
69bd6cb4a0
commit
89ffa4194e
3 changed files with 32 additions and 81 deletions
|
@ -3,14 +3,14 @@ import styled from 'styled-components';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { prop, remSize } from '../../theme';
|
import { prop, remSize } from '../../theme';
|
||||||
|
|
||||||
const background = prop('MobilePanel.default.background');
|
const background = transparent => prop(transparent ? 'backgroundColor' : 'MobilePanel.default.background');
|
||||||
const textColor = prop('primaryTextColor');
|
const textColor = prop('primaryTextColor');
|
||||||
|
|
||||||
|
|
||||||
const HeaderDiv = styled.div`
|
const HeaderDiv = styled.div`
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background: ${props => (props.transparent ? 'transparent' : background)};
|
background: ${props => background(props.transparent === true)};
|
||||||
color: ${textColor};
|
color: ${textColor};
|
||||||
padding: ${remSize(12)};
|
padding: ${remSize(12)};
|
||||||
padding-left: ${remSize(16)};
|
padding-left: ${remSize(16)};
|
||||||
|
|
|
@ -20,11 +20,6 @@ const Content = styled.div`
|
||||||
margin-top: ${remSize(68)};
|
margin-top: ${remSize(68)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
const SettingsHeader = styled(Header)`
|
|
||||||
background: transparent;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const SectionHeader = styled.h2`
|
const SectionHeader = styled.h2`
|
||||||
color: ${prop('primaryTextColor')};
|
color: ${prop('primaryTextColor')};
|
||||||
padding-top: ${remSize(32)};
|
padding-top: ${remSize(32)};
|
||||||
|
@ -34,6 +29,23 @@ const SectionSubeader = styled.h3`
|
||||||
color: ${prop('primaryTextColor')};
|
color: ${prop('primaryTextColor')};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const optionsOnOff = (name, onLabel = 'On', offLabel = 'Off') => [
|
||||||
|
{
|
||||||
|
value: true, label: onLabel, ariaLabel: `${name} on`, name: `${name}`, id: `${name}-on`.replace(' ', '-')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: false, label: offLabel, ariaLabel: `${name} off`, name: `${name}`, id: `${name}-off`.replace(' ', '-')
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const optionsPickOne = (name, ...options) => options.map(option => ({
|
||||||
|
value: option,
|
||||||
|
label: option,
|
||||||
|
ariaLabel: `${option} ${name} on`,
|
||||||
|
name: `${option} ${name}`,
|
||||||
|
id: `${option}-${name}-on`.replace(' ', '-')
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
const MobilePreferences = (props) => {
|
const MobilePreferences = (props) => {
|
||||||
const {
|
const {
|
||||||
|
@ -47,49 +59,21 @@ const MobilePreferences = (props) => {
|
||||||
{
|
{
|
||||||
title: 'Theme',
|
title: 'Theme',
|
||||||
value: theme,
|
value: theme,
|
||||||
options: [
|
options: optionsPickOne('theme', 'light', 'dark', 'contrast'),
|
||||||
{
|
|
||||||
value: 'light', label: 'light', ariaLabel: 'light theme on', name: 'light theme', id: 'light-theme-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'dark', label: 'dark', ariaLabel: 'dark theme on', name: 'dark theme', id: 'dark-theme-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'contrast',
|
|
||||||
label: 'contrast',
|
|
||||||
ariaLabel: 'contrast theme on',
|
|
||||||
name: 'contrast theme',
|
|
||||||
id: 'contrast-theme-on'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
onSelect: x => setTheme(x) // setTheme
|
onSelect: x => setTheme(x) // setTheme
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: 'Autosave',
|
title: 'Autosave',
|
||||||
value: autosave,
|
value: autosave,
|
||||||
options: [
|
options: optionsOnOff('autosave'),
|
||||||
{
|
|
||||||
value: true, label: 'On', ariaLabel: 'autosave on', name: 'autosave', id: 'autosave-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: false, label: 'Off', ariaLabel: 'autosave off', name: 'autosave', id: 'autosave-off'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
onSelect: x => setAutosave(x) // setAutosave
|
onSelect: x => setAutosave(x) // setAutosave
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: 'Word Wrap',
|
title: 'Word Wrap',
|
||||||
value: linewrap,
|
value: linewrap,
|
||||||
options: [
|
options: optionsOnOff('linewrap'),
|
||||||
{
|
|
||||||
value: true, label: 'On', ariaLabel: 'linewrap on', name: 'linewrap', id: 'linewrap-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: false, label: 'Off', ariaLabel: 'linewrap off', name: 'linewrap', id: 'linewrap-off'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
onSelect: x => setLinewrap(x)
|
onSelect: x => setLinewrap(x)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -98,40 +82,19 @@ const MobilePreferences = (props) => {
|
||||||
{
|
{
|
||||||
title: 'Plain-text',
|
title: 'Plain-text',
|
||||||
value: textOutput,
|
value: textOutput,
|
||||||
options: [
|
options: optionsOnOff('text output'),
|
||||||
{
|
|
||||||
value: true, label: 'On', ariaLabel: 'text output on', name: 'text output', id: 'text-output-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: false, label: 'Off', ariaLabel: 'text output off', name: 'text output', id: 'text-output-off'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
onSelect: x => setTextOutput(x)
|
onSelect: x => setTextOutput(x)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Table-text',
|
title: 'Table-text',
|
||||||
value: gridOutput,
|
value: gridOutput,
|
||||||
options: [
|
options: optionsOnOff('table output'),
|
||||||
{
|
|
||||||
value: true, label: 'On', ariaLabel: 'table output on', name: 'table output', id: 'table-output-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: false, label: 'Off', ariaLabel: 'table output off', name: 'table output', id: 'table-output-off'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
onSelect: x => setGridOutput(x)
|
onSelect: x => setGridOutput(x)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Sound',
|
title: 'Sound',
|
||||||
value: soundOutput,
|
value: soundOutput,
|
||||||
options: [
|
options: optionsOnOff('sound output'),
|
||||||
{
|
|
||||||
value: true, label: 'On', ariaLabel: 'sound output on', name: 'sound output', id: 'sound-output-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: false, label: 'Off', ariaLabel: 'sound output off', name: 'sound output', id: 'sound-output-off'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
onSelect: x => setSoundOutput(x)
|
onSelect: x => setSoundOutput(x)
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -140,27 +103,13 @@ const MobilePreferences = (props) => {
|
||||||
{
|
{
|
||||||
title: 'Line Numbers',
|
title: 'Line Numbers',
|
||||||
value: lineNumbers,
|
value: lineNumbers,
|
||||||
options: [
|
options: optionsOnOff('line numbers'),
|
||||||
{
|
|
||||||
value: true, label: 'On', ariaLabel: 'line numbers on', name: 'line numbers', id: 'line-numbers-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: false, label: 'Off', ariaLabel: 'line numbers off', name: 'line numbers', id: 'line-numbers-off'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
onSelect: x => setLineNumbers(x)
|
onSelect: x => setLineNumbers(x)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Lint Warning Sound',
|
title: 'Lint Warning Sound',
|
||||||
value: lintWarning,
|
value: lintWarning,
|
||||||
options: [
|
options: optionsOnOff('lint warning'),
|
||||||
{
|
|
||||||
value: true, label: 'On', ariaLabel: 'lint warning on', name: 'lint warning', id: 'lint-warning-on'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: false, label: 'Off', ariaLabel: 'lint warning off', name: 'lint warning', id: 'lint-warning-off'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
onSelect: x => setLintWarning(x)
|
onSelect: x => setLintWarning(x)
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -168,10 +117,9 @@ const MobilePreferences = (props) => {
|
||||||
return (
|
return (
|
||||||
<Screen fullscreen>
|
<Screen fullscreen>
|
||||||
<section>
|
<section>
|
||||||
<SettingsHeader transparent title="Preferences">
|
<Header transparent title="Preferences">
|
||||||
|
|
||||||
<IconButton to="/mobile" icon={ExitIcon} aria-label="Return to ide view" />
|
<IconButton to="/mobile" icon={ExitIcon} aria-label="Return to ide view" />
|
||||||
</SettingsHeader>
|
</Header>
|
||||||
<section className="preferences">
|
<section className="preferences">
|
||||||
<Content>
|
<Content>
|
||||||
<SectionHeader>General Settings</SectionHeader>
|
<SectionHeader>General Settings</SectionHeader>
|
||||||
|
|
|
@ -62,6 +62,7 @@ export default {
|
||||||
colors,
|
colors,
|
||||||
...common,
|
...common,
|
||||||
primaryTextColor: grays.dark,
|
primaryTextColor: grays.dark,
|
||||||
|
backgroundColor: grays.lighter,
|
||||||
|
|
||||||
Button: {
|
Button: {
|
||||||
default: {
|
default: {
|
||||||
|
@ -101,6 +102,7 @@ export default {
|
||||||
colors,
|
colors,
|
||||||
...common,
|
...common,
|
||||||
primaryTextColor: grays.lightest,
|
primaryTextColor: grays.lightest,
|
||||||
|
backgroundColor: grays.darker,
|
||||||
|
|
||||||
Button: {
|
Button: {
|
||||||
default: {
|
default: {
|
||||||
|
@ -140,6 +142,7 @@ export default {
|
||||||
colors,
|
colors,
|
||||||
...common,
|
...common,
|
||||||
primaryTextColor: grays.lightest,
|
primaryTextColor: grays.lightest,
|
||||||
|
backgroundColor: grays.darker,
|
||||||
|
|
||||||
Button: {
|
Button: {
|
||||||
default: {
|
default: {
|
||||||
|
|
Loading…
Reference in a new issue