mirror of
https://github.com/chinchang/web-maker.git
synced 2025-05-06 18:45:31 +02:00
Distribute settings in categories and fixes in tab/switch
This commit is contained in:
parent
f2a96b3ec2
commit
6776855cad
@ -2,6 +2,7 @@ import { h, Component } from 'preact';
|
|||||||
import { editorThemes } from '../editorThemes';
|
import { editorThemes } from '../editorThemes';
|
||||||
import Switch from './Switch';
|
import Switch from './Switch';
|
||||||
import Tabs, { TabPanel } from './Tabs';
|
import Tabs, { TabPanel } from './Tabs';
|
||||||
|
import { Divider } from './common';
|
||||||
|
|
||||||
function CheckboxSetting({
|
function CheckboxSetting({
|
||||||
title,
|
title,
|
||||||
@ -42,6 +43,56 @@ export default class Settings extends Component {
|
|||||||
<h1>Settings</h1>
|
<h1>Settings</h1>
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
|
<TabPanel label="General">
|
||||||
|
<CheckboxSetting
|
||||||
|
name="preserveLastCode"
|
||||||
|
title="Loads the last open creation when app starts"
|
||||||
|
label="Preserve last written code"
|
||||||
|
pref={prefs.preserveLastCode}
|
||||||
|
onChange={this.updateSetting.bind(this)}
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
<CheckboxSetting
|
||||||
|
name="lightVersion"
|
||||||
|
title="Switch to lighter version for better performance. Removes things like blur etc."
|
||||||
|
label="Fast/light version"
|
||||||
|
pref={prefs.lightVersion}
|
||||||
|
onChange={this.updateSetting.bind(this)}
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
<CheckboxSetting
|
||||||
|
name="autoPreview"
|
||||||
|
title="Refreshes the preview as you code. Otherwise use the Run button"
|
||||||
|
label="Auto-preview"
|
||||||
|
pref={prefs.autoPreview}
|
||||||
|
onChange={this.updateSetting.bind(this)}
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
<CheckboxSetting
|
||||||
|
name="autoSave"
|
||||||
|
title="Auto-save keeps saving your code at regular intervals after you hit the first save manually"
|
||||||
|
label="Auto-save"
|
||||||
|
pref={prefs.autoSave}
|
||||||
|
onChange={this.updateSetting.bind(this)}
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
<CheckboxSetting
|
||||||
|
name="replaceNewTab"
|
||||||
|
title="Turning this on will start showing Web Maker in every new tab you open"
|
||||||
|
label="Replace new tab page"
|
||||||
|
pref={prefs.replaceNewTab}
|
||||||
|
onChange={this.updateSetting.bind(this)}
|
||||||
|
showWhenExtension
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
<CheckboxSetting
|
||||||
|
name="preserveConsoleLogs"
|
||||||
|
title="Preserves the console logs across your preview refreshes"
|
||||||
|
label="Preserve console logs"
|
||||||
|
pref={prefs.preserveConsoleLogs}
|
||||||
|
onChange={this.updateSetting.bind(this)}
|
||||||
|
/>
|
||||||
|
</TabPanel>
|
||||||
<TabPanel label="Indentation">
|
<TabPanel label="Indentation">
|
||||||
<div
|
<div
|
||||||
class="line"
|
class="line"
|
||||||
@ -218,6 +269,7 @@ export default class Settings extends Component {
|
|||||||
pref={prefs.lineWrap}
|
pref={prefs.lineWrap}
|
||||||
onChange={this.updateSetting.bind(this)}
|
onChange={this.updateSetting.bind(this)}
|
||||||
/>
|
/>
|
||||||
|
<Divider />
|
||||||
<CheckboxSetting
|
<CheckboxSetting
|
||||||
name="refreshOnResize"
|
name="refreshOnResize"
|
||||||
title="Your Preview will refresh when you resize the preview split"
|
title="Your Preview will refresh when you resize the preview split"
|
||||||
@ -225,6 +277,7 @@ export default class Settings extends Component {
|
|||||||
pref={prefs.refreshOnResize}
|
pref={prefs.refreshOnResize}
|
||||||
onChange={this.updateSetting.bind(this)}
|
onChange={this.updateSetting.bind(this)}
|
||||||
/>
|
/>
|
||||||
|
<Divider />
|
||||||
<CheckboxSetting
|
<CheckboxSetting
|
||||||
name="autoComplete"
|
name="autoComplete"
|
||||||
title="Turns on the auto-completion suggestions as you type"
|
title="Turns on the auto-completion suggestions as you type"
|
||||||
@ -232,70 +285,25 @@ export default class Settings extends Component {
|
|||||||
pref={prefs.autoComplete}
|
pref={prefs.autoComplete}
|
||||||
onChange={this.updateSetting.bind(this)}
|
onChange={this.updateSetting.bind(this)}
|
||||||
/>
|
/>
|
||||||
<CheckboxSetting
|
|
||||||
name="autoPreview"
|
|
||||||
title="Refreshes the preview as you code. Otherwise use the Run button"
|
|
||||||
label="Auto-preview"
|
|
||||||
pref={prefs.autoPreview}
|
|
||||||
onChange={this.updateSetting.bind(this)}
|
|
||||||
/>
|
|
||||||
<CheckboxSetting
|
|
||||||
name="autoSave"
|
|
||||||
title="Auto-save keeps saving your code at regular intervals after you hit the first save manually"
|
|
||||||
label="Auto-save"
|
|
||||||
pref={prefs.autoSave}
|
|
||||||
onChange={this.updateSetting.bind(this)}
|
|
||||||
/>
|
|
||||||
<CheckboxSetting
|
|
||||||
name="preserveLastCode"
|
|
||||||
title="Loads the last open creation when app starts"
|
|
||||||
label="Preserve last written code"
|
|
||||||
pref={prefs.preserveLastCode}
|
|
||||||
onChange={this.updateSetting.bind(this)}
|
|
||||||
/>
|
|
||||||
<CheckboxSetting
|
|
||||||
name="replaceNewTab"
|
|
||||||
title="Turning this on will start showing Web Maker in every new tab you open"
|
|
||||||
label="Replace new tab page"
|
|
||||||
pref={prefs.replaceNewTab}
|
|
||||||
onChange={this.updateSetting.bind(this)}
|
|
||||||
showWhenExtension
|
|
||||||
/>
|
|
||||||
<CheckboxSetting
|
|
||||||
name="preserveConsoleLogs"
|
|
||||||
title="Preserves the console logs across your preview refreshes"
|
|
||||||
label="Preserve console logs"
|
|
||||||
pref={prefs.preserveConsoleLogs}
|
|
||||||
onChange={this.updateSetting.bind(this)}
|
|
||||||
/>
|
|
||||||
<CheckboxSetting
|
|
||||||
name="lightVersion"
|
|
||||||
title="Switch to lighter version for better performance. Removes things like blur etc."
|
|
||||||
label="Fast/light version"
|
|
||||||
pref={prefs.lightVersion}
|
|
||||||
onChange={this.updateSetting.bind(this)}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel label="Fun">
|
<TabPanel label="Fun">
|
||||||
<p>
|
<CheckboxSetting
|
||||||
<CheckboxSetting
|
title="Enjoy wonderful particle blasts while you type"
|
||||||
title="Enjoy wonderful particle blasts while you type"
|
label="Code blast!"
|
||||||
label="Code blast!"
|
name="isCodeBlastOn"
|
||||||
name="isCodeBlastOn"
|
pref={prefs.isCodeBlastOn}
|
||||||
pref={prefs.isCodeBlastOn}
|
onChange={this.updateSetting.bind(this)}
|
||||||
onChange={this.updateSetting.bind(this)}
|
/>
|
||||||
/>
|
<Divider />
|
||||||
|
<CheckboxSetting
|
||||||
<CheckboxSetting
|
title="Get ready to build some games at JS13KGames"
|
||||||
title="Get ready to build some games at JS13KGames"
|
label="Js13kGames Mode"
|
||||||
label="Js13kGames Mode"
|
name="isJs13kModeOn"
|
||||||
name="isJs13kModeOn"
|
pref={prefs.isJs13kModeOn}
|
||||||
pref={prefs.isJs13kModeOn}
|
onChange={this.updateSetting.bind(this)}
|
||||||
onChange={this.updateSetting.bind(this)}
|
/>
|
||||||
/>
|
|
||||||
</p>
|
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel label="Advanced">
|
<TabPanel label="Advanced">
|
||||||
<p>
|
<p>
|
||||||
|
@ -4,12 +4,26 @@ export default class Switch extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<label class="check-switch">
|
<label class="check-switch">
|
||||||
{this.props.children}
|
|
||||||
<input role="switch" type="checkbox" checked={this.props.checked} />
|
<input role="switch" type="checkbox" checked={this.props.checked} />
|
||||||
<span aria-hidden="true" class="check-switch__toggle" />
|
<div class="check-switch__toggle-wrap">
|
||||||
<span aria-hidden="true" class="check-switch__status">
|
<span
|
||||||
{this.props.checked ? 'on' : 'off'}
|
aria-hidden="true"
|
||||||
</span>
|
class="check-switch__status"
|
||||||
|
style={`visibility:${this.props.checked ? 'hidden' : 'visible'}`}
|
||||||
|
>
|
||||||
|
Off
|
||||||
|
</span>
|
||||||
|
<span aria-hidden="true" class="check-switch__toggle" />
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
class="check-switch__status"
|
||||||
|
style={`visibility:${this.props.checked ? 'visible' : 'hidden'}`}
|
||||||
|
>
|
||||||
|
On
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{this.props.children}
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ export default class Tabs extends Component {
|
|||||||
let { selectedTab } = this.state;
|
let { selectedTab } = this.state;
|
||||||
if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
|
if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
|
||||||
selectedTab--;
|
selectedTab--;
|
||||||
selectedTab = selectedTab < 0 ? this.props.length - 1 : selectedTab;
|
selectedTab =
|
||||||
|
selectedTab < 0 ? this.props.children.length - 1 : selectedTab;
|
||||||
this.setState({ selectedTab: selectedTab });
|
this.setState({ selectedTab: selectedTab });
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
|
} else if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
|
||||||
|
@ -32,3 +32,7 @@ export function AutoFocusInput(props) {
|
|||||||
<input ref={el => el && setTimeout(() => el.focus(), 100)} {...props} />
|
<input ref={el => el && setTimeout(() => el.focus(), 100)} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function Divider(props) {
|
||||||
|
return <div class="divider" />;
|
||||||
|
}
|
||||||
|
@ -212,6 +212,11 @@ hr {
|
|||||||
label {
|
label {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
.divider {
|
||||||
|
margin: 10px 0;
|
||||||
|
height: 1px;
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
[class*='hint--']:after {
|
[class*='hint--']:after {
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
@ -260,31 +265,35 @@ a > svg {
|
|||||||
background: rgba(0, 0, 0, 0.1);
|
background: rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.check-switch .check-switch__toggle {
|
||||||
|
position: relative;
|
||||||
|
margin: 0 5px;
|
||||||
|
}
|
||||||
.check-switch .check-switch__toggle:after {
|
.check-switch .check-switch__toggle:after {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
position: absolute;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
height: 1.5em;
|
width: 1.1em;
|
||||||
|
height: 1.1em;
|
||||||
|
top: 3px;
|
||||||
right: 1.5em;
|
right: 1.5em;
|
||||||
|
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
|
||||||
transition: right 0.1825s ease-in-out;
|
transition: right 0.1825s ease-in-out;
|
||||||
width: 1.5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-switch .check-switch__toggle:before,
|
.check-switch .check-switch__toggle:before,
|
||||||
.check-switch .check-switch__toggle:after {
|
.check-switch .check-switch__toggle:after {
|
||||||
border: 1px solid #565656;
|
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
display: block;
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-switch .check-switch__toggle:before {
|
.check-switch .check-switch__toggle:before {
|
||||||
background: #eee;
|
background: rgba(255, 255, 255, 0.2);
|
||||||
border-radius: 1.75em;
|
border-radius: 1.75em;
|
||||||
height: 1.75em;
|
width: 2.75em;
|
||||||
|
height: 1.45em;
|
||||||
right: 0.25em;
|
right: 0.25em;
|
||||||
transition: background 0.2s ease-in-out;
|
transition: background 0.2s ease-in-out;
|
||||||
width: 2.75em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-switch input:not([role='button']) {
|
.check-switch input:not([role='button']) {
|
||||||
@ -292,31 +301,38 @@ a > svg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.check-switch input {
|
.check-switch input {
|
||||||
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
opacity: 0.0001;
|
opacity: 0.0001;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-switch__status {
|
.check-switch__status {
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-switch input:focus + .check-switch__toggle:before {
|
.check-switch input:focus + * .check-switch__toggle:before {
|
||||||
outline: 2px solid;
|
outline: 2px solid;
|
||||||
outline-color: var(--color-focus-outline);
|
outline-color: var(--color-focus-outline);
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-switch input:checked + .check-switch__toggle:after {
|
.check-switch input:checked + * .check-switch__toggle:after {
|
||||||
right: 0.25em;
|
right: 0.15em;
|
||||||
|
left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.check-switch input:checked + .check-switch__toggle:before {
|
.check-switch input:checked + * .check-switch__toggle:before {
|
||||||
background: #61ad1c;
|
background: #61ad1c;
|
||||||
}
|
}
|
||||||
|
.check-switch__toggle-wrap {
|
||||||
|
float: right;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@ -1907,7 +1923,7 @@ while the theme CSS file is loading */
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
.tabs__tab--selected {
|
.tabs__tab--selected {
|
||||||
background-color: rgba(0, 0, 0, 0.3);
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
}
|
}
|
||||||
.tabs__tabpanel-wrap {
|
.tabs__tabpanel-wrap {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user