refactor(ui): move Appearance from sidebar to header user dropdown
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
import * as LucideIcons from 'lucide-react';
|
import * as LucideIcons from 'lucide-react';
|
||||||
const { ChevronDown, Lock } = LucideIcons;
|
const { ChevronDown, Lock } = LucideIcons;
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
@@ -325,7 +324,6 @@ function SidebarTopItem({ item, sectionName, currentPath, navigate, edition, onU
|
|||||||
export function Sidebar() {
|
export function Sidebar() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const { t } = useTranslation();
|
|
||||||
const activeSection = useUIStore((s) => s.activeSection);
|
const activeSection = useUIStore((s) => s.activeSection);
|
||||||
const setActiveSection = useUIStore((s) => s.setActiveSection);
|
const setActiveSection = useUIStore((s) => s.setActiveSection);
|
||||||
const sidebarOpen = useUIStore((s) => s.sidebarOpen);
|
const sidebarOpen = useUIStore((s) => s.sidebarOpen);
|
||||||
@@ -376,9 +374,6 @@ export function Sidebar() {
|
|||||||
if (first) navigate(`/${target.name}/${first}`);
|
if (first) navigate(`/${target.name}/${first}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isAppearanceActive =
|
|
||||||
location.pathname === '/Appearance' || location.pathname.startsWith('/Appearance/');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@@ -408,22 +403,6 @@ export function Sidebar() {
|
|||||||
</nav>
|
</nav>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|
||||||
<div className="border-t px-2 py-2 [[data-radius='square']_&]:px-0">
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
data-sidebar-active={isAppearanceActive || undefined}
|
|
||||||
className={cn(
|
|
||||||
sidebarItemClass,
|
|
||||||
sidebarItemSquareClass,
|
|
||||||
isAppearanceActive && 'bg-accent text-accent-foreground hover:bg-accent',
|
|
||||||
)}
|
|
||||||
onClick={() => navigate('/Appearance')}
|
|
||||||
>
|
|
||||||
<LucideIcons.Palette className="h-4 w-4 shrink-0" />
|
|
||||||
<span className="truncate">{t('appearance.label', 'Appearance')}</span>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{layouts.length > 1 && (
|
{layouts.length > 1 && (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<div className="flex items-center justify-around border-t bg-background px-2 py-2 [[data-radius='square']_&]:px-0 [[data-radius='square']_&]:py-0">
|
<div className="flex items-center justify-around border-t bg-background px-2 py-2 [[data-radius='square']_&]:px-0 [[data-radius='square']_&]:py-0">
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { Link, useNavigate } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import * as LucideIcons from 'lucide-react';
|
import * as LucideIcons from 'lucide-react';
|
||||||
const { User, LogOut, Check, Menu, Sparkles, Search } = LucideIcons;
|
const { User, LogOut, Check, Menu, Sparkles, Search, Palette } = LucideIcons;
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { CommandPalette } from '@/components/common/CommandPalette';
|
import { CommandPalette } from '@/components/common/CommandPalette';
|
||||||
import {
|
import {
|
||||||
@@ -198,6 +198,11 @@ export function TopBar() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<DropdownMenuItem onClick={() => navigate('/Appearance')}>
|
||||||
|
<Palette className="mr-2 h-4 w-4" />
|
||||||
|
{t('appearance.label', 'Appearance')}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user