Skip to content

Commit

Permalink
Add link to see history from the first page
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianoratamero committed May 4, 2024
1 parent 44b7ff3 commit f30d65c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
49 changes: 34 additions & 15 deletions src/lib/components/Button.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import type { HTMLButtonAttributes } from 'svelte/elements';
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
const {
children,
type = 'button',
disabled,
disabled = false,
...rest
}: HTMLButtonAttributes & { children: Snippet } = $props();
}:
| ({
href: string;
disabled?: boolean;
children: Snippet;
} & HTMLAnchorAttributes)
| ({ children: Snippet } & HTMLButtonAttributes) = $props();
const disabledClasses = disabled ? 'opacity-50 cursor-not-allowed' : 'active:scale-95';
</script>

<button
{type}
{disabled}
{...rest}
class={`
${disabledClasses}
rounded border border-zinc-800 px-4 py-2 shadow-lg transition-all
`}
>
{@render children()}
</button>
{#if 'href' in rest}
<a
{...rest}
class={`
${disabledClasses}
${rest.class}
inline-block rounded border border-zinc-800 px-4 py-2 text-center shadow-lg transition-all
`}
>
{@render children()}
</a>
{:else}
<button
type={rest.type || 'button'}
{disabled}
{...rest}
class={`
${disabledClasses}
${rest.class}
inline-block rounded border border-zinc-800 px-4 py-2 text-center shadow-lg transition-all
`}
>
{@render children()}
</button>
{/if}
1 change: 1 addition & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<Button onclick={changePallette}>Change color palette</Button>
<Button onclick={goFullscreen}>Go fullscreen</Button>
</div>
<Button href="/history">See history</Button>
</form>

<BokehPage {colorPalette} {decay} bind:showForm />

0 comments on commit f30d65c

Please sign in to comment.