Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/components/link/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as React from 'react'
import { Slot } from '@radix-ui/react-slot'
import { cva, type VariantProps } from 'class-variance-authority'

import { cn } from '../../lib/utils'

const linkVariants = cva(
'leading-tight inline-flex items-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
{
variants: {
variant: {
default: '',
underline: 'underline underline-offset-4',
hover: 'hover:underline hover:underline-offset-4',
},
textColor: {
primary: 'text-primary hover:text-primary/80',
inherit: 'text-inherit hover:opacity-80',
},
},
defaultVariants: {
variant: 'default',
textColor: 'primary',
},
}
)

export interface LinkProps
extends React.AnchorHTMLAttributes<HTMLAnchorElement>,
VariantProps<typeof linkVariants> {
asChild?: boolean
}

const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
({ className, variant, textColor, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'a'
return <Comp className={cn(linkVariants({ variant, textColor, className }))} ref={ref} {...props} />
}
)
Link.displayName = 'Link'

export { Link, linkVariants }
43 changes: 43 additions & 0 deletions src/stories/Typography/Typography.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { Meta, StoryObj } from '@storybook/react'
import { Link } from '../../components/link'

const meta = {
title: 'Typography/Link',
component: Link,
parameters: {
layout: 'centered',
},
tags: ['autodocs'],
argTypes: {
variant: {
control: 'select',
options: ['default', 'underline', 'hover'],
description: 'The visual style variant of the link',
},
textColor: {
control: 'select',
options: ['primary', 'inherit'],
description: 'The text color scheme of the link',
defaultValue: 'primary',
},
asChild: {
control: 'boolean',
description: 'When true, renders the child component with Link styles and props merged.',
},
className: {
control: 'text',
description: 'Additional CSS classes for custom styling',
},
},
} satisfies Meta<typeof Link>

export default meta
type Story = StoryObj<typeof meta>

export const Default: Story = {
args: {
children: 'Oasis Explorer',
href: '#',
textColor: 'primary',
},
}
2 changes: 1 addition & 1 deletion src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
--card-foreground: hsl(240 10% 4%);
--popover: hsl(0 0% 100%);
--popover-foreground: hsl(240 10% 4%);
--primary: hsl(241 100% 44%);
--primary: hsl(241.33 100% 44.31%);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

They colors could have changed, initially they were exported from Figma.

--primary-foreground: hsl(0 0% 98%);
--secondary: hsl(240 5% 96%);
--secondary-foreground: hsl(240 6% 10%);
Expand Down