Skip to content

Commit

Permalink
feat: 🎸 add basket counter
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskaransarkaria committed Jan 15, 2022
1 parent 8d36831 commit 9a02101
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .routify/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ module.exports = {
noHashScroll: false,
distDir: 'dist',
extensions: ['svelte', 'html', 'svx', 'md'],
started: '2022-01-15T15:36:09.495Z',
started: '2022-01-15T16:52:26.406Z',
};
4 changes: 2 additions & 2 deletions .routify/routes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @roxi/routify 2.7.3
* File generated Sat Jan 15 2022 15:36:12 GMT+0000 (Greenwich Mean Time)
* File generated Sat Jan 15 2022 16:52:28 GMT+0000 (Greenwich Mean Time)
*/

export const __version = '2.7.3';
export const __timestamp = '2022-01-15T15:36:12.057Z';
export const __timestamp = '2022-01-15T16:52:28.988Z';

//buildRoutes
import { buildClientTree } from '@roxi/routify/runtime/buildRoutes';
Expand Down
27 changes: 13 additions & 14 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="Enki Jewellery & Craft Gallery shop in Kings Heath, Birmingham, UK"
/>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<meta name="description" content="Enki Jewellery & Craft Gallery shop in Kings Heath, Birmingham, UK">
<title>Enki</title>

<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="stylesheet" href="/global.css" />
<link rel="stylesheet" href="/build/bundle-1642260969493.css" />

<script defer src="/build/bundle-1642260969493.js"></script>
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='/global.css'>
<link rel='stylesheet' href='/build/bundle-1642260969493.css'>
<script defer src='/build/bundle-1642260969493.js'></script>
</head>
<body></body>
</html>
<body>
</body>
</html>
1 change: 0 additions & 1 deletion src/components/Basket/Basket.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
justify-content: space-between;
align-items: center;
height: 100px;
margin: 10%;
}
.mobile-quantity-and-price {
Expand Down
14 changes: 10 additions & 4 deletions src/components/Hamburger/Hamburger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import { goto } from '@roxi/routify';
let toggleOpen = false;
const toggleAndGo = (dest: string) => {
toggleOpen = !toggleOpen;
$goto(dest);
};
</script>

<div
Expand All @@ -17,10 +22,10 @@

{#if toggleOpen}
<div class="menu">
<button on:click={$goto('/shop')}> shop </button>
<button on:click={$goto('/repairs')}> repairs </button>
<button on:click={$goto('/classes')}> classes </button>
<button on:click={$goto('/about')}> about </button>
<button on:click={() => toggleAndGo('/shop')}> shop </button>
<button on:click={() => toggleAndGo('/repairs')}> repairs </button>
<button on:click={() => toggleAndGo('/classes')}> classes </button>
<button on:click={() => toggleAndGo('/about')}> about </button>
</div>
{/if}

Expand Down Expand Up @@ -50,6 +55,7 @@
button:focus {
border-bottom: 3px solid orange;
}
#nav-icon3 {
position: absolute;
width: 40px;
Expand Down
70 changes: 64 additions & 6 deletions src/components/Header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { goto } from '@roxi/routify';
import { tweened } from 'svelte/motion';
import { fade } from 'svelte/transition';
import { basket as basketStore } from '@/stores/basket';
import Basket from '@/components/Basket/Basket.svelte';
import SearchProducts from '@/components/SearchProducts/SearchProducts.svelte';
import Hamburger from '@/components/Hamburger/Hamburger.svelte';
Expand Down Expand Up @@ -50,6 +51,7 @@
$: outerWidth = 0;
$: offset = outerWidth < 960 ? lessThan960 : moreThan960;
$: isMobile = outerWidth < 960;
</script>

<svelte:window bind:outerWidth />
Expand Down Expand Up @@ -97,12 +99,49 @@
<SearchProducts width={growSearchWidth($width)} />
</div>
{/if}
<img
class="basket-icon"
src="https://enki.imgix.net/basket_icon.svg"
alt="basket"
on:click={showBasketItems}
/>
<div
class={isMobile
? 'mobile-basket-icon-container'
: 'basket-icon-container'}
>
<img
class="basket-icon"
src="https://enki.imgix.net/basket_icon.svg"
alt="basket"
on:click={() => (isMobile ? showBasketItems() : $goto('/shop/basket'))}
/>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve"
style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 100 100"
width={isMobile ? '15' : '25'}
height={isMobile ? '15' : '25'}
class="num-basket-items"
on:click={() => (isMobile ? showBasketItems() : $goto('/shop/basket'))}
>
<g id="UrTavla">
<circle
style="fill:#fa6603;stroke:#fa6603;stroke-width:1.6871;stroke-miterlimit:10;"
cx="50"
cy="50"
r="50"
/>
<text
x="47.5%"
y="40%"
text-anchor="middle"
stroke="white"
fill="white"
stroke-width="2.5px"
dy=".45em"
font-size="5em"
>{$basketStore.reduce((acc, curr) => acc + curr.quantity, 0)}</text
>
</g>
</svg>
</div>
</div>
</div>
{#if showBasket && outerWidth < 960}
Expand Down Expand Up @@ -135,6 +174,25 @@
align-self: flex-end;
}
.mobile-basket-icon-container {
display: flex;
align-self: center;
align-items: center;
justify-content: center;
}
.num-basket-items {
position: absolute;
cursor: pointer;
transform: translate(-10%, 10%);
}
@media (min-width: 960px) {
.num-basket-items {
transform: translate(-120%, 100%);
}
}
img:hover {
cursor: pointer;
}
Expand Down

0 comments on commit 9a02101

Please sign in to comment.