Skip to content

Commit

Permalink
link
Browse files Browse the repository at this point in the history
  • Loading branch information
shyakadavis committed Jul 19, 2024
1 parent a765cf2 commit b168c79
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@
--gray-alpha-900: rgba(0, 0, 0, 0.61);
--gray-alpha-1000: rgba(0, 0, 0, 0.91);

--accents-1: #fafafa;
--accents-2: #eaeaea;
--accents-3: #999;
--accents-4: #888;
--accents-5: #666;
--accents-6: #444;
--accents-7: #333;
--accents-8: #111;

--contrast-fg: hsl(0 0% 100%);
--focus-color: var(--blue-700);

Expand Down Expand Up @@ -225,6 +234,15 @@
--gray-alpha-900: hsla(0, 0%, 100%, 0.61);
--gray-alpha-1000: hsla(0, 0%, 100%, 0.92);

--accents-1: #111;
--accents-2: #333;
--accents-3: #444;
--accents-4: #666;
--accents-5: #888;
--accents-6: #999;
--accents-7: #eaeaea;
--accents-8: #fafafa;

--focus-color: var(--blue-900);

/* Shadows */
Expand Down
3 changes: 3 additions & 0 deletions src/lib/assets/icons/external-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/lib/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Command from './command.svg?component';
import Copy from './copy.svg?component';
import Database from './database.svg?component';
import ErrorStates from './error-states.svg?component';
import ExternalSmall from './external-small.svg?component';
import External from './external.svg?component';
import FileText from './file-text.svg?component';
import Flag from './flag.svg?component';
Expand Down Expand Up @@ -70,6 +71,7 @@ export const Icons = {
Copy,
Database,
ErrorStates,
ExternalSmall,
External,
FileText,
Flag,
Expand Down
38 changes: 38 additions & 0 deletions src/lib/components/ui/link/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { Button as LinkPrimitive } from 'bits-ui';
import { type VariantProps, tv } from 'tailwind-variants';
import Link from './link.svelte';

const link_variants = tv({
base: 'inline-flex select-none items-center justify-center gap-x-1 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background-200 transition-[background,color,transform,box-shadow] ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-color focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:text-gray-700 [&>svg]:size-3',
variants: {
variant: {
default: '',
secondary: 'text-accents-5 hover:text-gray-1000',
tertiary: '',
error: '',
warning: ''
}
},
defaultVariants: {
variant: 'default'
}
});

type Variant = VariantProps<typeof link_variants>['variant'];

type Props = LinkPrimitive.Props & {
variant?: Variant;
external?: boolean;
href: string;
};

type Events = LinkPrimitive.Events;

export {
Link,
link_variants,
type Events as ButtonEvents,
type Props as ButtonProps,
type Events,
type Props
};
32 changes: 32 additions & 0 deletions src/lib/components/ui/link/link.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script lang="ts">
import { Icons } from '$lib/assets/icons/index.js';
import { cn } from '$lib/utils.js';
import { Button as LinkPrimitive } from 'bits-ui';
import { type Events, type Props, link_variants } from './index.js';
type $$Props = Props;
type $$Events = Events;
let class_name: $$Props['class'] = undefined;
export let variant: $$Props['variant'] = 'default';
export let href: $$Props['href'];
export let builders: $$Props['builders'] = [];
export let external: $$Props['external'] = false;
export { class_name as class };
</script>

<LinkPrimitive.Root
{builders}
class={cn(link_variants({ variant, className: class_name }))}
{href}
target={external ? '_blank' : undefined}
rel={external ? 'noopener noreferrer' : undefined}
{...$$restProps}
on:click
on:keydown
>
<slot />
{#if external}
<Icons.External aria-hidden="true" />
{/if}
</LinkPrimitive.Root>
7 changes: 3 additions & 4 deletions src/routes/empty-state/informational.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
import { Icons } from '$lib/assets/icons';
import { Button } from '$lib/components/ui/button';
import { EmptyState } from '$lib/components/ui/empty-state';
import { Link } from '$lib/components/ui/link';
</script>

<EmptyState
title="Title"
description="This should detail the actions you can take on this screen, as well as why it's valuable."
icon={Icons.ChartBarPeak}
icon_size={32}
title="Title"
>
<Button variant="secondary">Primary Action</Button>
<!-- <Link external href="/" variant="secondary">
Learn more
</Link> -->
<Link external href="https://shyakadavis.me/" variant="secondary">Learn more</Link>
</EmptyState>
10 changes: 10 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ const config: Config = {
900: 'var(--pink-900)',
1000: 'var(--pink-1000)'
},
accents: {
1: 'var(--accents-1)',
2: 'var(--accents-2)',
3: 'var(--accents-3)',
4: 'var(--accents-4)',
5: 'var(--accents-5)',
6: 'var(--accents-6)',
7: 'var(--accents-7)',
8: 'var(--accents-8)'
},
'contrast-fg': 'var(--contrast-fg)',
'focus-color': 'var(--focus-color)'
},
Expand Down

0 comments on commit b168c79

Please sign in to comment.