frontend/src/views/CollectionView/CollectionToolbar.vue
2025-09-25 20:04:27 +03:00

100 lines
1.7 KiB
Vue

<script setup>
import { ref, watch } from 'vue'
import router from '@/router/index.js'
const value = ref(null)
const options = [
{ label: 'Placeholder 1', value: 'Placeholder 1' },
{ label: 'Placeholder 2', value: 'Placeholder 2' },
]
const addMerch = () => {
router.push({ name: 'addMerch' })
}
const props = defineProps({
modelValue: {
type: String,
default: '',
},
})
const emit = defineEmits(['update:modelValue'])
const localValue = ref(props.modelValue)
watch(
() => props.modelValue,
(newVal) => {
localValue.value = newVal
}
)
watch(localValue, (newVal) => {
emit('update:modelValue', newVal)
})
</script>
<template>
<div class="toolbar">
<n-button type="primary" class="toolbar-item" @click="addMerch"> Add merch </n-button>
<div class="search-wrapper toolbar-item">
<n-input v-model:value="localValue" placeholder="Search..." clearable />
</div>
<div class="selector toolbar-item">
<n-select
placeholder="Select label"
clearable
multiple
v-model:value="value"
:options="options"
class="mobile-full-width" />
</div>
</div>
</template>
<style scoped>
.toolbar {
display: flex;
align-items: center;
gap: 16px;
padding: 16px;
background-color: #f5f5f5;
border-bottom: 1px solid #e0e0e0;
border-radius: 8px;
flex-wrap: wrap;
}
.toolbar-item {
flex-shrink: 0;
}
.search-wrapper {
flex-grow: 1;
min-width: 200px;
}
.selector {
min-width: 220px;
}
@media (max-width: 768px) {
.selector {
flex-basis: 100%;
margin-left: auto;
}
}
@media (max-width: 768px) {
.search-wrapper {
flex-basis: 100%;
}
}
:deep(.mobile-full-width) {
width: 100%;
}
</style>