Skip to content

Commit 7ef40bd

Browse files
committed
feat: transfer form-field-set components to ui/components
1 parent a884c8e commit 7ef40bd

File tree

16 files changed

+95
-51
lines changed

16 files changed

+95
-51
lines changed

packages/ui/src/components/button.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const buttonVariants = cva(
1212
variant: {
1313
default:
1414
'bg-background-5 text-foreground-6 hover:bg-background-10 disabled:bg-background-6 disabled:text-foreground-9',
15-
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm',
15+
destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
1616
outline:
17-
'border-borders-2 text-foreground-2 hover:border-borders-6 hover:text-foreground-8 border bg-transparent',
18-
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80 shadow-sm',
19-
tertiary: 'bg-tertiary text-secondary-foreground hover:bg-tertiary/80 shadow-sm',
17+
'border border-borders-2 bg-transparent text-foreground-2 hover:border-borders-6 hover:text-foreground-8',
18+
secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
19+
tertiary: 'bg-tertiary text-secondary-foreground shadow-sm hover:bg-tertiary/80',
2020
ghost: 'hover:bg-background-12 hover:text-accent-foreground',
2121
link: 'text-primary underline-offset-4 hover:underline',
2222
link_accent: 'text-foreground-accent underline-offset-4 hover:underline',

packages/ui/src/components/checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Checkbox = forwardRef<ElementRef<typeof CheckboxPrimitive.Root>, CheckboxP
1515
<div className={cn('flex gap-x-2.5', className)}>
1616
<CheckboxPrimitive.Root
1717
ref={ref}
18-
className="border-icons-1 hover:border-icons-3 disabled:border-icons-4 data-[state=checked]:border-icons-2 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground peer size-4 shrink-0 rounded-sm border shadow disabled:cursor-not-allowed"
18+
className="peer size-4 shrink-0 rounded-sm border border-icons-1 shadow hover:border-icons-3 disabled:cursor-not-allowed disabled:border-icons-4 data-[state=checked]:border-icons-2 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground"
1919
{...props}
2020
>
2121
<CheckboxPrimitive.Indicator className={cn('flex items-center justify-center text-current')}>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ReactNode } from 'react'
2+
3+
import { Text } from '@components/text'
4+
5+
interface FormLegendProps {
6+
title: ReactNode
7+
description?: ReactNode
8+
className?: string
9+
}
10+
11+
export function FormLegend({ title, description, className }: FormLegendProps) {
12+
return (
13+
<div className={className}>
14+
<Text size={3} weight={'medium'} as="p" role="heading">
15+
{title}
16+
</Text>
17+
{description && (
18+
<Text size={2} as="p" id="fieldset-description">
19+
{description}
20+
</Text>
21+
)}
22+
</div>
23+
)
24+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { cn } from '@utils/cn'
2+
3+
interface FormSeparatorProps {
4+
dashed?: boolean
5+
dotted?: boolean
6+
className?: string
7+
}
8+
9+
export function FormSeparator({ dashed, dotted, className }: FormSeparatorProps) {
10+
return (
11+
<div
12+
className={cn('border-b', { 'border-dashed': dashed, 'border-dotted': dotted }, className)}
13+
role="separator"
14+
aria-orientation="horizontal"
15+
/>
16+
)
17+
}

packages/ui/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export * from './breadcrumb'
4141
export * from './skeleton-list'
4242
export * from './dialog'
4343
export * from './path-breadcrumbs'
44+
export * from './form-separator'
45+
export * from './form-legend'
4446

4547
export * as ShaBadge from './sha-badge'
4648
export * as ListActions from './list-actions'

packages/ui/src/components/input.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ export interface BaseInputProps
1212
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'>,
1313
VariantProps<typeof inputVariants> {}
1414

15-
const inputVariants = cva('text-foreground-1 bg-transparent px-2.5 py-1 disabled:cursor-not-allowed', {
15+
const inputVariants = cva('bg-transparent px-2.5 py-1 text-foreground-1 disabled:cursor-not-allowed', {
1616
variants: {
1717
variant: {
1818
default:
19-
'placeholder:text-foreground-4 flex w-full rounded border text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:rounded focus-visible:outline-none',
19+
'flex w-full rounded border text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-foreground-4 focus-visible:rounded focus-visible:outline-none',
2020
extended: 'grow border-none focus-visible:outline-none'
2121
},
2222
size: {
@@ -72,7 +72,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
7272
</FormErrorMessage>
7373
)}
7474
{caption && (
75-
<Text className="text-foreground-4 mt-1 leading-snug" size={2}>
75+
<Text className="mt-1 leading-snug text-foreground-4" size={2}>
7676
{caption}
7777
</Text>
7878
)}

packages/ui/src/components/label.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface LabelProps extends VariantProps<typeof labelVariants>, PropsWithChildr
4141
const Label = ({ htmlFor, optional, color, variant, children, className }: LabelProps) => {
4242
return (
4343
<LabelRoot htmlFor={htmlFor} variant={variant} color={color} className={className}>
44-
{children} {optional && <span className="text-foreground-7 align-top">(optional)</span>}
44+
{children} {optional && <span className="align-top text-foreground-7">(optional)</span>}
4545
</LabelRoot>
4646
)
4747
}

packages/ui/src/components/manage-navigation/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const ManageNavigation = ({
127127
</AlertDialogHeader>
128128
<ScrollArea className="-mx-5 -mb-5 mt-1">
129129
<div className="px-5">
130-
<Text className="text-foreground-7 inline-block leading-none" size={1}>
130+
<Text className="inline-block leading-none text-foreground-7" size={1}>
131131
Pinned
132132
</Text>
133133
{!currentPinnedItems.length ? (

packages/ui/src/components/radio-group.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ComponentPropsWithoutRef, ElementRef, FC, forwardRef, ReactElement, ReactNode } from 'react'
22

3-
import { CheckIcon } from '@radix-ui/react-icons'
43
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'
54
import { cn } from '@utils/cn'
65

@@ -64,14 +63,12 @@ const RadioButton = forwardRef<
6463
<RadioGroupPrimitive.Item
6564
ref={ref}
6665
className={cn(
67-
'border-primary hover:border-icons-3 text-icons-5 aspect-square h-4 w-4 rounded-full border shadow focus-visible:rounded-full disabled:cursor-not-allowed disabled:border-icons-4',
66+
'relative border-primary hover:border-icons-3 text-icons-5 aspect-square h-4 w-4 rounded-full border shadow focus-visible:rounded-full disabled:cursor-not-allowed disabled:border-icons-4 flex items-center justify-center',
6867
className
6968
)}
7069
{...props}
7170
>
72-
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
73-
<CheckIcon className="size-3.5 fill-icons-2" />
74-
</RadioGroupPrimitive.Indicator>
71+
<RadioGroupPrimitive.Indicator className="bg-primary size-2 rounded-full" />
7572
</RadioGroupPrimitive.Item>
7673
)
7774
})

packages/ui/src/components/select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const Select: FC<SelectProps> = ({
4949
</FormErrorMessage>
5050
)}
5151
{caption && (
52-
<Text className="text-foreground-4 mt-1 leading-snug" size={2}>
52+
<Text className="mt-1 leading-snug text-foreground-4" size={2}>
5353
{caption}
5454
</Text>
5555
)}

0 commit comments

Comments
 (0)