-
Notifications
You must be signed in to change notification settings - Fork 5
fix: UI refactor #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: UI refactor #12
Changes from 9 commits
4310bac
c77169b
c960245
5e6a997
1962592
97d5dc9
bb45658
04bd4a7
18bf725
556876d
a858d5e
60eb9bf
3df69b1
93d2836
f5bd29c
ea3395c
c32f505
b88ee74
7d947f9
849d686
e319add
d2714b1
5ce8c8b
b976357
f6271da
7cd915a
aaf7fe1
e1289c3
b0d905f
1d98831
9fa8419
728a251
ac620ef
864518e
6db888c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import React from "react"; | ||
| import { cn } from "../../lib/utils"; | ||
|
|
||
| export type BadgeVariant = | ||
| | "default" | ||
| | "success" | ||
| | "warning" | ||
| | "danger" | ||
| | "info"; | ||
|
|
||
| export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> { | ||
| variant?: BadgeVariant; | ||
| dot?: boolean; | ||
| } | ||
|
|
||
| const variantClasses: Record<BadgeVariant, string> = { | ||
| default: "bg-gray-100 text-gray-700", | ||
| success: "bg-green-100 text-green-700", | ||
| warning: "bg-amber-100 text-amber-700", | ||
| danger: "bg-red-100 text-red-700", | ||
| info: "bg-blue-100 text-blue-700", | ||
| }; | ||
|
|
||
| const dotClasses: Record<BadgeVariant, string> = { | ||
| default: "bg-gray-500", | ||
| success: "bg-green-500", | ||
| warning: "bg-amber-500", | ||
| danger: "bg-red-500", | ||
| info: "bg-blue-500", | ||
| }; | ||
|
|
||
| export function Badge({ | ||
| variant = "default", | ||
| dot = false, | ||
| className, | ||
| children, | ||
| ...rest | ||
| }: BadgeProps) { | ||
| return ( | ||
| <span | ||
| className={cn( | ||
| "inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium", | ||
| variantClasses[variant], | ||
| className | ||
| )} | ||
| {...rest} | ||
| > | ||
| {dot && ( | ||
| <span | ||
| className={cn("h-1.5 w-1.5 shrink-0 rounded-full", dotClasses[variant])} | ||
| aria-hidden="true" | ||
| /> | ||
| )} | ||
| {children} | ||
| </span> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,110 @@ | ||||||||||||
| import React from "react"; | ||||||||||||
| import { cn } from "../../lib/utils"; | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| import { cn } from "../../lib/utils"; | |
| function cn(...classes: Array<string | false | null | undefined>): string { | |
| return classes.filter(Boolean).join(" "); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,89 @@ | ||||||||||||
| import React from "react"; | ||||||||||||
| import { cn } from "../../lib/utils"; | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+1
to
+2
|
||||||||||||
| import { cn } from "../../lib/utils"; | |
| function cn(...classes: Array<string | false | null | undefined>): string { | |
| return classes.filter(Boolean).join(" "); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,103 @@ | ||||||||||||
| import React from "react"; | ||||||||||||
| import { cn } from "../../lib/utils"; | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| import { cn } from "../../lib/utils"; | |
| function cn(...classes: Array<string | false | null | undefined>): string { | |
| return classes.filter(Boolean).join(" "); | |
| } |
Outdated
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If neither id nor label is provided, inputId is undefined, but aria-describedby is still built from it, producing values like "undefined-error"/"undefined-hint". Use React.useId() (or require id when hint/error are present) to ensure a stable, unique ID.
Outdated
Copilot
AI
Mar 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hint/error elements build their id from inputId. When inputId is undefined, this produces duplicate IDs like id="undefined-error" and breaks aria-describedby associations. Generate a per-instance ID (e.g., useId) before building these strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cnis imported from../../lib/utils, but there is nosrc/lib/utils(or anylib/utils) in the repository, so this file will fail to compile as-is. Add the missing utility (and its exports) or update the import to the correct existing helper module.