mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-07 22:18:39 +00:00
* feat: rtl * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add sidebar * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * chore: changeset * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix
101 lines
2.6 KiB
TypeScript
101 lines
2.6 KiB
TypeScript
"use client"
|
|
|
|
import { Button } from "@/examples/base/ui-rtl/button"
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverDescription,
|
|
PopoverHeader,
|
|
PopoverTitle,
|
|
PopoverTrigger,
|
|
} from "@/examples/base/ui-rtl/popover"
|
|
|
|
import {
|
|
useTranslation,
|
|
type Translations,
|
|
} from "@/components/language-selector"
|
|
|
|
const translations: Translations = {
|
|
en: {
|
|
dir: "ltr",
|
|
values: {
|
|
title: "Dimensions",
|
|
description: "Set the dimensions for the layer.",
|
|
"inline-start": "Inline Start",
|
|
left: "Left",
|
|
top: "Top",
|
|
bottom: "Bottom",
|
|
right: "Right",
|
|
"inline-end": "Inline End",
|
|
},
|
|
},
|
|
ar: {
|
|
dir: "rtl",
|
|
values: {
|
|
title: "الأبعاد",
|
|
description: "تعيين الأبعاد للطبقة.",
|
|
"inline-start": "بداية السطر",
|
|
left: "يسار",
|
|
top: "أعلى",
|
|
bottom: "أسفل",
|
|
right: "يمين",
|
|
"inline-end": "نهاية السطر",
|
|
},
|
|
},
|
|
he: {
|
|
dir: "rtl",
|
|
values: {
|
|
title: "מימדים",
|
|
description: "הגדר את המימדים לשכבה.",
|
|
"inline-start": "תחילת השורה",
|
|
left: "שמאל",
|
|
top: "למעלה",
|
|
bottom: "למטה",
|
|
right: "ימין",
|
|
"inline-end": "סוף השורה",
|
|
},
|
|
},
|
|
}
|
|
|
|
const physicalSides = ["left", "top", "bottom", "right"] as const
|
|
const logicalSides = ["inline-start", "inline-end"] as const
|
|
|
|
export function PopoverRtl() {
|
|
const { dir, t } = useTranslation(translations, "ar")
|
|
|
|
return (
|
|
<div className="grid gap-4">
|
|
<div className="flex flex-wrap justify-center gap-2">
|
|
{physicalSides.map((side) => (
|
|
<Popover key={side}>
|
|
<PopoverTrigger render={<Button variant="outline" />}>
|
|
{t[side]}
|
|
</PopoverTrigger>
|
|
<PopoverContent side={side} dir={dir}>
|
|
<PopoverHeader>
|
|
<PopoverTitle>{t.title}</PopoverTitle>
|
|
<PopoverDescription>{t.description}</PopoverDescription>
|
|
</PopoverHeader>
|
|
</PopoverContent>
|
|
</Popover>
|
|
))}
|
|
</div>
|
|
<div className="flex flex-wrap justify-center gap-2">
|
|
{logicalSides.map((side) => (
|
|
<Popover key={side}>
|
|
<PopoverTrigger render={<Button variant="outline" />}>
|
|
{t[side]}
|
|
</PopoverTrigger>
|
|
<PopoverContent side={side} dir={dir}>
|
|
<PopoverHeader>
|
|
<PopoverTitle>{t.title}</PopoverTitle>
|
|
<PopoverDescription>{t.description}</PopoverDescription>
|
|
</PopoverHeader>
|
|
</PopoverContent>
|
|
</Popover>
|
|
))}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|