feat(ui): add framework-neutral localization support
- add a lightweight UI i18n provider with translation and locale contexts\n- localize accessibility labels across breadcrumb, carousel, dialog, pagination, sheet, sidebar, spinner, and toast components\n- integrate calendar locale data without coupling UI components to Lingui\n- publish tree-shakeable catalogs for eight common locales
This commit is contained in:
@@ -4,11 +4,18 @@ import { useRender } from "@base-ui/react/use-render"
|
||||
|
||||
import { cn } from "@workspace/ui/lib/utils"
|
||||
import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
|
||||
import { LocalizedText, uiMessages, useMessage } from "./i18n"
|
||||
|
||||
function Breadcrumb({
|
||||
"aria-label": ariaLabel,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"nav">) {
|
||||
const defaultLabel = useMessage(uiMessages.breadcrumb)
|
||||
|
||||
function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) {
|
||||
return (
|
||||
<nav
|
||||
aria-label="breadcrumb"
|
||||
aria-label={ariaLabel ?? defaultLabel}
|
||||
data-slot="breadcrumb"
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
@@ -85,9 +92,7 @@ function BreadcrumbSeparator({
|
||||
className={cn("[&>svg]:size-3.5", className)}
|
||||
{...props}
|
||||
>
|
||||
{children ?? (
|
||||
<ChevronRightIcon className="rtl:rotate-180" />
|
||||
)}
|
||||
{children ?? <ChevronRightIcon className="rtl:rotate-180" />}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
@@ -107,9 +112,10 @@ function BreadcrumbEllipsis({
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontalIcon
|
||||
/>
|
||||
<span className="sr-only">More</span>
|
||||
<MoreHorizontalIcon />
|
||||
<span className="sr-only">
|
||||
<LocalizedText message={uiMessages.more} />
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user