исправление: читаемость при свайпе и стеклянный выпадающий список
- MessageListItem: добавлен непрозрачный тёмный фон (.message-item), письмо теперь скользит как карточка поверх цветного фона действия - CustomSelect: новый кастомный компонент вместо нативного <select>, триггер в стиле glass-pill, выпадающий список с blur/saturate, галочка на активном пункте, закрытие по клику вне - SettingsView: нативные <select> заменены на <CustomSelect> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
03e3276a9a
commit
6fc0cb939c
3 changed files with 219 additions and 42 deletions
211
src/renderer/src/components/CustomSelect.vue
Normal file
211
src/renderer/src/components/CustomSelect.vue
Normal file
|
|
@ -0,0 +1,211 @@
|
||||||
|
<script setup lang="ts" generic="T extends string">
|
||||||
|
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: T
|
||||||
|
options: { value: T; label: string }[]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: T]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const open = ref(false)
|
||||||
|
const triggerRef = ref<HTMLElement>()
|
||||||
|
const dropdownRef = ref<HTMLElement>()
|
||||||
|
const dropdownStyle = ref<Record<string, string>>({})
|
||||||
|
|
||||||
|
const selectedLabel = computed(
|
||||||
|
() => props.options.find((o) => o.value === props.modelValue)?.label ?? ''
|
||||||
|
)
|
||||||
|
|
||||||
|
function select(value: T): void {
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
open.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(open, async (val) => {
|
||||||
|
if (!val) return
|
||||||
|
await nextTick()
|
||||||
|
if (!triggerRef.value) return
|
||||||
|
const r = triggerRef.value.getBoundingClientRect()
|
||||||
|
dropdownStyle.value = {
|
||||||
|
position: 'fixed',
|
||||||
|
top: `${r.bottom + 4}px`,
|
||||||
|
left: `${r.left}px`,
|
||||||
|
minWidth: `${r.width}px`,
|
||||||
|
zIndex: '9999',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function onDocClick(e: MouseEvent): void {
|
||||||
|
const target = e.target as Node
|
||||||
|
if (!triggerRef.value?.contains(target) && !dropdownRef.value?.contains(target)) {
|
||||||
|
open.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => document.addEventListener('mousedown', onDocClick))
|
||||||
|
onUnmounted(() => document.removeEventListener('mousedown', onDocClick))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="custom-select" :class="{ open }">
|
||||||
|
<button
|
||||||
|
ref="triggerRef"
|
||||||
|
class="select-trigger"
|
||||||
|
type="button"
|
||||||
|
@click="open = !open"
|
||||||
|
>
|
||||||
|
<span class="select-value">{{ selectedLabel }}</span>
|
||||||
|
<span class="select-arrow" :class="{ rotated: open }">
|
||||||
|
<svg viewBox="0 0 16 16" width="12" height="12" fill="none"
|
||||||
|
stroke="currentColor" stroke-width="1.75"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<polyline points="4,6 8,10 12,6" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<Teleport to="body">
|
||||||
|
<div
|
||||||
|
v-if="open"
|
||||||
|
ref="dropdownRef"
|
||||||
|
class="select-dropdown"
|
||||||
|
:style="dropdownStyle"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-for="opt in options"
|
||||||
|
:key="opt.value"
|
||||||
|
class="select-option"
|
||||||
|
:class="{ active: opt.value === modelValue }"
|
||||||
|
type="button"
|
||||||
|
@click="select(opt.value)"
|
||||||
|
>
|
||||||
|
<span class="option-check">
|
||||||
|
<svg v-if="opt.value === modelValue" viewBox="0 0 16 16" width="10" height="10"
|
||||||
|
fill="none" stroke="currentColor" stroke-width="2.5"
|
||||||
|
stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<polyline points="3,8 6.5,12 13,4" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
{{ opt.label }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</Teleport>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.custom-select {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-trigger {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.08),
|
||||||
|
0 2px 6px rgba(0, 0, 0, 0.15);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
-webkit-backdrop-filter: blur(12px);
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
min-width: 200px;
|
||||||
|
transition:
|
||||||
|
background var(--transition-fast),
|
||||||
|
border-color var(--transition-fast),
|
||||||
|
box-shadow var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-trigger:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.09);
|
||||||
|
border-color: rgba(255, 255, 255, 0.16);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.1),
|
||||||
|
0 3px 10px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.open .select-trigger {
|
||||||
|
background: rgba(255, 255, 255, 0.09);
|
||||||
|
border-color: color-mix(in srgb, var(--accent) 40%, transparent);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.1),
|
||||||
|
0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-value {
|
||||||
|
flex: 1;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-arrow {
|
||||||
|
color: var(--text-muted);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
transition: transform var(--transition-fast);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-arrow.rotated {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- Dropdown телепортируется в body — scoped не работает, нужны глобальные стили -->
|
||||||
|
<style>
|
||||||
|
.select-dropdown {
|
||||||
|
background: rgba(18, 18, 26, 0.82);
|
||||||
|
backdrop-filter: blur(32px) saturate(1.8);
|
||||||
|
-webkit-backdrop-filter: blur(32px) saturate(1.8);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.09),
|
||||||
|
0 8px 32px rgba(0, 0, 0, 0.55),
|
||||||
|
0 2px 8px rgba(0, 0, 0, 0.3);
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-option {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 7px 10px;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
transition: background 100ms ease, color 100ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-option:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: rgba(255, 255, 255, 0.92);
|
||||||
|
}
|
||||||
|
|
||||||
|
.select-option.active {
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.option-check {
|
||||||
|
width: 14px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -337,7 +337,8 @@ onUnmounted(() => {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 10px 10px 10px 4px;
|
padding: 10px 10px 10px 4px;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
background: transparent;
|
/* Непрозрачный тёмный фон — скользит как карточка поверх фона действия */
|
||||||
|
background: #0e0e15;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
touch-action: pan-y;
|
touch-action: pan-y;
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,15 @@
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useAccountsStore } from '../stores/accounts.store'
|
import { useAccountsStore } from '../stores/accounts.store'
|
||||||
import { useSettingsStore, SWIPE_ACTION_LABELS, ACCENT_QUICK_PICKS, type SwipeAction } from '../stores/settings.store'
|
import { useSettingsStore, SWIPE_ACTION_LABELS, ACCENT_QUICK_PICKS, type SwipeAction } from '../stores/settings.store'
|
||||||
|
import CustomSelect from '../components/CustomSelect.vue'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const accountsStore = useAccountsStore()
|
const accountsStore = useAccountsStore()
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
|
|
||||||
const swipeOptions: SwipeAction[] = ['delete', 'toggleRead', 'toggleFlag', 'none']
|
const swipeOptions: { value: SwipeAction; label: string }[] = (
|
||||||
|
['delete', 'toggleRead', 'toggleFlag', 'none'] as SwipeAction[]
|
||||||
|
).map((v) => ({ value: v, label: SWIPE_ACTION_LABELS[v] }))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -84,22 +87,14 @@ const swipeOptions: SwipeAction[] = ['delete', 'toggleRead', 'toggleFlag', 'none
|
||||||
<label class="setting-label">
|
<label class="setting-label">
|
||||||
<span class="swipe-dir">← Свайп влево</span>
|
<span class="swipe-dir">← Свайп влево</span>
|
||||||
</label>
|
</label>
|
||||||
<select v-model="settingsStore.swipeLeftAction" class="setting-select">
|
<CustomSelect v-model="settingsStore.swipeLeftAction" :options="swipeOptions" />
|
||||||
<option v-for="opt in swipeOptions" :key="opt" :value="opt">
|
|
||||||
{{ SWIPE_ACTION_LABELS[opt] }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<label class="setting-label">
|
<label class="setting-label">
|
||||||
<span class="swipe-dir">→ Свайп вправо</span>
|
<span class="swipe-dir">→ Свайп вправо</span>
|
||||||
</label>
|
</label>
|
||||||
<select v-model="settingsStore.swipeRightAction" class="setting-select">
|
<CustomSelect v-model="settingsStore.swipeRightAction" :options="swipeOptions" />
|
||||||
<option v-for="opt in swipeOptions" :key="opt" :value="opt">
|
|
||||||
{{ SWIPE_ACTION_LABELS[opt] }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -285,36 +280,6 @@ const swipeOptions: SwipeAction[] = ['delete', 'toggleRead', 'toggleFlag', 'none
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.setting-select {
|
|
||||||
background: rgba(255, 255, 255, 0.06);
|
|
||||||
color: var(--text-primary);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
padding: 6px 12px;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
min-width: 200px;
|
|
||||||
backdrop-filter: blur(12px);
|
|
||||||
-webkit-backdrop-filter: blur(12px);
|
|
||||||
box-shadow:
|
|
||||||
inset 0 1px 0 rgba(255, 255, 255, 0.08),
|
|
||||||
0 2px 6px rgba(0, 0, 0, 0.15);
|
|
||||||
transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
|
|
||||||
appearance: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-select:hover {
|
|
||||||
background: rgba(255, 255, 255, 0.09);
|
|
||||||
border-color: rgba(255, 255, 255, 0.16);
|
|
||||||
}
|
|
||||||
|
|
||||||
.setting-select:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: color-mix(in srgb, var(--accent) 55%, transparent);
|
|
||||||
box-shadow:
|
|
||||||
inset 0 1px 0 rgba(255, 255, 255, 0.09),
|
|
||||||
0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Color picker */
|
/* Color picker */
|
||||||
.color-picker-row {
|
.color-picker-row {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue