Add entering transition on Shop and fix some styling

- Center intro title vertically
- Cart item styling tweaks
- Add cart button quantity label inside of button so it's clickable
This commit is contained in:
2021-12-06 22:14:02 +01:00
parent 9da5ae55cd
commit f15a2f2e47
7 changed files with 72 additions and 15 deletions

View File

@@ -14,9 +14,8 @@
<div class="button-cart"> <div class="button-cart">
<ButtonCircle color="purple" on:click={openCart}> <ButtonCircle color="purple" on:click={openCart}>
<Icon icon="bag" label="Cart icon" /> <Icon icon="bag" label="Cart icon" />
</ButtonCircle>
{#if $cartAmount > 0} {#if $cartAmount > 0}
<span class="quantity" transition:scale={{ start: 0.6, duration: 400, easing: quartOut }}>{$cartAmount}</span> <span class="quantity" transition:scale={{ start: 0.6, duration: 400, easing: quartOut }}>{$cartAmount}</span>
{/if} {/if}
</ButtonCircle>
</div> </div>

View File

@@ -30,7 +30,10 @@
</div> </div>
<div class="cart-item__right"> <div class="cart-item__right">
<h3>Poster</h3> <h3>Poster</h3>
<p>{item.product.name} {item.price_total}</p> <p>
{item.product.name}
<br> {item.price}
</p>
{#if item && item.quantity} {#if item && item.quantity}
<Select <Select

View File

@@ -140,7 +140,7 @@
<div class="cart__content"> <div class="cart__content">
{#if $cartAmount > 0} {#if $cartAmount > 0}
{#each $cartData.items as item, index} {#each $cartData.items as item, index}
<CartItem {item} {index} <CartItem {item}
on:updatedQuantity={changedQuantity} on:updatedQuantity={changedQuantity}
on:removed={removedItem} on:removed={removedItem}
/> />
@@ -155,7 +155,7 @@
{/if} {/if}
{#if !$cartData || $cartIsUpdating} {#if !$cartData || $cartIsUpdating}
<div class="cart__update"> <div class="cart__update" transition:fade={{ duration: 400 }}>
<p>Updating…</p> <p>Updating…</p>
</div> </div>
{/if} {/if}

View File

@@ -1,6 +1,9 @@
<script lang="ts"> <script lang="ts">
import { browser } from '$app/env'
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { shopLocations, cartOpen, cartNotifications } from '$utils/stores/shop' import { shopLocations, cartOpen, cartNotifications } from '$utils/stores/shop'
import anime from 'animejs'
import type { AnimeTimelineInstance } from 'animejs'
// Components // Components
import Metas from '$components/Metas.svelte' import Metas from '$components/Metas.svelte'
import SiteTitle from '$components/atoms/SiteTitle.svelte' import SiteTitle from '$components/atoms/SiteTitle.svelte'
@@ -31,7 +34,45 @@
}) })
onMount(async () => { /**
* Transition: Anime timeline
*/
let timeline: AnimeTimelineInstance
if (browser) {
requestAnimationFrame(() => {
timeline = anime.timeline({
duration: 1600,
easing: 'easeOutQuart',
autoplay: false,
})
// Hero image
timeline.add({
targets: '.shop-page__background',
scale: [1.06, 1],
opacity: [0, 1],
duration: 2400,
}, 400)
// Intro top elements
timeline.add({
targets: '.shop-page__intro .top > *',
translateY: [-100, 0],
delay: anime.stagger(250),
}, 400)
// Intro navbar
timeline.add({
targets: '.shop-page__nav .container > *',
translateY: [100, 0],
delay: anime.stagger(250),
}, 700)
})
}
onMount(() => {
// Reveal the nav past the Intro // Reveal the nav past the Intro
navObserver = new IntersectionObserver(entries => { navObserver = new IntersectionObserver(entries => {
entries.forEach(entry => { entries.forEach(entry => {
@@ -43,6 +84,11 @@
}) })
navObserver.observe(introEl) navObserver.observe(introEl)
// Transition in
requestAnimationFrame(() => {
timeline.play()
})
// Destroy // Destroy
return () => { return () => {
@@ -96,6 +142,7 @@
</nav> </nav>
<Image <Image
class="shop-page__background"
id={shop.page_heroimage.id} id={shop.page_heroimage.id}
alt="photo" alt="photo"
sizeKey="hero" sizeKey="hero"

View File

@@ -8,6 +8,10 @@
margin-left: auto; margin-left: auto;
} }
button {
overflow: visible;
}
// Icon // Icon
svg { svg {
color: #fff; color: #fff;
@@ -20,18 +24,20 @@
// Quantity label // Quantity label
.quantity { .quantity {
position: absolute; position: absolute;
z-index: 2;
top: 50%; top: 50%;
left: -12px; left: 2px;
transform: translateY(-50%); transform: translate3d(-50%, -50%, 0);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 22px; width: 22px;
height: 22px; height: 22px;
font-size: rem(11px); font-size: rem(12px);
font-weight: 600; font-weight: 600;
color: #fff; color: #fff;
background-color: $color-secondary; background-color: $color-secondary;
border-radius: 100%; border-radius: 100%;
opacity: 1;
} }
} }

View File

@@ -39,6 +39,7 @@
&__right { &__right {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1;
// Poster Title // Poster Title
h3 { h3 {
@@ -52,7 +53,7 @@
} }
// Text // Text
p { p {
max-width: 124px; max-width: 152px;
margin: 8px 0 20px; margin: 8px 0 20px;
font-size: rem(12px); font-size: rem(12px);
line-height: 1.4; line-height: 1.4;
@@ -68,7 +69,7 @@
align-items: center; align-items: center;
height: 28px; height: 28px;
margin-right: auto; margin-right: auto;
padding: 0 12px; padding: 2px 12px 0;
border: 1px solid rgba($color-lightgray, 0.3); border: 1px solid rgba($color-lightgray, 0.3);
border-radius: 100vh; border-radius: 100vh;
cursor: pointer; cursor: pointer;

View File

@@ -80,13 +80,14 @@
@include bp (sm) { @include bp (sm) {
top: clamp(#{rem(40px)}, 16vw, #{rem(144px)}); // top: clamp(#{rem(40px)}, 16vw, #{rem(144px)});
top: 40%;
left: 0; left: 0;
font-size: clamp(#{rem(40px)}, 8vw, #{rem(96px)}); font-size: clamp(#{rem(40px)}, 8vw, #{rem(96px)});
transform: none; transform: none;
} }
@include bp (md) { @include bp (md) {
top: clamp(#{rem(40px)}, 10vw, #{rem(96px)}); // top: clamp(#{rem(40px)}, 10vw, #{rem(96px)});
font-size: clamp(#{rem(40px)}, 6vw, #{rem(96px)}); font-size: clamp(#{rem(40px)}, 6vw, #{rem(96px)});
} }