select 대체 ChipSelect 컴포넌트(cols 지원) 신설. 계좌 선택 드롭다운을 칩(한 줄 2개)으로 교체: - AccountView 출금·입금·상환대상 계좌 - RecurringView 출금·입금 계좌 계좌 종류 뱃지로 이미 걸러지고 무료 한도(종류별 2개)라 칩 수도 적당. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<script setup>
|
||||
// select 대체 칩 선택기. 선택지가 적을 때(계좌 등) 드롭다운 대신 칩으로 노출.
|
||||
// 사용: <ChipSelect v-model="form.walletId" :options="[{value,label}]" :disabled="..." />
|
||||
defineProps({
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
options: { type: Array, default: () => [] }, // [{ value, label }]
|
||||
disabled: { type: Boolean, default: false },
|
||||
emptyText: { type: String, default: '선택할 항목이 없습니다' },
|
||||
cols: { type: Number, default: 0 }, // 0=자유 줄바꿈, N=한 줄에 N개(그리드)
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
function pick(v, disabled) {
|
||||
if (disabled) return
|
||||
emit('update:modelValue', v)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="chip-select"
|
||||
:class="{ grid: cols > 0 }"
|
||||
:style="cols > 0 ? { gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))` } : null"
|
||||
>
|
||||
<button
|
||||
v-for="o in options"
|
||||
:key="String(o.value)"
|
||||
type="button"
|
||||
class="cs-chip"
|
||||
:class="{ active: modelValue === o.value }"
|
||||
:disabled="disabled"
|
||||
@click="pick(o.value, disabled)"
|
||||
>
|
||||
{{ o.label }}
|
||||
</button>
|
||||
<span v-if="!options.length" class="cs-empty">{{ emptyText }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.chip-select {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
.chip-select.grid {
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
.chip-select.grid .cs-chip {
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cs-chip {
|
||||
padding: 0.28rem 0.75rem;
|
||||
border: 1.5px solid var(--color-border);
|
||||
border-radius: 100px;
|
||||
background: var(--color-background-soft);
|
||||
color: var(--color-text);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
line-height: 1.4;
|
||||
transition:
|
||||
border-color 0.12s,
|
||||
background 0.12s,
|
||||
color 0.12s;
|
||||
}
|
||||
.cs-chip:disabled {
|
||||
opacity: 0.45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.cs-chip.active {
|
||||
border-color: hsla(160, 100%, 37%, 1);
|
||||
background: hsla(160, 100%, 37%, 1);
|
||||
color: #fff;
|
||||
}
|
||||
.cs-empty {
|
||||
font-size: 0.82rem;
|
||||
opacity: 0.55;
|
||||
padding: 0.28rem 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user