Skip to content

Commit 1bbfe5f

Browse files
committed
颜色选择器添加清除按钮
1 parent 97492c6 commit 1bbfe5f

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

src/editor/inputs/subblocks/colorPicker.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<template>
2-
<s-text-field class="input monospace" label="颜色" v-model.trim="color">
2+
<s-text-field
3+
class="input monospace-inner"
4+
:label="t('data.more.color')"
5+
v-model.trim="color"
6+
>
7+
<Transition name="fade">
8+
<s-icon-button
9+
slot="end"
10+
class="colorpicker-button"
11+
v-if="color !== ''"
12+
@click="color = ''"
13+
>
14+
<s-icon name="close"></s-icon>
15+
</s-icon-button>
16+
</Transition>
317
<s-popup slot="end" ref="popup" @show="pickerKey = Symbol()">
418
<s-icon-button
519
slot="trigger"
@@ -26,6 +40,10 @@ import SIconPalette from "@/ui/icons/palette.vue";
2640
import { computed, ref } from "vue";
2741
import { ColorPicker } from "vue-color-kit";
2842
43+
import { useI18n } from "vue-i18n";
44+
import { I18nSchema } from "@/i18n";
45+
const { t } = useI18n<{ message: I18nSchema }>();
46+
2947
const color = defineModel<string>({ required: true });
3048
3149
interface ColorPickerArgs {
@@ -190,4 +208,15 @@ const pickerKey = ref(Symbol());
190208
}
191209
}
192210
}
211+
212+
.fade {
213+
&-enter-active,
214+
&-leave-active {
215+
transition: opacity 0.1s;
216+
}
217+
&-enter-from,
218+
&-leave-to {
219+
opacity: 0;
220+
}
221+
}
193222
</style>

src/editor/inputs/subblocks/function.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const isEmpty = computed(() => value.value === "");
2626
background-color: var(--s-color-surface-container-high);
2727
border-top-left-radius: 5px;
2828
border-top-right-radius: 5px;
29-
border-bottom: var(--s-color-outline) solid 0.1em;
29+
border-bottom: var(--s-color-outline-variant) solid 0.1em;
3030
transition:
3131
background-color 0.2s,
3232
border-bottom-color 0.2s;
@@ -48,6 +48,7 @@ const isEmpty = computed(() => value.value === "");
4848
caret-color: var(--s-color-primary);
4949
line-height: 1.2;
5050
z-index: 1;
51+
color:var(--s-color)
5152
}
5253
label {
5354
color: var(--s-color-outline);

src/public.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ input[type="number"] {
5151
}
5252

5353
.monospace,
54-
.monospace::part(input) {
54+
.monospace::part(input),
55+
.monospace-inner::part(input) {
5556
font-family: var(--font-mono);
5657
}
5758

0 commit comments

Comments
 (0)