Skip to content

Commit

Permalink
Fix back button
Browse files Browse the repository at this point in the history
  • Loading branch information
Greenheart committed Jun 20, 2022
1 parent c6c81af commit f5b0c56
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/src/components/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
import Link from '$components/Link.svelte'
import { isMenuOpen } from '$lib/stores'
import { page } from '$app/stores'
export let showBackButton = false
const toggleMenu = () => {
$isMenuOpen = !$isMenuOpen
}
const goBack = () => window.history.back()
const getBackLink = (routeId: string) => {
const backLinks = {
'explore/[link]': '/explore',
explore: '/',
}
return backLinks[routeId as keyof typeof backLinks] ?? '/'
}
const links = [
{ href: '/explore', text: 'Toolbox' },
Expand All @@ -19,12 +26,13 @@

<header class="relative flex items-center justify-between pt-6 pb-12">
{#if showBackButton}
<button
on:click={goBack}
<Link
href={getBackLink($page.routeId ?? '')}
unstyled
class="z-10 -ml-4 grid h-[60px] rotate-180 place-items-center p-4"
>
<Arrow class="h-8 w-8 pb-1" />
</button>
</Link>

<div class="absolute left-0 right-0 z-0 h-[60px]">
<div class="flex h-full">
Expand Down

1 comment on commit f5b0c56

@vercel
Copy link

@vercel vercel bot commented on f5b0c56 Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.