add: collapsing and deletion animation
Added collapsable cards and animation for deletion and card footer
This commit is contained in:
parent
c99c243dfc
commit
7c46be6227
6 changed files with 121 additions and 29 deletions
|
@ -1,5 +1,9 @@
|
||||||
.Button {
|
.Button {
|
||||||
--padding: .2rem;
|
--padding: .2rem;
|
||||||
|
--background: var(--color-main);
|
||||||
|
--color: var(--color-white);
|
||||||
|
--background-hover: var(--color-main-dark);
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -9,19 +13,26 @@
|
||||||
outline: none;
|
outline: none;
|
||||||
border: none;
|
border: none;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
color: var(--color);
|
||||||
|
|
||||||
&.cta {
|
&.cta {
|
||||||
background: var(--color-main);
|
background: var(--background);
|
||||||
color: var(--color-white);
|
color: var(--color);
|
||||||
padding: .5rem 1.5rem;
|
padding: .5rem 1.5rem;
|
||||||
border-radius: var(--radius-default);
|
border-radius: var(--radius-default);
|
||||||
box-shadow: var(--box-shadow-z2);
|
box-shadow: var(--box-shadow-z2);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: var(--color-main-dark);
|
background: var(--background-hover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.cta.white {
|
||||||
|
--background: var(--color-white);
|
||||||
|
--color: var(--color-main);
|
||||||
|
--background-hover: var(--color-grey);
|
||||||
|
}
|
||||||
|
|
||||||
&.icon-button {
|
&.icon-button {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: var(--padding);
|
padding: var(--padding);
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
--color-main-light: var(--color-blue-light);
|
--color-main-light: var(--color-blue-light);
|
||||||
--color-main-dark: var(--color-blue-dark);
|
--color-main-dark: var(--color-blue-dark);
|
||||||
|
|
||||||
|
--box-shadow-upper: 0 -3px 6px rgba(0,0,0,0.16), 0 -3px 6px rgba(0,0,0,0.23);
|
||||||
--box-shadow-z2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
|
--box-shadow-z2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
|
||||||
|
--box-shadow-inset: inset 0 3px 6px rgba(0,0,0,0.16), inset 0 3px 6px rgba(0,0,0,0.23);
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
@ -52,6 +54,11 @@ body {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flex-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
.text-white {
|
.text-white {
|
||||||
color: var(--color-white);
|
color: var(--color-white);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,60 @@
|
||||||
.PriceCard {
|
.PriceCard {
|
||||||
|
--height: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: grid;
|
||||||
|
transition: var(--transition-default);
|
||||||
|
grid-template-rows: auto 1fr auto;
|
||||||
|
height: var(--height);
|
||||||
|
|
||||||
|
&.deleting {
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.folded {
|
||||||
|
grid-template-rows: auto 0fr auto;
|
||||||
|
}
|
||||||
|
|
||||||
& > header {
|
& > header {
|
||||||
color: white;
|
color: var(--color-white);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
|
|
||||||
& > .Button {
|
& > .Button {
|
||||||
scale: 0;
|
|
||||||
color: var(--color-white);
|
color: var(--color-white);
|
||||||
border: 2px solid var(--color-white);
|
border: 2px solid var(--color-white);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
& aside {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
& footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
& > .Button.delete {
|
||||||
|
scale: 0;
|
||||||
|
}
|
||||||
|
|
||||||
& > .Button.deletable {
|
& > .Button.deletable {
|
||||||
scale: 1;
|
scale: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .padding {
|
& .padding {
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
padding: var(--padding-default);
|
padding: var(--padding-default);
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .bg-blue {
|
& .bg-blue {
|
||||||
background: var(--color-blue);
|
background: var(--color-blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .bg-white {
|
& .bg-white {
|
||||||
background: var(--color-white);
|
background: var(--color-white);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +66,7 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
& > * {
|
& > * {
|
||||||
flex-basis: 30%;
|
flex-basis: 25%;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
background: var(--color-main);
|
background: var(--color-main);
|
||||||
position: sticky;
|
position: sticky;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
box-shadow: var(--box-shadow-upper);
|
||||||
|
|
||||||
& > .Button {
|
& > .Button {
|
||||||
--padding: 1rem;
|
--padding: 1rem;
|
||||||
|
|
|
@ -1,27 +1,34 @@
|
||||||
<template>
|
<template>
|
||||||
<form class="PriceCard card">
|
<form
|
||||||
|
ref="root"
|
||||||
|
class="PriceCard card"
|
||||||
|
:class="{ folded }"
|
||||||
|
:style="{ '--height': height }"
|
||||||
|
@submit.prevent="() => {}"
|
||||||
|
>
|
||||||
<header class="padding bg-blue">
|
<header class="padding bg-blue">
|
||||||
TODO: IRGENDWAS
|
{{ name || 'Kein Name' }}
|
||||||
<PpButton
|
<PpButton
|
||||||
class="icon-button bg-main"
|
class="icon-button bg-main"
|
||||||
:class="[deletable && 'deletable']"
|
@click="folded = !folded"
|
||||||
@click="emit('remove', uid)"
|
|
||||||
>
|
>
|
||||||
<Icon name="uil:times" mode="svg" />
|
<Icon :name="folded ? 'uil:sort' : 'uil:sorting'" mode="svg" />
|
||||||
</PpButton>
|
</PpButton>
|
||||||
</header>
|
</header>
|
||||||
<div class="padding bg-blue flex-col">
|
<aside>
|
||||||
<div class="wrapper">
|
<div class="input-wrapper padding bg-blue flex-col">
|
||||||
<!-- <PpFormInput v-model="name" label="Name" id="n" :uid="uid" type="text" />-->
|
<div class="wrapper">
|
||||||
<PpFormInput v-model="price" label="Preis" id="p" :uid="uid" type="number" :min="0.01" @blur="calculate" />
|
<PpFormInput v-model="name" label="Name" id="n" :uid="uid" type="text" />
|
||||||
|
<PpFormInput v-model="price" label="Preis" id="p" :uid="uid" type="number" :min="0.01" @blur="calculate" />
|
||||||
|
</div>
|
||||||
|
<div class="wrapper">
|
||||||
|
<PpFormInput v-model="roles" label="Rollen" id="r" :uid="uid" type="number" :max="150" @blur="calculate" />
|
||||||
|
<PpFormInput v-model="sheets" label="Blätter" id="b" :uid="uid" type="number" :max="500" @blur="calculate" />
|
||||||
|
<PpFormInput v-model="layers" label="Lagen" id="l" :uid="uid" type="number" :max="10" @blur="calculate" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wrapper">
|
</aside>
|
||||||
<PpFormInput v-model="roles" label="Rollen" id="r" :uid="uid" type="number" :max="150" @blur="calculate" />
|
<main class="wrapper padding bg-white">
|
||||||
<PpFormInput v-model="sheets" label="Blätter" id="b" :uid="uid" type="number" :max="500" @blur="calculate" />
|
|
||||||
<PpFormInput v-model="layers" label="Lagen" id="l" :uid="uid" type="number" :max="10" @blur="calculate" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="wrapper padding bg-white">
|
|
||||||
<div class="info flex-col">
|
<div class="info flex-col">
|
||||||
<Icon class="icon" name="uil:toilet-paper" mode="svg" />
|
<Icon class="icon" name="uil:toilet-paper" mode="svg" />
|
||||||
<span class="price">{{ intl.format(ppr) }}</span>
|
<span class="price">{{ intl.format(ppr) }}</span>
|
||||||
|
@ -37,20 +44,42 @@
|
||||||
<span class="price">{{ intl.format(ppl) }}</span>
|
<span class="price">{{ intl.format(ppl) }}</span>
|
||||||
<span class="pro">Pro 100</span>
|
<span class="pro">Pro 100</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</main>
|
||||||
|
<footer class="padding bg-blue flex-row">
|
||||||
|
<PpButton
|
||||||
|
class="delete"
|
||||||
|
:class="{ deletable }"
|
||||||
|
@click="deleteCard"
|
||||||
|
>
|
||||||
|
<Icon name="uil:trash" mode="svg" />
|
||||||
|
Entfernen
|
||||||
|
</PpButton>
|
||||||
|
<PpButton class="cta white">
|
||||||
|
<Icon name="uil:qrcode-scan" mode="svg" />
|
||||||
|
Scan
|
||||||
|
</PpButton>
|
||||||
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { nextTick } from '@redocly/openapi-core/src/utils'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
uid: string
|
uid: string
|
||||||
deletable: boolean
|
deletable: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const { uid } = defineProps<Props>()
|
const { uid } = defineProps<Props>()
|
||||||
|
|
||||||
const emit = defineEmits(['remove'])
|
const emit = defineEmits(['remove'])
|
||||||
|
|
||||||
|
const root = ref<HTMLElement>()
|
||||||
|
const height = ref<string>()
|
||||||
|
const folded = ref(false)
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
})
|
||||||
|
|
||||||
const name = ref('')
|
const name = ref('')
|
||||||
const price = ref(0)
|
const price = ref(0)
|
||||||
const roles = ref(0)
|
const roles = ref(0)
|
||||||
|
@ -76,4 +105,14 @@ const calculate = () => {
|
||||||
if(!layers.value) return
|
if(!layers.value) return
|
||||||
ppl.value = (pps.value / layers.value) * 10
|
ppl.value = (pps.value / layers.value) * 10
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deleteCard = async () => {
|
||||||
|
root.value?.addEventListener('transitionend', () => {
|
||||||
|
emit('remove', uid)
|
||||||
|
})
|
||||||
|
|
||||||
|
height.value = `${root.value?.offsetHeight}px`
|
||||||
|
await nextTick()
|
||||||
|
root.value?.classList.add('deleting')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -23,14 +23,22 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const initialId = crypto.randomUUID()
|
const randomUUID = () => {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, char => {
|
||||||
|
const random = Math.random() * 16 | 0
|
||||||
|
const value = char === 'x' ? random : (random & 0x3 | 0x8)
|
||||||
|
return value.toString(16)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialId = randomUUID()
|
||||||
|
|
||||||
const cards = useState('cards', () => [
|
const cards = useState('cards', () => [
|
||||||
initialId,
|
initialId,
|
||||||
])
|
])
|
||||||
|
|
||||||
const addCard = () => {
|
const addCard = () => {
|
||||||
cards.value.push(crypto.randomUUID())
|
cards.value.push(randomUUID())
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeCard = (uuid : string) => {
|
const removeCard = (uuid : string) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue