Skip to content

Commit

Permalink
feat: プリセット管理ダイアログを編集可能にする (#2452)
Browse files Browse the repository at this point in the history
Co-authored-by: Hiroshiba <[email protected]>
Co-authored-by: Hiroshiba Kazuyuki <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 18, 2025
1 parent 8e4eb03 commit 6602613
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 106 deletions.
1 change: 1 addition & 0 deletions src/components/Base/BaseListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ defineEmits<{
border: none;
padding: vars.$padding-1 vars.$padding-2;
border-radius: vars.$radius-1;
text-align: left;
&:not(.selected):hover {
background-color: colors.$clear-hovered;
Expand Down
56 changes: 45 additions & 11 deletions src/components/Base/BaseSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:max
:step
:disabled
:modelValue="[model]"
:modelValue="[modelValue]"
@update:modelValue="
(value) => {
if (value == undefined) {
Expand All @@ -14,6 +14,8 @@
$emit('update:modelValue', value[0]);
}
"
@wheel="onWheel"
@valueCommit="$emit('valueCommit', $event[0])"
>
<SliderTrack class="SliderTrack">
<SliderRange class="SliderRange" />
Expand All @@ -24,20 +26,52 @@

<script setup lang="ts">
import { SliderRange, SliderRoot, SliderThumb, SliderTrack } from "radix-vue";
import { isOnCommandOrCtrlKeyDown } from "@/store/utility";
import { debounce } from "@/helpers/timer";
defineProps<{
min?: number;
max?: number;
step?: number;
disabled?: boolean;
modelValue: number;
}>();
const props = withDefaults(
defineProps<{
min?: number;
max?: number;
step?: number;
scrollStep?: number;
disabled?: boolean;
modelValue: number;
}>(),
{
min: 0,
max: 100,
step: 1,
scrollStep: undefined,
},
);
defineEmits<{
const emit = defineEmits<{
"update:modelValue": [value: number];
valueCommit: [value: number];
}>();
const model = defineModel<number>({ required: true });
const debounceEmitValueCommit = debounce(
(value: number) => emit("valueCommit", value),
300,
);
const onWheel = (event: WheelEvent) => {
if (props.disabled) return;
event.preventDefault();
const delta = event.deltaY > 0 ? -1 : 1;
const scrollStep =
props.scrollStep && !isOnCommandOrCtrlKeyDown(event)
? props.scrollStep
: props.step;
const value = props.modelValue + scrollStep * delta;
const clampedValue = Math.min(props.max, Math.max(props.min, value));
emit("update:modelValue", clampedValue);
debounceEmitValueCommit(clampedValue);
};
</script>

<style lang="scss">
Expand All @@ -49,7 +83,7 @@ const model = defineModel<number>({ required: true });
position: relative;
display: flex;
align-items: center;
height: vars.$size-control;
height: vars.$size-indicator;
cursor: grab;
&:active {
Expand Down
7 changes: 6 additions & 1 deletion src/components/Base/BaseTextField.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<template>
<div class="wrapper">
<input
:id
v-model="model"
type="text"
class="input"
:class="{ error: hasError }"
:placeholder
:readonly
:disabled
@change="(payload) => $emit('change', payload)"
@click="(payload) => $emit('click', payload)"
/>
<div v-if="hasError" class="error-label">
Expand All @@ -22,9 +24,11 @@ defineProps<{
hasError?: boolean;
readonly?: boolean;
disabled?: boolean;
id?: string;
}>();
defineEmits<{
change: [payload: Event];
click: [payload: MouseEvent];
}>();
Expand Down Expand Up @@ -66,7 +70,8 @@ const model = defineModel<string>();
}
.error {
border: 2px solid colors.$display-warning;
@include mixin.on-focus;
outline-color: colors.$display-warning !important;
}
.error-label {
Expand Down
Loading

0 comments on commit 6602613

Please sign in to comment.