mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 13:03:08 +02:00
chore(client): refactor and style tweaks
This commit is contained in:
parent
57bb6e611f
commit
270e1212ac
4 changed files with 250 additions and 358 deletions
|
@ -33,123 +33,83 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, onMounted, onUnmounted, nextTick, ref, watch, computed, toRefs } from 'vue';
|
import { onMounted, onUnmounted, nextTick, ref, watch, computed, toRefs } from 'vue';
|
||||||
import { debounce } from 'throttle-debounce';
|
import { debounce } from 'throttle-debounce';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import MkButton from '@/components/ui/button.vue';
|
||||||
import { useInterval } from '@/scripts/use-interval';
|
import { useInterval } from '@/scripts/use-interval';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
components: {
|
modelValue: string | number;
|
||||||
MkButton,
|
type?: 'text' | 'number' | 'password' | 'email' | 'url' | 'date' | 'time';
|
||||||
},
|
required?: boolean;
|
||||||
|
readonly?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
pattern?: string;
|
||||||
|
placeholder?: string;
|
||||||
|
autofocus?: boolean;
|
||||||
|
autocomplete?: boolean;
|
||||||
|
spellcheck?: boolean;
|
||||||
|
step?: any;
|
||||||
|
datalist?: string[];
|
||||||
|
inline?: boolean;
|
||||||
|
debounce?: boolean;
|
||||||
|
manualSave?: boolean;
|
||||||
|
small?: boolean;
|
||||||
|
large?: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
props: {
|
const emit = defineEmits<{
|
||||||
modelValue: {
|
(ev: 'change', _ev: KeyboardEvent): void;
|
||||||
required: true,
|
(ev: 'keydown', _ev: KeyboardEvent): void;
|
||||||
},
|
(ev: 'enter'): void;
|
||||||
type: {
|
(ev: 'update:modelValue', value: string | number): void;
|
||||||
type: String,
|
}>();
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
required: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
readonly: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
pattern: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
autofocus: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
autocomplete: {
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
spellcheck: {
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
step: {
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
datalist: {
|
|
||||||
type: Array,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
inline: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
debounce: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
manualSave: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['change', 'keydown', 'enter', 'update:modelValue'],
|
const { modelValue, type, autofocus } = toRefs(props);
|
||||||
|
const v = ref(modelValue.value);
|
||||||
|
const id = Math.random().toString(); // TODO: uuid?
|
||||||
|
const focused = ref(false);
|
||||||
|
const changed = ref(false);
|
||||||
|
const invalid = ref(false);
|
||||||
|
const filled = computed(() => v.value !== '' && v.value != null);
|
||||||
|
const inputEl = ref<HTMLElement>();
|
||||||
|
const prefixEl = ref<HTMLElement>();
|
||||||
|
const suffixEl = ref<HTMLElement>();
|
||||||
|
const height =
|
||||||
|
props.small ? 38 :
|
||||||
|
props.large ? 42 :
|
||||||
|
40;
|
||||||
|
|
||||||
setup(props, context) {
|
const focus = () => inputEl.value.focus();
|
||||||
const { modelValue, type, autofocus } = toRefs(props);
|
const onInput = (ev: KeyboardEvent) => {
|
||||||
const v = ref(modelValue.value);
|
|
||||||
const id = Math.random().toString(); // TODO: uuid?
|
|
||||||
const focused = ref(false);
|
|
||||||
const changed = ref(false);
|
|
||||||
const invalid = ref(false);
|
|
||||||
const filled = computed(() => v.value !== '' && v.value != null);
|
|
||||||
const inputEl = ref<HTMLElement>();
|
|
||||||
const prefixEl = ref<HTMLElement>();
|
|
||||||
const suffixEl = ref<HTMLElement>();
|
|
||||||
|
|
||||||
const focus = () => inputEl.value.focus();
|
|
||||||
const onInput = (ev) => {
|
|
||||||
changed.value = true;
|
changed.value = true;
|
||||||
context.emit('change', ev);
|
emit('change', ev);
|
||||||
};
|
};
|
||||||
const onKeydown = (ev: KeyboardEvent) => {
|
const onKeydown = (ev: KeyboardEvent) => {
|
||||||
context.emit('keydown', ev);
|
emit('keydown', ev);
|
||||||
|
|
||||||
if (ev.code === 'Enter') {
|
if (ev.code === 'Enter') {
|
||||||
context.emit('enter');
|
emit('enter');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updated = () => {
|
const updated = () => {
|
||||||
changed.value = false;
|
changed.value = false;
|
||||||
if (type.value === 'number') {
|
if (type.value === 'number') {
|
||||||
context.emit('update:modelValue', parseFloat(v.value));
|
emit('update:modelValue', parseFloat(v.value));
|
||||||
} else {
|
} else {
|
||||||
context.emit('update:modelValue', v.value);
|
emit('update:modelValue', v.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const debouncedUpdated = debounce(1000, updated);
|
const debouncedUpdated = debounce(1000, updated);
|
||||||
|
|
||||||
watch(modelValue, newValue => {
|
watch(modelValue, newValue => {
|
||||||
v.value = newValue;
|
v.value = newValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(v, newValue => {
|
watch(v, newValue => {
|
||||||
if (!props.manualSave) {
|
if (!props.manualSave) {
|
||||||
if (props.debounce) {
|
if (props.debounce) {
|
||||||
debouncedUpdated();
|
debouncedUpdated();
|
||||||
|
@ -159,11 +119,11 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
invalid.value = inputEl.value.validity.badInput;
|
invalid.value = inputEl.value.validity.badInput;
|
||||||
});
|
});
|
||||||
|
|
||||||
// このコンポーネントが作成された時、非表示状態である場合がある
|
// このコンポーネントが作成された時、非表示状態である場合がある
|
||||||
// 非表示状態だと要素の幅などは0になってしまうので、定期的に計算する
|
// 非表示状態だと要素の幅などは0になってしまうので、定期的に計算する
|
||||||
useInterval(() => {
|
useInterval(() => {
|
||||||
if (prefixEl.value) {
|
if (prefixEl.value) {
|
||||||
if (prefixEl.value.offsetWidth) {
|
if (prefixEl.value.offsetWidth) {
|
||||||
inputEl.value.style.paddingLeft = prefixEl.value.offsetWidth + 'px';
|
inputEl.value.style.paddingLeft = prefixEl.value.offsetWidth + 'px';
|
||||||
|
@ -174,35 +134,17 @@ export default defineComponent({
|
||||||
inputEl.value.style.paddingRight = suffixEl.value.offsetWidth + 'px';
|
inputEl.value.style.paddingRight = suffixEl.value.offsetWidth + 'px';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100, {
|
}, 100, {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
afterMounted: true,
|
afterMounted: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (autofocus.value) {
|
if (autofocus.value) {
|
||||||
focus();
|
focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
v,
|
|
||||||
focused,
|
|
||||||
invalid,
|
|
||||||
changed,
|
|
||||||
filled,
|
|
||||||
inputEl,
|
|
||||||
prefixEl,
|
|
||||||
suffixEl,
|
|
||||||
focus,
|
|
||||||
onInput,
|
|
||||||
onKeydown,
|
|
||||||
updated,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -229,14 +171,13 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
> .input {
|
> .input {
|
||||||
$height: 42px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
> input {
|
> input {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
display: block;
|
display: block;
|
||||||
height: $height;
|
height: v-bind("height + 'px'");
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
|
@ -266,7 +207,7 @@ export default defineComponent({
|
||||||
top: 0;
|
top: 0;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
height: $height;
|
height: v-bind("height + 'px'");
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
&:empty {
|
&:empty {
|
||||||
|
|
|
@ -26,94 +26,73 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent, onMounted, onUnmounted, nextTick, ref, watch, computed, toRefs, VNode } from 'vue';
|
import { onMounted, onUnmounted, nextTick, ref, watch, computed, toRefs, VNode, useSlots } from 'vue';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import MkButton from '@/components/ui/button.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { useInterval } from '@/scripts/use-interval';
|
import { useInterval } from '@/scripts/use-interval';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps<{
|
||||||
components: {
|
modelValue: string;
|
||||||
MkButton,
|
required?: boolean;
|
||||||
},
|
readonly?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
placeholder?: string;
|
||||||
|
autofocus?: boolean;
|
||||||
|
inline?: boolean;
|
||||||
|
manualSave?: boolean;
|
||||||
|
small?: boolean;
|
||||||
|
large?: boolean;
|
||||||
|
}>();
|
||||||
|
|
||||||
props: {
|
const emit = defineEmits<{
|
||||||
modelValue: {
|
(ev: 'change', _ev: KeyboardEvent): void;
|
||||||
required: true,
|
(ev: 'update:modelValue', value: string): void;
|
||||||
},
|
}>();
|
||||||
required: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
readonly: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
autofocus: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
inline: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
manualSave: {
|
|
||||||
type: Boolean,
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
emits: ['change', 'update:modelValue'],
|
const slots = useSlots();
|
||||||
|
|
||||||
setup(props, context) {
|
const { modelValue, autofocus } = toRefs(props);
|
||||||
const { modelValue, autofocus } = toRefs(props);
|
const v = ref(modelValue.value);
|
||||||
const v = ref(modelValue.value);
|
const focused = ref(false);
|
||||||
const focused = ref(false);
|
const changed = ref(false);
|
||||||
const changed = ref(false);
|
const invalid = ref(false);
|
||||||
const invalid = ref(false);
|
const filled = computed(() => v.value !== '' && v.value != null);
|
||||||
const filled = computed(() => v.value !== '' && v.value != null);
|
const inputEl = ref(null);
|
||||||
const inputEl = ref(null);
|
const prefixEl = ref(null);
|
||||||
const prefixEl = ref(null);
|
const suffixEl = ref(null);
|
||||||
const suffixEl = ref(null);
|
const container = ref(null);
|
||||||
const container = ref(null);
|
const height =
|
||||||
|
props.small ? 38 :
|
||||||
|
props.large ? 42 :
|
||||||
|
40;
|
||||||
|
|
||||||
const focus = () => inputEl.value.focus();
|
const focus = () => inputEl.value.focus();
|
||||||
const onInput = (ev) => {
|
const onInput = (ev) => {
|
||||||
changed.value = true;
|
changed.value = true;
|
||||||
context.emit('change', ev);
|
emit('change', ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updated = () => {
|
const updated = () => {
|
||||||
changed.value = false;
|
changed.value = false;
|
||||||
context.emit('update:modelValue', v.value);
|
emit('update:modelValue', v.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(modelValue, newValue => {
|
watch(modelValue, newValue => {
|
||||||
v.value = newValue;
|
v.value = newValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(v, newValue => {
|
watch(v, newValue => {
|
||||||
if (!props.manualSave) {
|
if (!props.manualSave) {
|
||||||
updated();
|
updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
invalid.value = inputEl.value.validity.badInput;
|
invalid.value = inputEl.value.validity.badInput;
|
||||||
});
|
});
|
||||||
|
|
||||||
// このコンポーネントが作成された時、非表示状態である場合がある
|
// このコンポーネントが作成された時、非表示状態である場合がある
|
||||||
// 非表示状態だと要素の幅などは0になってしまうので、定期的に計算する
|
// 非表示状態だと要素の幅などは0になってしまうので、定期的に計算する
|
||||||
useInterval(() => {
|
useInterval(() => {
|
||||||
if (prefixEl.value) {
|
if (prefixEl.value) {
|
||||||
if (prefixEl.value.offsetWidth) {
|
if (prefixEl.value.offsetWidth) {
|
||||||
inputEl.value.style.paddingLeft = prefixEl.value.offsetWidth + 'px';
|
inputEl.value.style.paddingLeft = prefixEl.value.offsetWidth + 'px';
|
||||||
|
@ -124,24 +103,24 @@ export default defineComponent({
|
||||||
inputEl.value.style.paddingRight = suffixEl.value.offsetWidth + 'px';
|
inputEl.value.style.paddingRight = suffixEl.value.offsetWidth + 'px';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100, {
|
}, 100, {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
afterMounted: true,
|
afterMounted: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (autofocus.value) {
|
if (autofocus.value) {
|
||||||
focus();
|
focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const onClick = (ev: MouseEvent) => {
|
const onClick = (ev: MouseEvent) => {
|
||||||
focused.value = true;
|
focused.value = true;
|
||||||
|
|
||||||
const menu = [];
|
const menu = [];
|
||||||
let options = context.slots.default();
|
let options = slots.default!();
|
||||||
|
|
||||||
const pushOption = (option: VNode) => {
|
const pushOption = (option: VNode) => {
|
||||||
menu.push({
|
menu.push({
|
||||||
|
@ -179,25 +158,7 @@ export default defineComponent({
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
focused.value = false;
|
focused.value = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
|
||||||
v,
|
|
||||||
focused,
|
|
||||||
invalid,
|
|
||||||
changed,
|
|
||||||
filled,
|
|
||||||
inputEl,
|
|
||||||
prefixEl,
|
|
||||||
suffixEl,
|
|
||||||
container,
|
|
||||||
focus,
|
|
||||||
onInput,
|
|
||||||
onClick,
|
|
||||||
updated,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -223,7 +184,6 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
> .input {
|
> .input {
|
||||||
$height: 42px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
@ -237,7 +197,7 @@ export default defineComponent({
|
||||||
appearance: none;
|
appearance: none;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
display: block;
|
display: block;
|
||||||
height: $height;
|
height: v-bind("height + 'px'");
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
|
@ -265,7 +225,7 @@ export default defineComponent({
|
||||||
top: 0;
|
top: 0;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
height: $height;
|
height: v-bind("height + 'px'");
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
&:empty {
|
&:empty {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(choice, i) in choices" :key="i">
|
<li v-for="(choice, i) in choices" :key="i">
|
||||||
<MkInput class="input" :model-value="choice" :placeholder="$t('_poll.choiceN', { n: i + 1 })" @update:modelValue="onInput(i, $event)">
|
<MkInput class="input" small :model-value="choice" :placeholder="$t('_poll.choiceN', { n: i + 1 })" @update:modelValue="onInput(i, $event)">
|
||||||
</MkInput>
|
</MkInput>
|
||||||
<button class="_button" @click="remove(i)">
|
<button class="_button" @click="remove(i)">
|
||||||
<i class="fas fa-times"></i>
|
<i class="fas fa-times"></i>
|
||||||
|
@ -17,25 +17,25 @@
|
||||||
<MkSwitch v-model="multiple">{{ $ts._poll.canMultipleVote }}</MkSwitch>
|
<MkSwitch v-model="multiple">{{ $ts._poll.canMultipleVote }}</MkSwitch>
|
||||||
<section>
|
<section>
|
||||||
<div>
|
<div>
|
||||||
<MkSelect v-model="expiration">
|
<MkSelect v-model="expiration" small>
|
||||||
<template #label>{{ $ts._poll.expiration }}</template>
|
<template #label>{{ $ts._poll.expiration }}</template>
|
||||||
<option value="infinite">{{ $ts._poll.infinite }}</option>
|
<option value="infinite">{{ $ts._poll.infinite }}</option>
|
||||||
<option value="at">{{ $ts._poll.at }}</option>
|
<option value="at">{{ $ts._poll.at }}</option>
|
||||||
<option value="after">{{ $ts._poll.after }}</option>
|
<option value="after">{{ $ts._poll.after }}</option>
|
||||||
</MkSelect>
|
</MkSelect>
|
||||||
<section v-if="expiration === 'at'">
|
<section v-if="expiration === 'at'">
|
||||||
<MkInput v-model="atDate" type="date" class="input">
|
<MkInput v-model="atDate" small type="date" class="input">
|
||||||
<template #label>{{ $ts._poll.deadlineDate }}</template>
|
<template #label>{{ $ts._poll.deadlineDate }}</template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
<MkInput v-model="atTime" type="time" class="input">
|
<MkInput v-model="atTime" small type="time" class="input">
|
||||||
<template #label>{{ $ts._poll.deadlineTime }}</template>
|
<template #label>{{ $ts._poll.deadlineTime }}</template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
</section>
|
</section>
|
||||||
<section v-else-if="expiration === 'after'">
|
<section v-else-if="expiration === 'after'">
|
||||||
<MkInput v-model="after" type="number" class="input">
|
<MkInput v-model="after" small type="number" class="input">
|
||||||
<template #label>{{ $ts._poll.duration }}</template>
|
<template #label>{{ $ts._poll.duration }}</template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
<MkSelect v-model="unit">
|
<MkSelect v-model="unit" small>
|
||||||
<option value="second">{{ $ts._time.second }}</option>
|
<option value="second">{{ $ts._time.second }}</option>
|
||||||
<option value="minute">{{ $ts._time.minute }}</option>
|
<option value="minute">{{ $ts._time.minute }}</option>
|
||||||
<option value="hour">{{ $ts._time.hour }}</option>
|
<option value="hour">{{ $ts._time.hour }}</option>
|
||||||
|
@ -49,12 +49,12 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import { addTime } from '@/scripts/time';
|
|
||||||
import { formatDateTimeString } from '@/scripts/format-time-string';
|
|
||||||
import MkInput from './form/input.vue';
|
import MkInput from './form/input.vue';
|
||||||
import MkSelect from './form/select.vue';
|
import MkSelect from './form/select.vue';
|
||||||
import MkSwitch from './form/switch.vue';
|
import MkSwitch from './form/switch.vue';
|
||||||
import MkButton from './ui/button.vue';
|
import MkButton from './ui/button.vue';
|
||||||
|
import { formatDateTimeString } from '@/scripts/format-time-string';
|
||||||
|
import { addTime } from '@/scripts/time';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
@ -129,7 +129,7 @@ function get() {
|
||||||
...(
|
...(
|
||||||
expiration.value === 'at' ? { expiresAt: calcAt() } :
|
expiration.value === 'at' ? { expiresAt: calcAt() } :
|
||||||
expiration.value === 'after' ? { expiredAfter: calcAfter() } : {}
|
expiration.value === 'after' ? { expiredAfter: calcAfter() } : {}
|
||||||
)
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="_formRoot">
|
<div class="_formRoot root">
|
||||||
<div v-adaptive-border class="rfqxtzch _panel _formBlock">
|
<div v-adaptive-border class="rfqxtzch _panel _formBlock">
|
||||||
<div class="toggle">
|
<div class="toggle">
|
||||||
<div class="toggleWrapper">
|
<div class="toggleWrapper">
|
||||||
|
@ -26,18 +26,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-if="darkMode">
|
<div class="selects _formBlock">
|
||||||
<FormSelect v-model="darkThemeId" class="_formBlock">
|
<FormSelect v-model="lightThemeId" large class="select">
|
||||||
<template #label>{{ $ts.themeForDarkMode }}</template>
|
|
||||||
<template #prefix><i class="fas fa-moon"></i></template>
|
|
||||||
<optgroup :label="$ts.darkThemes">
|
|
||||||
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
|
||||||
</optgroup>
|
|
||||||
<optgroup :label="$ts.lightThemes">
|
|
||||||
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
|
||||||
</optgroup>
|
|
||||||
</FormSelect>
|
|
||||||
<FormSelect v-model="lightThemeId" class="_formBlock">
|
|
||||||
<template #label>{{ $ts.themeForLightMode }}</template>
|
<template #label>{{ $ts.themeForLightMode }}</template>
|
||||||
<template #prefix><i class="fas fa-sun"></i></template>
|
<template #prefix><i class="fas fa-sun"></i></template>
|
||||||
<optgroup :label="$ts.lightThemes">
|
<optgroup :label="$ts.lightThemes">
|
||||||
|
@ -47,19 +37,7 @@
|
||||||
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</FormSelect>
|
</FormSelect>
|
||||||
</template>
|
<FormSelect v-model="darkThemeId" large class="select">
|
||||||
<template v-else>
|
|
||||||
<FormSelect v-model="lightThemeId" class="_formBlock">
|
|
||||||
<template #label>{{ $ts.themeForLightMode }}</template>
|
|
||||||
<template #prefix><i class="fas fa-sun"></i></template>
|
|
||||||
<optgroup :label="$ts.lightThemes">
|
|
||||||
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
|
||||||
</optgroup>
|
|
||||||
<optgroup :label="$ts.darkThemes">
|
|
||||||
<option v-for="x in darkThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
|
||||||
</optgroup>
|
|
||||||
</FormSelect>
|
|
||||||
<FormSelect v-model="darkThemeId" class="_formBlock">
|
|
||||||
<template #label>{{ $ts.themeForDarkMode }}</template>
|
<template #label>{{ $ts.themeForDarkMode }}</template>
|
||||||
<template #prefix><i class="fas fa-moon"></i></template>
|
<template #prefix><i class="fas fa-moon"></i></template>
|
||||||
<optgroup :label="$ts.darkThemes">
|
<optgroup :label="$ts.darkThemes">
|
||||||
|
@ -69,7 +47,7 @@
|
||||||
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
<option v-for="x in lightThemes" :key="x.id" :value="x.id">{{ x.name }}</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</FormSelect>
|
</FormSelect>
|
||||||
</template>
|
</div>
|
||||||
|
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<div class="_formLinksGrid">
|
<div class="_formLinksGrid">
|
||||||
|
@ -406,4 +384,17 @@ definePageMetadata({
|
||||||
border-top: solid 0.5px var(--divider);
|
border-top: solid 0.5px var(--divider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.root {
|
||||||
|
> .selects {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--margin);
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
> .select {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 280px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue