mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-27 22:54:18 +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
247 lines
7.8 KiB
TypeScript
247 lines
7.8 KiB
TypeScript
"use client"
|
||
|
||
import * as React from "react"
|
||
import { Button } from "@/examples/base/ui-rtl/button"
|
||
import {
|
||
DropdownMenu,
|
||
DropdownMenuCheckboxItem,
|
||
DropdownMenuContent,
|
||
DropdownMenuGroup,
|
||
DropdownMenuItem,
|
||
DropdownMenuLabel,
|
||
DropdownMenuPortal,
|
||
DropdownMenuRadioGroup,
|
||
DropdownMenuRadioItem,
|
||
DropdownMenuSeparator,
|
||
DropdownMenuShortcut,
|
||
DropdownMenuSub,
|
||
DropdownMenuSubContent,
|
||
DropdownMenuSubTrigger,
|
||
DropdownMenuTrigger,
|
||
} from "@/examples/base/ui-rtl/dropdown-menu"
|
||
import { CreditCardIcon, SettingsIcon, UserIcon } from "lucide-react"
|
||
|
||
import {
|
||
useTranslation,
|
||
type Translations,
|
||
} from "@/components/language-selector"
|
||
|
||
const translations: Translations = {
|
||
en: {
|
||
dir: "ltr",
|
||
values: {
|
||
open: "Open",
|
||
account: "Account",
|
||
profile: "Profile",
|
||
billing: "Billing",
|
||
settings: "Settings",
|
||
logout: "Log out",
|
||
team: "Team",
|
||
inviteUsers: "Invite users",
|
||
email: "Email",
|
||
message: "Message",
|
||
more: "More",
|
||
calendar: "Calendar",
|
||
chat: "Chat",
|
||
webhook: "Webhook",
|
||
advanced: "Advanced...",
|
||
newTeam: "New Team",
|
||
view: "View",
|
||
statusBar: "Status Bar",
|
||
activityBar: "Activity Bar",
|
||
panel: "Panel",
|
||
position: "Position",
|
||
top: "Top",
|
||
bottom: "Bottom",
|
||
right: "Right",
|
||
left: "Left",
|
||
},
|
||
},
|
||
ar: {
|
||
dir: "rtl",
|
||
values: {
|
||
open: "افتح القائمة",
|
||
account: "الحساب",
|
||
profile: "الملف الشخصي",
|
||
billing: "الفوترة",
|
||
settings: "الإعدادات",
|
||
logout: "تسجيل الخروج",
|
||
team: "الفريق",
|
||
inviteUsers: "دعوة المستخدمين",
|
||
email: "البريد الإلكتروني",
|
||
message: "رسالة",
|
||
more: "المزيد",
|
||
calendar: "تقويم",
|
||
chat: "دردشة",
|
||
webhook: "خطاف ويب",
|
||
advanced: "متقدم...",
|
||
newTeam: "فريق جديد",
|
||
view: "عرض",
|
||
statusBar: "شريط الحالة",
|
||
activityBar: "شريط النشاط",
|
||
panel: "اللوحة",
|
||
position: "الموضع",
|
||
top: "أعلى",
|
||
bottom: "أسفل",
|
||
right: "يمين",
|
||
left: "يسار",
|
||
},
|
||
},
|
||
he: {
|
||
dir: "rtl",
|
||
values: {
|
||
open: "פתח תפריט",
|
||
account: "חשבון",
|
||
profile: "פרופיל",
|
||
billing: "חיוב",
|
||
settings: "הגדרות",
|
||
logout: "התנתק",
|
||
team: "הצוות",
|
||
inviteUsers: "הזמן משתמשים",
|
||
email: "אימייל",
|
||
message: "הודעה",
|
||
more: "עוד",
|
||
calendar: "יומן",
|
||
chat: "צ'אט",
|
||
webhook: "Webhook",
|
||
advanced: "מתקדם...",
|
||
newTeam: "צוות חדש",
|
||
view: "תצוגה",
|
||
statusBar: "שורת סטטוס",
|
||
activityBar: "שורת פעילות",
|
||
panel: "לוח",
|
||
position: "מיקום",
|
||
top: "למעלה",
|
||
bottom: "למטה",
|
||
right: "ימין",
|
||
left: "שמאל",
|
||
},
|
||
},
|
||
}
|
||
|
||
export function DropdownMenuRtl() {
|
||
const { dir, language, t } = useTranslation(translations, "ar")
|
||
const [showStatusBar, setShowStatusBar] = React.useState(true)
|
||
const [showActivityBar, setShowActivityBar] = React.useState(false)
|
||
const [showPanel, setShowPanel] = React.useState(false)
|
||
const [position, setPosition] = React.useState("bottom")
|
||
|
||
return (
|
||
<DropdownMenu>
|
||
<DropdownMenuTrigger render={<Button variant="outline" />}>
|
||
{t.open}
|
||
</DropdownMenuTrigger>
|
||
<DropdownMenuContent
|
||
align={dir === "rtl" ? "end" : "start"}
|
||
dir={dir}
|
||
className="w-36"
|
||
data-lang={dir === "rtl" ? language : undefined}
|
||
>
|
||
<DropdownMenuGroup>
|
||
<DropdownMenuSub>
|
||
<DropdownMenuSubTrigger>{t.account}</DropdownMenuSubTrigger>
|
||
<DropdownMenuPortal>
|
||
<DropdownMenuSubContent
|
||
dir={dir}
|
||
data-lang={dir === "rtl" ? language : undefined}
|
||
>
|
||
<DropdownMenuGroup>
|
||
<DropdownMenuItem>
|
||
<UserIcon />
|
||
{t.profile}
|
||
</DropdownMenuItem>
|
||
<DropdownMenuItem>
|
||
<CreditCardIcon />
|
||
{t.billing}
|
||
</DropdownMenuItem>
|
||
<DropdownMenuItem>
|
||
<SettingsIcon />
|
||
{t.settings}
|
||
</DropdownMenuItem>
|
||
</DropdownMenuGroup>
|
||
</DropdownMenuSubContent>
|
||
</DropdownMenuPortal>
|
||
</DropdownMenuSub>
|
||
</DropdownMenuGroup>
|
||
<DropdownMenuSeparator />
|
||
<DropdownMenuGroup>
|
||
<DropdownMenuLabel>{t.team}</DropdownMenuLabel>
|
||
<DropdownMenuItem>{t.team}</DropdownMenuItem>
|
||
<DropdownMenuSub>
|
||
<DropdownMenuSubTrigger>{t.inviteUsers}</DropdownMenuSubTrigger>
|
||
<DropdownMenuPortal>
|
||
<DropdownMenuSubContent
|
||
dir={dir}
|
||
data-lang={dir === "rtl" ? language : undefined}
|
||
>
|
||
<DropdownMenuItem>{t.email}</DropdownMenuItem>
|
||
<DropdownMenuItem>{t.message}</DropdownMenuItem>
|
||
<DropdownMenuSub>
|
||
<DropdownMenuSubTrigger>{t.more}</DropdownMenuSubTrigger>
|
||
<DropdownMenuPortal>
|
||
<DropdownMenuSubContent
|
||
dir={dir}
|
||
data-lang={dir === "rtl" ? language : undefined}
|
||
>
|
||
<DropdownMenuItem>{t.calendar}</DropdownMenuItem>
|
||
<DropdownMenuItem>{t.chat}</DropdownMenuItem>
|
||
<DropdownMenuSeparator />
|
||
<DropdownMenuItem>{t.webhook}</DropdownMenuItem>
|
||
</DropdownMenuSubContent>
|
||
</DropdownMenuPortal>
|
||
</DropdownMenuSub>
|
||
<DropdownMenuSeparator />
|
||
<DropdownMenuItem>{t.advanced}</DropdownMenuItem>
|
||
</DropdownMenuSubContent>
|
||
</DropdownMenuPortal>
|
||
</DropdownMenuSub>
|
||
<DropdownMenuItem>
|
||
{t.newTeam}
|
||
<DropdownMenuShortcut>⌘+T</DropdownMenuShortcut>
|
||
</DropdownMenuItem>
|
||
</DropdownMenuGroup>
|
||
<DropdownMenuSeparator />
|
||
<DropdownMenuGroup>
|
||
<DropdownMenuLabel>{t.view}</DropdownMenuLabel>
|
||
<DropdownMenuCheckboxItem
|
||
checked={showStatusBar}
|
||
onCheckedChange={setShowStatusBar}
|
||
>
|
||
{t.statusBar}
|
||
</DropdownMenuCheckboxItem>
|
||
<DropdownMenuCheckboxItem
|
||
checked={showActivityBar}
|
||
onCheckedChange={setShowActivityBar}
|
||
>
|
||
{t.activityBar}
|
||
</DropdownMenuCheckboxItem>
|
||
<DropdownMenuCheckboxItem
|
||
checked={showPanel}
|
||
onCheckedChange={setShowPanel}
|
||
>
|
||
{t.panel}
|
||
</DropdownMenuCheckboxItem>
|
||
</DropdownMenuGroup>
|
||
<DropdownMenuSeparator />
|
||
<DropdownMenuGroup>
|
||
<DropdownMenuLabel>{t.position}</DropdownMenuLabel>
|
||
<DropdownMenuRadioGroup value={position} onValueChange={setPosition}>
|
||
<DropdownMenuRadioItem value="top">{t.top}</DropdownMenuRadioItem>
|
||
<DropdownMenuRadioItem value="bottom">
|
||
{t.bottom}
|
||
</DropdownMenuRadioItem>
|
||
<DropdownMenuRadioItem value="right">
|
||
{t.right}
|
||
</DropdownMenuRadioItem>
|
||
<DropdownMenuRadioItem value="left">{t.left}</DropdownMenuRadioItem>
|
||
</DropdownMenuRadioGroup>
|
||
</DropdownMenuGroup>
|
||
<DropdownMenuSeparator />
|
||
<DropdownMenuGroup>
|
||
<DropdownMenuItem variant="destructive">{t.logout}</DropdownMenuItem>
|
||
</DropdownMenuGroup>
|
||
</DropdownMenuContent>
|
||
</DropdownMenu>
|
||
)
|
||
}
|