diff --git a/web/src/App.tsx b/web/src/App.tsx index 21003fb6..58af7932 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1,3 +1,4 @@ +import { DirectionProvider } from "@base-ui/react/direction-provider"; import { useEffect } from "react"; import { Outlet, ScrollRestoration } from "react-router-dom"; import { useInstance } from "./contexts/InstanceContext"; @@ -11,7 +12,7 @@ const App = () => { const { profile: instanceProfile, profileLoaded, generalSetting: instanceGeneralSetting } = useInstance(); // Apply user preferences reactively - useUserLocale(); + const direction = useUserLocale(); useUserTheme(); // Clean up expired OAuth states on app initialization @@ -58,10 +59,10 @@ const App = () => { }, [instanceGeneralSetting.customProfile]); return ( - <> + - + ); }; diff --git a/web/src/components/ActivityCalendar/YearCalendar.tsx b/web/src/components/ActivityCalendar/YearCalendar.tsx index c34b8f16..e731ed88 100644 --- a/web/src/components/ActivityCalendar/YearCalendar.tsx +++ b/web/src/components/ActivityCalendar/YearCalendar.tsx @@ -36,7 +36,7 @@ const YearNavigation = memo(({ selectedYear, currentYear, onPrev, onNext, onToda aria-label="Previous year" className="size-7 rounded-md text-muted-foreground/65 hover:bg-muted/50 hover:text-foreground/90" > - + diff --git a/web/src/components/AppSidebar/AppSidebar.tsx b/web/src/components/AppSidebar/AppSidebar.tsx index 446cd5d9..44517b66 100644 --- a/web/src/components/AppSidebar/AppSidebar.tsx +++ b/web/src/components/AppSidebar/AppSidebar.tsx @@ -1,3 +1,4 @@ +import { useDirection } from "@base-ui/react/direction-provider"; import { useQueryClient } from "@tanstack/react-query"; import { ArchiveIcon, @@ -644,7 +645,7 @@ const AppSidebar = ({ className }: { className?: string }) => { {t("common.sign-in-to-memos")} @@ -673,10 +674,14 @@ export const MobileAppHeader = () => { }; export const MobileAppSidebar = () => { + const direction = useDirection(); const { mobileOpen, setMobileOpen } = useAppSidebar(); return ( - + Navigation diff --git a/web/src/components/AppSidebar/SidebarResizeHandle.tsx b/web/src/components/AppSidebar/SidebarResizeHandle.tsx index 6686ac17..dfc5318c 100644 --- a/web/src/components/AppSidebar/SidebarResizeHandle.tsx +++ b/web/src/components/AppSidebar/SidebarResizeHandle.tsx @@ -1,3 +1,4 @@ +import { useDirection } from "@base-ui/react/direction-provider"; import { type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, @@ -25,6 +26,7 @@ interface Props { const SidebarResizeHandle = ({ width, minWidth, maxWidth, onWidthChange, targetRef }: Props) => { const t = useTranslate(); + const direction = useDirection(); // `dragging` drives the band's styling; `draggingRef` is what the handlers and the unmount // cleanup read, so neither depends on a state update having been flushed first. const [dragging, setDragging] = useState(false); @@ -99,7 +101,8 @@ const SidebarResizeHandle = ({ width, minWidth, maxWidth, onWidthChange, targetR if (!draggingRef.current) return; // Track the delta rather than the raw cursor x, so grabbing anywhere in the strip // does not snap the rail's edge to the pointer. - previewWidth(clamp(originRef.current.width + event.clientX - originRef.current.x)); + const pointerDelta = event.clientX - originRef.current.x; + previewWidth(clamp(originRef.current.width + (direction === "rtl" ? -pointerDelta : pointerDelta))); }; const endDrag = (event: ReactPointerEvent) => { @@ -114,11 +117,12 @@ const SidebarResizeHandle = ({ width, minWidth, maxWidth, onWidthChange, targetR }; const handleKeyDown = (event: ReactKeyboardEvent) => { + const horizontalStep = direction === "rtl" ? -KEYBOARD_STEP : KEYBOARD_STEP; const next = event.key === "ArrowLeft" - ? width - KEYBOARD_STEP + ? width - horizontalStep : event.key === "ArrowRight" - ? width + KEYBOARD_STEP + ? width + horizontalStep : event.key === "Home" ? minWidth : event.key === "End" @@ -144,7 +148,7 @@ const SidebarResizeHandle = ({ width, minWidth, maxWidth, onWidthChange, targetR onPointerCancel={endDrag} onDoubleClick={() => onWidthChange(SIDEBAR_DEFAULT_WIDTH)} onKeyDown={handleKeyDown} - className="group absolute inset-y-0 -right-1 z-10 flex w-2 cursor-col-resize touch-none justify-center focus-visible:outline-none" + className="group absolute inset-y-0 -end-1 z-10 flex w-2 cursor-col-resize touch-none justify-center focus-visible:outline-none" > {/* A 2px band centering to whole pixels inside the 8px strip, so it covers the rail's border and stays crisp at 1x instead of antialiasing across a half-pixel seam. */} diff --git a/web/src/components/AuthPageLayout.tsx b/web/src/components/AuthPageLayout.tsx index bdfee90e..715eabfb 100644 --- a/web/src/components/AuthPageLayout.tsx +++ b/web/src/components/AuthPageLayout.tsx @@ -78,7 +78,7 @@ const AuthPageLayout = ({ chip, title, subtitle, hideExplore, children }: Props) > {t("auth.explore-public-memos")} - + )} diff --git a/web/src/components/ColumnGrid/ColumnGrid.tsx b/web/src/components/ColumnGrid/ColumnGrid.tsx index 0ed295d1..2081a1f9 100644 --- a/web/src/components/ColumnGrid/ColumnGrid.tsx +++ b/web/src/components/ColumnGrid/ColumnGrid.tsx @@ -1,3 +1,4 @@ +import { useDirection } from "@base-ui/react/direction-provider"; import { type ReactNode, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react"; interface ColumnGridProps { @@ -79,6 +80,7 @@ function ColumnGrid({ maxColumns, maxColumnWidth, }: ColumnGridProps) { + const direction = useDirection(); const containerRef = useRef(null); const itemRefs = useRef>(new Map()); const refCallbacks = useRef void>>(new Map()); @@ -156,7 +158,8 @@ function ColumnGrid({ const pos = new Map(); for (const { key } of ordered) { const col = columnOf.get(key) ?? 0; - const x = offsetX + col * (columnWidth + GRID_GAP); + const inlineOffset = offsetX + col * (columnWidth + GRID_GAP); + const x = direction === "rtl" ? width - columnWidth - inlineOffset : inlineOffset; const y = columnY[col]; pos.set(key, { x, y }); columnY[col] = y + heightOf(key) + GRID_GAP; @@ -185,7 +188,7 @@ function ColumnGrid({ } setContainerHeight(Math.max(0, ...columnY.map((h) => h - GRID_GAP))); - }, [items, getKey, estimateHeight, priorityKey, maxColumns, maxColumnWidth]); + }, [items, getKey, estimateHeight, priorityKey, maxColumns, maxColumnWidth, direction]); // Keep a stable reference so observer callbacks always run the latest layout. const relayoutRef = useRef(relayout); diff --git a/web/src/components/MemoContent/LinkMetadataCard.tsx b/web/src/components/MemoContent/LinkMetadataCard.tsx index ebc77a29..36d2a329 100644 --- a/web/src/components/MemoContent/LinkMetadataCard.tsx +++ b/web/src/components/MemoContent/LinkMetadataCard.tsx @@ -51,7 +51,7 @@ const LinkMetadataCard = ({ url, fallback, enabled = true }: LinkMetadataCardPro {description && {description}} {image && !imageFailed && ( - + { heading.level === minLevel && "font-medium", active ? "text-foreground" : "text-muted-foreground/70 hover:bg-sidebar-accent/65 hover:text-foreground", )} - style={{ paddingLeft: 8 + (heading.level - minLevel) * 12 }} + style={{ paddingInlineStart: 8 + (heading.level - minLevel) * 12 }} > diff --git a/web/src/components/MemoDisplaySettingMenu.tsx b/web/src/components/MemoDisplaySettingMenu.tsx index 0f3f72c4..69e1c090 100644 --- a/web/src/components/MemoDisplaySettingMenu.tsx +++ b/web/src/components/MemoDisplaySettingMenu.tsx @@ -1,3 +1,4 @@ +import { useDirection } from "@base-ui/react/direction-provider"; import { Columns2Icon, Columns3Icon, InfinityIcon, type LucideIcon, Rows3Icon, SlidersHorizontalIcon } from "lucide-react"; import type { ReactNode } from "react"; import { SIDEBAR_SECTION_ACTION_BUTTON_CLASSES, SIDEBAR_SECTION_ACTION_ICON_CLASSES } from "@/components/AppSidebar/SidebarSection"; @@ -41,6 +42,7 @@ const SettingRow = ({ label, description, children }: SettingRowProps) => ( function MemoDisplaySettingsContent() { const t = useTranslate(); + const direction = useDirection(); const { orderByTimeAsc, timeBasis, @@ -76,7 +78,19 @@ function MemoDisplaySettingsContent() { className="grid grid-cols-4 gap-0.5 rounded-lg bg-muted/55 p-0.5" onKeyDown={(event) => { const delta = - event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0; + event.key === "ArrowRight" + ? direction === "rtl" + ? -1 + : 1 + : event.key === "ArrowLeft" + ? direction === "rtl" + ? 1 + : -1 + : event.key === "ArrowDown" + ? 1 + : event.key === "ArrowUp" + ? -1 + : 0; if (delta === 0) return; event.preventDefault(); const index = MAX_COLUMNS_VALUES.indexOf(maxColumns); diff --git a/web/src/components/MemoEditor/components/AudioRecorderPanel.tsx b/web/src/components/MemoEditor/components/AudioRecorderPanel.tsx index 0d0ccd2f..ff71acc8 100644 --- a/web/src/components/MemoEditor/components/AudioRecorderPanel.tsx +++ b/web/src/components/MemoEditor/components/AudioRecorderPanel.tsx @@ -49,7 +49,7 @@ export const AudioRecorderPanel: FC = ({ -
+
{canTranscribe && ( - }> + }>
@@ -78,7 +78,7 @@ const HowToUseDisclosure = () => { aria-expanded={open} onClick={() => setOpen((v) => !v)} > - + {t("setting.access-token.how-to-use")} {open && ( diff --git a/web/src/components/StatisticsView/MonthNavigator.tsx b/web/src/components/StatisticsView/MonthNavigator.tsx index 455be6e9..83ad4c67 100644 --- a/web/src/components/StatisticsView/MonthNavigator.tsx +++ b/web/src/components/StatisticsView/MonthNavigator.tsx @@ -26,7 +26,7 @@ export const MonthNavigator = memo(({ visibleMonth, onMonthChange }: MonthNaviga aria-label={t("common.previous-month")} className="size-6 rounded text-muted-foreground/65 hover:bg-muted/50 hover:text-foreground/90" > - + diff --git a/web/src/components/TagTree.tsx b/web/src/components/TagTree.tsx index d88f6966..7319ef85 100644 --- a/web/src/components/TagTree.tsx +++ b/web/src/components/TagTree.tsx @@ -82,7 +82,7 @@ const TagMark = () =>