Skip to content

Commit

Permalink
feat(ui): implement focus styles for link+btn
Browse files Browse the repository at this point in the history
  • Loading branch information
ferothefox committed Aug 10, 2023
1 parent 713c4d6 commit 4bde5ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/lib/components/layout/NavBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
</script>

<div class="beatforge-page-navbar flex w-full items-center py-8 px-4 mx-auto max-w-7xl z-[100] text-sm font-bold">
<a href="/" class="flex items-center">
<Link variant="ghost" focusRing={false}>
<img src="/images/logo.svg" draggable="false" alt="logo" class="h-12 p-3" />
</a>
</Link>

<div class="ml-auto mr-4 flex flex-row gap-8 items-center">
<Link variant="text" href="https://discord.gg/HTVrjFENaZ" external>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/button/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
pill: 'text-xs bg-primary-700 w-fit px-2 p-1 text-fore-base whitespace-nowrap',
};
let buttonClasses = `disabled:opacity-50 flex flex-row items-center justify-center transition-all duration-[80ms] rounded-full gap-2 font-bold text-sm ${variantClasses[variant]} ${customClasses}`;
let buttonClasses = `outline-none focus:shadow-none focus-visible:ring-4 focus-visible:ring-[#00a8fc] disabled:opacity-50 flex flex-row items-center justify-center transition-all duration-[80ms] rounded-full gap-2 font-bold text-sm ${variantClasses[variant]} ${customClasses}`;
</script>

<button {disabled} class={buttonClasses}>
Expand Down
8 changes: 5 additions & 3 deletions packages/ui/link/Link.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
export let customClasses = '';
// Boolean
export let external = false;
export let focusRing = true;
export let href = '';
const variantClasses = {
ghost: 'outline-none',
underlined: 'underline',
text: 'hover:underline',
text: 'hover:underline focus-visible:underline',
primary: 'flex flex-row items-center justify-center transition-all duration-[80ms] rounded-full gap-2 font-bold text-sm px-4 py-2 bg-primary-50 hover:bg-primary-100 text-primary-950',
secondary: 'flex flex-row items-center justify-center transition-all duration-[80ms] rounded-full gap-2 font-bold text-sm px-4 py-2 bg-primary-800 hover:bg-primary-700 text-white'
};
let linkClasses = `${variantClasses[variant]} ${customClasses}`
let linkClasses = `${focusRing ? 'outline-none focus:shadow-none focus-visible:ring-4 focus-visible:ring-[#00a8fc]' : ''} ${variantClasses[variant]} ${customClasses}`
</script>

<a href={href ?? ''} class={linkClasses} target={`${external ? '_blank' : ''}`} rel={`${external ? 'noopener noreferrer' : ''}`}>
<a tabindex="0" href={href ?? ''} class={linkClasses} target={`${external ? '_blank' : ''}`} rel={`${external ? 'noopener noreferrer' : ''}`}>
<slot />
</a>

0 comments on commit 4bde5ba

Please sign in to comment.