Position Switcher for mobile and on Viewer
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Icon from '$components/atoms/Icon.svelte'
|
import Icon from '$components/atoms/Icon.svelte'
|
||||||
|
|
||||||
|
export let isOver: boolean = false
|
||||||
|
|
||||||
let switcherEl: HTMLElement
|
let switcherEl: HTMLElement
|
||||||
let isOpen = false
|
let isOpen = false
|
||||||
|
|
||||||
@@ -48,7 +50,10 @@
|
|||||||
|
|
||||||
<svelte:window on:click={windowClick} />
|
<svelte:window on:click={windowClick} />
|
||||||
|
|
||||||
<aside class="switcher" class:is-open={isOpen} bind:this={switcherEl}>
|
<aside class="switcher" bind:this={switcherEl}
|
||||||
|
class:is-open={isOpen}
|
||||||
|
class:is-over={isOver}
|
||||||
|
>
|
||||||
<nav class="switcher__links">
|
<nav class="switcher__links">
|
||||||
<ul>
|
<ul>
|
||||||
{#each links as { icon, iconLabel, url, text }}
|
{#each links as { icon, iconLabel, url, text }}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Switcher />
|
<Switcher isOver={!!$page.params.location && !!$page.params.photo} />
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,32 @@
|
|||||||
.switcher {
|
.switcher {
|
||||||
|
--offset: 16px;
|
||||||
|
--button-size: 44px;
|
||||||
$shadow-color: rgba(0, 0, 0, 0.05);
|
$shadow-color: rgba(0, 0, 0, 0.05);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 101;
|
z-index: 101;
|
||||||
bottom: 16px;
|
bottom: var(--offset);
|
||||||
left: 16px;
|
left: var(--offset);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
@include bp (sm) {
|
@include bp (sm) {
|
||||||
bottom: 20px;
|
--offset: 20px;
|
||||||
left: 20px;
|
|
||||||
}
|
}
|
||||||
@include bp (md) {
|
@include bp (md) {
|
||||||
bottom: 40px;
|
--offset: 40px;
|
||||||
left: 40px;
|
--button-size: 56px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Links
|
// Links
|
||||||
&__links {
|
&__links {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 2;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
min-width: 240px;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
background: $color-primary-tertiary20;
|
background: $color-primary-tertiary20;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
margin-bottom: 16px;
|
|
||||||
transform: translate3d(0, 8px, 0);
|
transform: translate3d(0, 8px, 0);
|
||||||
box-shadow: 0 6px 6px $shadow-color, 0 12px 12px $shadow-color, 0 24px 24px $shadow-color;
|
box-shadow: 0 6px 6px $shadow-color, 0 12px 12px $shadow-color, 0 24px 24px $shadow-color;
|
||||||
transition: opacity 0.8s var(--ease-quart), transform 0.8s var(--ease-quart);
|
transition: opacity 0.8s var(--ease-quart), transform 0.8s var(--ease-quart);
|
||||||
@@ -58,8 +63,8 @@
|
|||||||
// Button
|
// Button
|
||||||
&__button {
|
&__button {
|
||||||
$shadow-color: rgba(0, 0, 0, 0.05);
|
$shadow-color: rgba(0, 0, 0, 0.05);
|
||||||
width: 56px;
|
width: var(--button-size);
|
||||||
height: 56px;
|
height: var(--button-size);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -78,12 +83,18 @@
|
|||||||
// Dot
|
// Dot
|
||||||
i {
|
i {
|
||||||
display: block;
|
display: block;
|
||||||
width: 6px;
|
width: 4px;
|
||||||
height: 6px;
|
height: 4px;
|
||||||
margin: 2px 0;
|
margin: 1.5px 0;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
transition: transform 0.8s var(--ease-quart);
|
transition: transform 0.8s var(--ease-quart);
|
||||||
|
|
||||||
|
@include bp (md) {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
margin: 2px 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hover
|
// Hover
|
||||||
@@ -98,7 +109,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Open state
|
/*
|
||||||
|
** States
|
||||||
|
*/
|
||||||
|
// Open
|
||||||
&.is-open {
|
&.is-open {
|
||||||
.switcher {
|
.switcher {
|
||||||
&__links {
|
&__links {
|
||||||
@@ -113,11 +127,56 @@
|
|||||||
|
|
||||||
&__button {
|
&__button {
|
||||||
i {
|
i {
|
||||||
&:nth-child(1) { transform: translate3d(-7px, 8px, 0); }
|
&:nth-child(1) {
|
||||||
&:nth-child(2) { transform: translate3d(7px, -2px, 0); }
|
transform: translate3d(-6px, 5px, 0);
|
||||||
&:nth-child(3) { transform: translate3d(0px, -3px, 0); }
|
|
||||||
|
@include bp (md) {
|
||||||
|
transform: translate3d(-7px, 8px, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&:nth-child(2) {
|
||||||
|
transform: translate3d(6px, -2px, 0);
|
||||||
|
|
||||||
|
@include bp (md) {
|
||||||
|
transform: translate3d(7px, -2px, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&:nth-child(3) {
|
||||||
|
transform: translate3d(0px, -2px, 0);
|
||||||
|
|
||||||
|
@include bp (md) {
|
||||||
|
transform: translate3d(0px, -3px, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Over (for Photo viewer)
|
||||||
|
&.is-over {
|
||||||
|
top: var(--offset);
|
||||||
|
right: var(--offset);
|
||||||
|
left: auto;
|
||||||
|
bottom: auto;
|
||||||
|
|
||||||
|
// Links
|
||||||
|
.switcher__links {
|
||||||
|
top: calc(var(--button-size) + 8px);
|
||||||
|
right: 0;
|
||||||
|
left: auto;
|
||||||
|
|
||||||
|
@include bp (md) {
|
||||||
|
top: auto;
|
||||||
|
bottom: calc(var(--button-size) + 24px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@include bp (md) {
|
||||||
|
top: auto;
|
||||||
|
right: var(--offset);
|
||||||
|
left: auto;
|
||||||
|
bottom: var(--offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user