replace checkboxes in user-settings with Checkbox component

This commit is contained in:
Henry Jameson 2019-10-07 00:05:21 +03:00
parent 0be86304d2
commit 8ee50f9f16
3 changed files with 69 additions and 86 deletions

View file

@ -1,13 +1,22 @@
<template> <template>
<label class="checkbox"> <label
class="checkbox"
:class="{ disabled, indeterminate }"
>
<input <input
type="checkbox" type="checkbox"
:disabled="disabled"
:checked="checked" :checked="checked"
:indeterminate.prop="indeterminate" :indeterminate.prop="indeterminate"
@change="$emit('change', $event.target.checked)" @change="$emit('change', $event.target.checked)"
> >
<i class="checkbox-indicator" /> <i class="checkbox-indicator" />
<span v-if="!!$slots.default"><slot /></span> <span
class="label"
v-if="!!$slots.default"
>
<slot />
</span>
</label> </label>
</template> </template>
@ -17,7 +26,11 @@ export default {
prop: 'checked', prop: 'checked',
event: 'change' event: 'change'
}, },
props: ['checked', 'indeterminate'] props: [
'checked',
'indeterminate',
'disabled'
]
} }
</script> </script>
@ -54,6 +67,17 @@ export default {
box-sizing: border-box; box-sizing: border-box;
} }
&.disabled {
.checkbox-indicator::before,
.label {
opacity: .5;
}
.label {
color: $fallback--faint;
color: var(--faint, $fallback--faint);
}
}
input[type=checkbox] { input[type=checkbox] {
display: none; display: none;
@ -68,9 +92,6 @@ export default {
color: var(--text, $fallback--text); color: var(--text, $fallback--text);
} }
&:disabled + .checkbox-indicator::before {
opacity: .5;
}
} }
& > span { & > span {

View file

@ -17,6 +17,7 @@ import Autosuggest from '../autosuggest/autosuggest.vue'
import Importer from '../importer/importer.vue' import Importer from '../importer/importer.vue'
import Exporter from '../exporter/exporter.vue' import Exporter from '../exporter/exporter.vue'
import withSubscription from '../../hocs/with_subscription/with_subscription' import withSubscription from '../../hocs/with_subscription/with_subscription'
import Checkbox from '../checkbox/checkbox.vue'
import Mfa from './mfa.vue' import Mfa from './mfa.vue'
const BlockList = withSubscription({ const BlockList = withSubscription({
@ -82,7 +83,8 @@ const UserSettings = {
ProgressButton, ProgressButton,
Importer, Importer,
Exporter, Exporter,
Mfa Mfa,
Checkbox
}, },
computed: { computed: {
user () { user () {

View file

@ -53,12 +53,9 @@
/> />
</EmojiInput> </EmojiInput>
<p> <p>
<input <Checkbox v-model="newLocked">
id="account-locked" {{ $t('settings.lock_account_description') }}
v-model="newLocked" </Checkbox>
type="checkbox"
>
<label for="account-locked">{{ $t('settings.lock_account_description') }}</label>
</p> </p>
<div> <div>
<label for="default-vis">{{ $t('settings.default_vis') }}</label> <label for="default-vis">{{ $t('settings.default_vis') }}</label>
@ -75,69 +72,52 @@
</div> </div>
</div> </div>
<p> <p>
<input <Checkbox v-model="newNoRichText">
id="account-no-rich-text" {{ $t('settings.no_rich_text_description') }}
v-model="newNoRichText" </Checkbox>
type="checkbox"
>
<label for="account-no-rich-text">{{ $t('settings.no_rich_text_description') }}</label>
</p> </p>
<p> <p>
<input <Checkbox v-model="hideFollows">
id="account-hide-follows" {{ $t('settings.hide_follows_description') }}
v-model="hideFollows" </Checkbox>
type="checkbox"
>
<label for="account-hide-follows">{{ $t('settings.hide_follows_description') }}</label>
</p> </p>
<p class="setting-subitem"> <p class="setting-subitem">
<input <Checkbox
id="account-hide-follows-count"
v-model="hideFollowsCount" v-model="hideFollowsCount"
type="checkbox"
:disabled="!hideFollows" :disabled="!hideFollows"
> >
<label for="account-hide-follows-count">{{ $t('settings.hide_follows_count_description') }}</label> {{ $t('settings.hide_follows_count_description') }}
</Checkbox>
</p> </p>
<p> <p>
<input <Checkbox
id="account-hide-followers"
v-model="hideFollowers" v-model="hideFollowers"
type="checkbox" >
> {{ $t('settings.hide_followers_description') }}
<label for="account-hide-followers">{{ $t('settings.hide_followers_description') }}</label> </Checkbox>
</p> </p>
<p class="setting-subitem"> <p class="setting-subitem">
<input <Checkbox
id="account-hide-followers-count"
v-model="hideFollowersCount" v-model="hideFollowersCount"
type="checkbox"
:disabled="!hideFollowers" :disabled="!hideFollowers"
> >
<label for="account-hide-followers-count">{{ $t('settings.hide_followers_count_description') }}</label> {{ $t('settings.hide_followers_count_description') }}
</Checkbox>
</p> </p>
<p> <p>
<input <Checkbox v-model="showRole">
id="account-show-role" <template v-if="role === 'admin'">
v-model="showRole" {{ $t('settings.show_admin_badge') }}
type="checkbox" </template>
> <template v-if="role === 'moderator'">
<label {{ $t('settings.show_moderator_badge') }}
v-if="role === 'admin'" </template>
for="account-show-role" </Checkbox>
>{{ $t('settings.show_admin_badge') }}</label>
<label
v-if="role === 'moderator'"
for="account-show-role"
>{{ $t('settings.show_moderator_badge') }}</label>
</p> </p>
<p> <p>
<input <Checkbox v-model="discoverable">
id="discoverable" {{ $t('settings.discoverable') }}
v-model="discoverable" </Checkbox>
type="checkbox"
>
<label for="discoverable">{{ $t('settings.discoverable') }}</label>
</p> </p>
<button <button
:disabled="newName && newName.length === 0" :disabled="newName && newName.length === 0"
@ -367,44 +347,24 @@
<span class="label">{{ $t('settings.notification_setting') }}</span> <span class="label">{{ $t('settings.notification_setting') }}</span>
<ul class="option-list"> <ul class="option-list">
<li> <li>
<input <Checkbox v-model="notificationSettings.follows">
id="notification-setting-follows"
v-model="notificationSettings.follows"
type="checkbox"
>
<label for="notification-setting-follows">
{{ $t('settings.notification_setting_follows') }} {{ $t('settings.notification_setting_follows') }}
</label> </Checkbox>
</li> </li>
<li> <li>
<input <Checkbox v-model="notificationSettings.followers">
id="notification-setting-followers"
v-model="notificationSettings.followers"
type="checkbox"
>
<label for="notification-setting-followers">
{{ $t('settings.notification_setting_followers') }} {{ $t('settings.notification_setting_followers') }}
</label> </Checkbox>
</li> </li>
<li> <li>
<input <Checkbox v-model="notificationSettings.non_follows">
id="notification-setting-non-follows"
v-model="notificationSettings.non_follows"
type="checkbox"
>
<label for="notification-setting-non-follows">
{{ $t('settings.notification_setting_non_follows') }} {{ $t('settings.notification_setting_non_follows') }}
</label> </Checkbox>
</li> </li>
<li> <li>
<input <Checkbox v-model="notificationSettings.non_followers">
id="notification-setting-non-followers"
v-model="notificationSettings.non_followers"
type="checkbox"
>
<label for="notification-setting-non-followers">
{{ $t('settings.notification_setting_non_followers') }} {{ $t('settings.notification_setting_non_followers') }}
</label> </Checkbox>
</li> </li>
</ul> </ul>
</div> </div>