-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
343 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@utima/ui": minor | ||
--- | ||
|
||
Added `Input` component | ||
Added `Table` component | ||
Added `Label` component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Primitives exports | ||
export { AvatarFallback as Fallback } from './AvatarFallback'; | ||
export { AvatarImage as Image } from './AvatarImage'; | ||
export { Root } from '@radix-ui/react-avatar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Input } from './Input'; | ||
|
||
const meta: Meta<typeof Input> = { | ||
component: Input, | ||
tags: ['autodocs'], | ||
title: 'Components/Input', | ||
args: { | ||
size: 'md', | ||
placeholder: 'Placeholder', | ||
variant: 'default', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Input>; | ||
|
||
export const Basic: Story = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { cva } from 'class-variance-authority'; | ||
|
||
import { twOverrides } from '@/overrides'; | ||
|
||
export const inputDef = twOverrides( | ||
{ | ||
input: | ||
'transition-all text-foreground font-normal flex w-full rounded-md border placeholder-placeholder bg-background ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border focus-visible:border-foreground disabled:cursor-not-allowed disabled:opacity-60', | ||
variants: { | ||
size: { | ||
sm: 'px-2 py-1.5 text-xs', | ||
md: 'px-3 py-2 text-sm', | ||
lg: 'px-4 py-3 text-base', | ||
}, | ||
variant: { | ||
default: | ||
'border-input-border focus-visible:border-foreground hover:border-foreground', | ||
danger: | ||
'border-danger focus-visible:border-danger hover:border-danger/30', | ||
success: | ||
'border-success focus-visible:border-success hover:border-success/30', | ||
}, | ||
}, | ||
}, | ||
'input', | ||
); | ||
|
||
export const inputStyles = cva(inputDef.input, { | ||
variants: inputDef.variants, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { VariantProps } from 'class-variance-authority'; | ||
import { forwardRef, type ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { inputStyles } from './Input.styles'; | ||
|
||
type InputProps = Omit<ComponentProps<'input'>, 'size'> & | ||
VariantProps<typeof inputStyles>; | ||
|
||
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input( | ||
{ className, size = 'md', variant = 'default', ...props }, | ||
ref, | ||
) { | ||
return ( | ||
<input | ||
ref={ref} | ||
className={cn(inputStyles({ size, variant }), className)} | ||
{...props} | ||
/> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Label } from './Label'; | ||
|
||
const meta: Meta<typeof Label> = { | ||
component: Label, | ||
tags: ['autodocs'], | ||
title: 'Components/Label', | ||
args: { | ||
children: 'Label', | ||
size: 'md', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Label>; | ||
|
||
export const Basic: Story = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { cva } from 'class-variance-authority'; | ||
|
||
import { twOverrides } from '@/overrides'; | ||
|
||
export const labelDef = twOverrides( | ||
{ | ||
label: | ||
'text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70', | ||
variants: { | ||
size: { | ||
xs: 'text-xs leading-3', | ||
sm: 'text-xs leading-4', | ||
md: 'text-sm text-sm leading-5', | ||
lg: 'text-base leading-6', | ||
xl: 'text-lg leading-7', | ||
}, | ||
}, | ||
}, | ||
'label', | ||
); | ||
|
||
export const labelStyles = cva(labelDef.label, { | ||
variants: labelDef.variants, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Root } from '@radix-ui/react-label'; | ||
import type { VariantProps } from 'class-variance-authority'; | ||
import { forwardRef, type ComponentProps, type ElementRef } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { labelStyles } from './Label.styles'; | ||
|
||
type LabelProps = Omit<ComponentProps<typeof Root>, 'size'> & | ||
VariantProps<typeof labelStyles>; | ||
|
||
export const Label = forwardRef<ElementRef<typeof Root>, LabelProps>( | ||
function Label({ className, size = 'md', ...props }, ref) { | ||
return ( | ||
<Root | ||
ref={ref} | ||
className={cn(labelStyles({ size }), className)} | ||
{...props} | ||
/> | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import * as Table from './index'; | ||
|
||
const meta: Meta<typeof Table.Root> = { | ||
component: Table.Root, | ||
tags: ['autodocs'], | ||
title: 'Components/Table', | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Table.Root>; | ||
|
||
export const Basic: Story = { | ||
args: { | ||
children: ( | ||
<Table.Root> | ||
<Table.Head> | ||
<Table.HRow> | ||
<Table.HCol>Header 1</Table.HCol> | ||
<Table.HCol>Header 2</Table.HCol> | ||
</Table.HRow> | ||
</Table.Head> | ||
<Table.Body> | ||
<Table.Row> | ||
<Table.Col>Cell 1</Table.Col> | ||
<Table.Col>Cell 2</Table.Col> | ||
</Table.Row> | ||
</Table.Body> | ||
<Table.Foot> | ||
<Table.HRow> | ||
<Table.HCol>Cell 1</Table.HCol> | ||
<Table.HCol>Cell 2</Table.HCol> | ||
</Table.HRow> | ||
</Table.Foot> | ||
</Table.Root> | ||
), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { twOverrides } from '@/overrides'; | ||
|
||
export const tableDef = twOverrides( | ||
{ | ||
table: | ||
'w-full text-sm text-left text-foreground rounded-tl-md rounded-tr-md overflow-hidden', | ||
body: '', | ||
foot: 'text-xs uppercase text-table-fg bg-table', | ||
head: 'text-table-fg bg-table', | ||
col: 'p-2 py-3 h-[70px]', | ||
row: 'bg-white hover:bg-border/10 border-b border-table-border', | ||
hRow: 'text-table-fg bg-table', | ||
hCol: 'p-2', | ||
}, | ||
'table', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableProps = ComponentProps<'table'>; | ||
|
||
export function Table({ className, ...props }: TableProps) { | ||
return <table className={cn(tableDef.table, className)} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableBodyProps = ComponentProps<'tbody'>; | ||
|
||
export function TableBody({ className, ...props }: TableBodyProps) { | ||
return <tbody className={cn(tableDef.body, className)} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableColProps = ComponentProps<'td'>; | ||
|
||
export function TableCol({ className, ...props }: TableColProps) { | ||
return <td className={cn(tableDef.col, className)} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableFootProps = ComponentProps<'thead'>; | ||
|
||
export function TableFoot({ className, ...props }: TableFootProps) { | ||
return <tfoot className={cn(tableDef.foot, className)} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableHColProps = ComponentProps<'th'>; | ||
|
||
export function TableHCol({ className, children, ...props }: TableHColProps) { | ||
return ( | ||
<th className={cn(tableDef.hCol, className)} {...props}> | ||
{children} | ||
</th> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableHRowProps = ComponentProps<'tr'>; | ||
|
||
export function TableHRow({ className, ...props }: TableHRowProps) { | ||
return <tr className={cn(tableDef.hRow, className)} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableHeadProps = ComponentProps<'thead'>; | ||
|
||
export function TableHead({ className, ...props }: TableHeadProps) { | ||
return <thead className={cn(tableDef.head, className)} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { ComponentProps } from 'react'; | ||
|
||
import { cn } from '@/utils'; | ||
|
||
import { tableDef } from './Table.styles'; | ||
|
||
type TableRowProps = ComponentProps<'tr'>; | ||
|
||
export function TableRow({ className, ...props }: TableRowProps) { | ||
return <tr className={cn(tableDef.row, className)} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export { Table as Root } from './Table'; | ||
export { TableBody as Body } from './TableBody'; | ||
export { TableCol as Col } from './TableCol'; | ||
export { TableFoot as Foot } from './TableFoot'; | ||
export { TableHCol as HCol } from './TableHCol'; | ||
export { TableHRow as HRow } from './TableHRow'; | ||
export { TableHead as Head } from './TableHead'; | ||
export { TableRow as Row } from './TableRow'; |
Oops, something went wrong.