add: subheader
Subheader for dynamic content
This commit is contained in:
parent
4b07ebb2ec
commit
1bd69c9c97
6 changed files with 259 additions and 101 deletions
|
@ -102,7 +102,6 @@
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
scale: 1.2;
|
scale: 1.2;
|
||||||
--background: var(--color-light);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
.Header {
|
.Header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 100;
|
||||||
|
background: var(--color-main-darkest);
|
||||||
|
|
||||||
|
& header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: var(--padding-default);
|
padding: var(--padding-default);
|
||||||
background: var(--color-main-darkest);
|
padding-bottom: 0;
|
||||||
position: sticky;
|
|
||||||
top: 0;
|
|
||||||
z-index: 100;
|
|
||||||
font-family: 'Roboto', sans-serif;
|
font-family: 'Roboto', sans-serif;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
||||||
|
@ -55,3 +58,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -22,7 +22,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-bar {
|
.search-bar {
|
||||||
|
z-index: 100;
|
||||||
padding: 0 1rem 1rem 1rem;
|
padding: 0 1rem 1rem 1rem;
|
||||||
|
|
||||||
|
& p {
|
||||||
|
font-family: 'Roboto Condensed', sans-serif;
|
||||||
|
font-weight: lighter;
|
||||||
|
color: var(--color-lightest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<header class="Header">
|
<div class="Header">
|
||||||
|
<header>
|
||||||
<NuxtLink class="header-text" to="/">
|
<NuxtLink class="header-text" to="/">
|
||||||
ProPapier
|
ProPapier
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
@ -17,6 +18,8 @@
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
<div id="subheader" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
|
@ -12,13 +12,11 @@
|
||||||
:current-card-index="currentCardIndex"
|
:current-card-index="currentCardIndex"
|
||||||
@update="updateCard()"
|
@update="updateCard()"
|
||||||
/>
|
/>
|
||||||
|
<Teleport to="#subheader">
|
||||||
<div class="search-bar">
|
<div class="search-bar">
|
||||||
<PpFormSearch
|
<p>Preise. Schnell. Unkompliziert.</p>
|
||||||
v-model="search"
|
|
||||||
label="Suche nach Klopapier!"
|
|
||||||
id="search_field"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
</Teleport>
|
||||||
<section class="content flex-col">
|
<section class="content flex-col">
|
||||||
<aside class="filter-bar">
|
<aside class="filter-bar">
|
||||||
<button v-for="(button, index) in filterButtons" @click="() => sort(index)" :class="{ 'active': button.active }">
|
<button v-for="(button, index) in filterButtons" @click="() => sort(index)" :class="{ 'active': button.active }">
|
||||||
|
@ -38,15 +36,6 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<PpToolbar>
|
<PpToolbar>
|
||||||
<PpButton class="mini-button text-white transparent" @click="sort(currentSort)">
|
|
||||||
<Icon class="icon" name="uil:refresh" mode="svg" />
|
|
||||||
<span>Neu sortieren</span>
|
|
||||||
<span
|
|
||||||
class="dot"
|
|
||||||
:class="{ visible : isDirty}"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
</PpButton>
|
|
||||||
<PpButton class="mini-button text-white transparent" @click="openModal(true, -1)">
|
<PpButton class="mini-button text-white transparent" @click="openModal(true, -1)">
|
||||||
<Icon class="icon" name="uil:plus" mode="svg" />
|
<Icon class="icon" name="uil:plus" mode="svg" />
|
||||||
<span>Hinzufügen</span>
|
<span>Hinzufügen</span>
|
||||||
|
@ -63,15 +52,12 @@ import { PpPriceCardDialog, PpDeleteDialog, PpPriceCard } from '#components'
|
||||||
|
|
||||||
const cards = useLocalStorage<Card[]>('cards', [])
|
const cards = useLocalStorage<Card[]>('cards', [])
|
||||||
const currentSort = useLocalStorage<number>('sort', 0)
|
const currentSort = useLocalStorage<number>('sort', 0)
|
||||||
const isDirty = ref(false)
|
|
||||||
const currentCard = ref<Card>()
|
const currentCard = ref<Card>()
|
||||||
const currentCardIndex = ref<number>(-1)
|
const currentCardIndex = ref<number>(-1)
|
||||||
const modal = useTemplateRef<typeof PpPriceCardDialog>('modal')
|
const modal = useTemplateRef<typeof PpPriceCardDialog>('modal')
|
||||||
const deleteModal = useTemplateRef<typeof PpDeleteDialog>('deleteModal')
|
const deleteModal = useTemplateRef<typeof PpDeleteDialog>('deleteModal')
|
||||||
const priceCards = useTemplateRef<(typeof PpPriceCard)[]>('priceCard')
|
const priceCards = useTemplateRef<(typeof PpPriceCard)[]>('priceCard')
|
||||||
|
|
||||||
const search = ref('')
|
|
||||||
|
|
||||||
const createCard = (uuid : string) : Card => ({
|
const createCard = (uuid : string) : Card => ({
|
||||||
uuid,
|
uuid,
|
||||||
name: '',
|
name: '',
|
||||||
|
@ -84,12 +70,12 @@ const createCard = (uuid : string) : Card => ({
|
||||||
|
|
||||||
const addCard = (card : Card) => {
|
const addCard = (card : Card) => {
|
||||||
cards.value.unshift({ ...card })
|
cards.value.unshift({ ...card })
|
||||||
isDirty.value = true
|
sort()
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeCard = (index : number) => {
|
const removeCard = (index : number) => {
|
||||||
cards.value.splice(index, 1)
|
cards.value.splice(index, 1)
|
||||||
isDirty.value = true
|
sort()
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateCard = () => {
|
const updateCard = () => {
|
||||||
|
@ -100,7 +86,7 @@ const updateCard = () => {
|
||||||
|
|
||||||
const newCard = { ...currentCard.value! }
|
const newCard = { ...currentCard.value! }
|
||||||
cards.value.splice(currentCardIndex.value, 1, newCard)
|
cards.value.splice(currentCardIndex.value, 1, newCard)
|
||||||
isDirty.value = true
|
sort()
|
||||||
}
|
}
|
||||||
|
|
||||||
const openModal = (createNew : boolean, index : number) => {
|
const openModal = (createNew : boolean, index : number) => {
|
||||||
|
@ -149,23 +135,17 @@ const sortBy = (key : 'ppr' | 'pps' | 'ppl') => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const sort = (index : number) => {
|
const sort = async (index : number = currentSort.value) => {
|
||||||
currentSort.value = index
|
currentSort.value = index
|
||||||
filterButtons.value.forEach(button => { button.active = false })
|
filterButtons.value.forEach(button => { button.active = false })
|
||||||
filterButtons.value[index]!.active = true
|
filterButtons.value[index]!.active = true
|
||||||
|
|
||||||
switch (index) {
|
await nextTick()
|
||||||
case 0:
|
|
||||||
sortBy('ppr')
|
|
||||||
break
|
|
||||||
case 1:
|
|
||||||
sortBy('pps')
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
sortBy('ppl')
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
isDirty.value = false
|
switch (index) {
|
||||||
|
case 0: return sortBy('ppr')
|
||||||
|
case 1: return sortBy('pps')
|
||||||
|
case 2: return sortBy('ppl')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
165
app/pages/other.vue
Normal file
165
app/pages/other.vue
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<ClientOnly>
|
||||||
|
<PpDeleteDialog
|
||||||
|
ref="deleteModal"
|
||||||
|
:current-card-index="currentCardIndex"
|
||||||
|
@delete="removeCard(currentCardIndex)"
|
||||||
|
/>
|
||||||
|
<PpPriceCardDialog
|
||||||
|
ref="modal"
|
||||||
|
:current-card="currentCard"
|
||||||
|
:current-card-index="currentCardIndex"
|
||||||
|
@update="updateCard()"
|
||||||
|
/>
|
||||||
|
<div class="search-bar">
|
||||||
|
<PpFormSearch
|
||||||
|
v-model="search"
|
||||||
|
label="Suche nach Klopapier!"
|
||||||
|
id="search_field"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<section class="content flex-col">
|
||||||
|
<aside class="filter-bar">
|
||||||
|
<button v-for="(button, index) in filterButtons" @click="() => sort(index)" :class="{ 'active': button.active }">
|
||||||
|
{{ button.label }}
|
||||||
|
</button>
|
||||||
|
</aside>
|
||||||
|
<div class="flex-col" role="list">
|
||||||
|
<PpPriceCard
|
||||||
|
ref="priceCard"
|
||||||
|
v-for="(card, index) in cards"
|
||||||
|
:key="card.uuid"
|
||||||
|
:deletable="cards.length > 1"
|
||||||
|
:card="card"
|
||||||
|
@update="openModal(false, index)"
|
||||||
|
@remove="openDeleteModal()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<PpToolbar>
|
||||||
|
<PpButton class="mini-button text-white transparent" @click="sort(currentSort)">
|
||||||
|
<Icon class="icon" name="uil:refresh" mode="svg" />
|
||||||
|
<span>Neu sortieren</span>
|
||||||
|
<span
|
||||||
|
class="dot"
|
||||||
|
:class="{ visible : isDirty}"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</PpButton>
|
||||||
|
<PpButton class="mini-button text-white transparent" @click="openModal(true, -1)">
|
||||||
|
<Icon class="icon" name="uil:plus" mode="svg" />
|
||||||
|
<span>Hinzufügen</span>
|
||||||
|
</PpButton>
|
||||||
|
</PpToolbar>
|
||||||
|
</ClientOnly>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { Card } from '../../shared/Card'
|
||||||
|
import type { Button } from '../../shared/ButtonGroup'
|
||||||
|
import { PpPriceCardDialog, PpDeleteDialog, PpPriceCard } from '#components'
|
||||||
|
|
||||||
|
const cards = useLocalStorage<Card[]>('cards', [])
|
||||||
|
const currentSort = useLocalStorage<number>('sort', 0)
|
||||||
|
const isDirty = ref(false)
|
||||||
|
const currentCard = ref<Card>()
|
||||||
|
const currentCardIndex = ref<number>(-1)
|
||||||
|
const modal = useTemplateRef<typeof PpPriceCardDialog>('modal')
|
||||||
|
const deleteModal = useTemplateRef<typeof PpDeleteDialog>('deleteModal')
|
||||||
|
const priceCards = useTemplateRef<(typeof PpPriceCard)[]>('priceCard')
|
||||||
|
|
||||||
|
const search = ref('')
|
||||||
|
|
||||||
|
const createCard = (uuid : string) : Card => ({
|
||||||
|
uuid,
|
||||||
|
name: '',
|
||||||
|
price: '',
|
||||||
|
roles: '',
|
||||||
|
sheets: '',
|
||||||
|
layers: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const addCard = (card : Card) => {
|
||||||
|
cards.value.unshift({ ...card })
|
||||||
|
isDirty.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeCard = (index : number) => {
|
||||||
|
cards.value.splice(index, 1)
|
||||||
|
isDirty.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateCard = () => {
|
||||||
|
if (currentCardIndex.value === -1) {
|
||||||
|
addCard(currentCard.value!)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const newCard = { ...currentCard.value! }
|
||||||
|
cards.value.splice(currentCardIndex.value, 1, newCard)
|
||||||
|
isDirty.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const openModal = (createNew : boolean, index : number) => {
|
||||||
|
if (createNew) {
|
||||||
|
currentCardIndex.value = -1
|
||||||
|
currentCard.value = createCard(randomUUID())
|
||||||
|
modal.value?.$el.showModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentCardIndex.value = index
|
||||||
|
currentCard.value = { ...cards.value[index]! }
|
||||||
|
|
||||||
|
modal.value?.$el.showModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const openDeleteModal = () => {
|
||||||
|
deleteModal.value?.$el.showModal()
|
||||||
|
}
|
||||||
|
|
||||||
|
const filterButtons = ref<Button[]>([
|
||||||
|
{
|
||||||
|
label: 'Rollen',
|
||||||
|
icon: 'uil:toilet-paper',
|
||||||
|
active: currentSort.value === 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Blatt',
|
||||||
|
icon: 'uil:file-landscape',
|
||||||
|
active: currentSort.value === 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Lagen',
|
||||||
|
icon: 'uil:layer-group',
|
||||||
|
active: currentSort.value === 2,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
const sortBy = (key : 'ppr' | 'pps' | 'ppl') => {
|
||||||
|
cards.value.sort((a, b) => {
|
||||||
|
const aCard = priceCards.value?.find(card => card.uuid === a.uuid) || null
|
||||||
|
const bCard = priceCards.value?.find(card => card.uuid === b.uuid) || null
|
||||||
|
if (!aCard || !bCard) return 0
|
||||||
|
return aCard[key] - bCard[key]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const sort = (index : number) => {
|
||||||
|
currentSort.value = index
|
||||||
|
filterButtons.value.forEach(button => { button.active = false })
|
||||||
|
filterButtons.value[index]!.active = true
|
||||||
|
|
||||||
|
isDirty.value = false
|
||||||
|
|
||||||
|
switch (index) {
|
||||||
|
case 0: return sortBy('ppr')
|
||||||
|
case 1: return sortBy('pps')
|
||||||
|
case 2: return sortBy('ppl')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue