Tidy switches Vue files

This commit is contained in:
Samuel Elliott 2018-02-12 18:50:35 +00:00
parent 8d7261a24a
commit 32326471b1
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
5 changed files with 32 additions and 55 deletions

View File

@ -15,17 +15,13 @@
<h5>Custom Editor</h5> <h5>Custom Editor</h5>
<div class="bd-form-warning"> <div class="bd-form-warning">
<div class="bd-text">Custom Editor is not installed!</div> <div class="bd-text">Custom Editor is not installed!</div>
<FormButton> <FormButton>Install</FormButton>
Install
</FormButton>
</div> </div>
<span style="color: #FFF; font-size: 12px; font-weight: 700;">*This is displayed if editor is not installed</span> <span style="color: #FFF; font-size: 12px; font-weight: 700;">*This is displayed if editor is not installed</span>
<FormButton :onClick="openInternalEditor"> <FormButton :onClick="openInternalEditor">Open</FormButton>
Open
</FormButton>
</div> </div>
<div class="bd-form-divider"></div> <div class="bd-form-divider"></div>
<SettingSwitch :setting="dummySetting" :onClick="settingClicked" /> <Setting :setting="liveUpdateSetting" :change="enabled => liveUpdateSetting.value = enabled" />
<div class="bd-form-item"> <div class="bd-form-item">
<h5>System Editor</h5> <h5>System Editor</h5>
<FormButton> <FormButton>
@ -33,12 +29,8 @@
</FormButton> </FormButton>
</div> </div>
<div class="bd-form-divider"></div> <div class="bd-form-divider"></div>
<FormButton :onClick="settingClicked"> <FormButton :onClick="() => {}">Enabled</FormButton>
Enabled <FormButton :disabled="true"><span>Disabled</span></FormButton>
</FormButton>
<FormButton :disabled="true">
<span>Disabled</span>
</FormButton>
<FormButton :loading="true" /> <FormButton :loading="true" />
</div> </div>
</SettingsWrapper> </SettingsWrapper>
@ -48,27 +40,29 @@
// Imports // Imports
import { CssEditor } from 'modules'; import { CssEditor } from 'modules';
import { SettingsWrapper } from './'; import { SettingsWrapper } from './';
import { SettingSwitch, FormButton } from '../common'; import { FormButton } from '../common';
import Setting from './setting/Setting.vue';
export default { export default {
components: { components: {
SettingsWrapper, SettingsWrapper,
SettingSwitch, FormButton Setting,
FormButton
},
data() {
return {
liveUpdateSetting: {
id: "live-update",
type: "bool",
text: "Live Update",
hint: "Automatically update client css when saved.",
value: true
}
}
}, },
methods: { methods: {
openInternalEditor() { openInternalEditor() {
CssEditor.show(); CssEditor.show();
},
settingClicked() {
}
},
data() {
return {
dummySetting: {
title: "Live Update",
hint: "Automatically update client css when saved.",
checked: true
}
} }
} }
} }

View File

@ -10,10 +10,7 @@
<template> <template>
<Card :item="plugin"> <Card :item="plugin">
<label slot="toggle" class="bd-switch-wrapper" @click="() => { togglePlugin(plugin); this.$forceUpdate(); }"> <SettingSwitch slot="toggle" :checked="plugin.enabled" :change="() => plugin.enabled ? plugin.stop() : plugin.start()" />
<input type="checkbox" class="bd-switch-checkbox" />
<div class="bd-switch" :class="{'bd-checked': plugin.enabled}" />
</label>
<ButtonGroup slot="controls"> <ButtonGroup slot="controls">
<Button v-tooltip="'Settings'" v-if="plugin.hasSettings" :onClick="() => showSettings(plugin)"> <Button v-tooltip="'Settings'" v-if="plugin.hasSettings" :onClick="() => showSettings(plugin)">
<MiSettings size="18" /> <MiSettings size="18" />

View File

@ -10,10 +10,7 @@
<template> <template>
<Card :item="theme"> <Card :item="theme">
<label slot="toggle" class="bd-switch-wrapper" @click="() => { toggleTheme(theme); this.$forceUpdate(); }"> <SettingSwitch slot="toggle" :checked="theme.enabled" :change="() => theme.enabled ? theme.disable() : theme.enable()" />
<input type="checkbox" class="bd-switch-checkbox" />
<div class="bd-switch" :class="{'bd-checked': theme.enabled}" />
</label>
<ButtonGroup slot="controls"> <ButtonGroup slot="controls">
<Button v-tooltip="'Settings'" v-if="theme.hasSettings" :onClick="() => showSettings(theme)"> <Button v-tooltip="'Settings'" v-if="theme.hasSettings" :onClick="() => showSettings(theme)">
<MiSettings size="18" /> <MiSettings size="18" />

View File

@ -12,21 +12,18 @@
<div class="bd-setting-switch"> <div class="bd-setting-switch">
<div class="bd-title"> <div class="bd-title">
<h3>{{setting.text}}</h3> <h3>{{setting.text}}</h3>
<label class="bd-switch-wrapper" @click="toggle"> <SettingSwitch :checked="setting.value" :change="change" />
<input type="checkbox" class="bd-switch-checkbox" />
<div class="bd-switch" :class="{'bd-checked': setting.value}" />
</label>
</div> </div>
<div class="bd-hint">{{setting.hint}}</div> <div class="bd-hint">{{setting.hint}}</div>
</div> </div>
</template> </template>
<script> <script>
import SettingSwitch from '../../common/SettingSwitch.vue';
export default { export default {
props: ['setting', 'change'], props: ['setting', 'change'],
methods: { components: {
toggle() { SettingSwitch
this.change(!this.setting.value);
}
} }
} }
</script> </script>

View File

@ -9,21 +9,13 @@
*/ */
<template> <template>
<div class="bd-setting-switch" :class="{'bd-disabled': disabled}"> <label class="bd-switch-wrapper" @click="() => change(!checked)">
<div class="bd-setting-switch-wrap"> <input type="checkbox" class="bd-switch-checkbox" />
<div class="bd-title"> <div class="bd-switch" :class="{'bd-checked': checked}" />
<h3>{{setting.title || setting.text}}</h3> </label>
<label class="bd-switch-wrapper" @click="!disabled ? onClick(setting) : null">
<input type="checkbox" class="bd-switch-checkbox" />
<div class="bd-switch" :class="{'bd-checked': (setting.checked || setting.enabled || setting.value)}" />
</label>
</div>
<div class="bd-hint">{{setting.hint}}</div>
</div>
</div>
</template> </template>
<script> <script>
export default { export default {
props: ['setting', 'onClick', 'disabled'] props: ['checked', 'change']
} }
</script> </script>