mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 15:26:33 +00:00
feat(header): add SettingsDialog and toggle its visibility via SettingsButton
This commit is contained in:
parent
09ef2bf22a
commit
07c625d310
@ -1,9 +0,0 @@
|
|||||||
import { SettingsDialog } from "@/components/settings-dialog"
|
|
||||||
|
|
||||||
export default function Page() {
|
|
||||||
return (
|
|
||||||
<div className="flex h-svh items-center justify-center">
|
|
||||||
<SettingsDialog />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,6 +1,10 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
import { useState } from "react";
|
||||||
import RunCode from "./run-code";
|
import RunCode from "./run-code";
|
||||||
import SettingsButton from "./settings-button";
|
import SettingsButton from "./settings-button";
|
||||||
|
import { SettingsDialog } from "./settings-dialog";
|
||||||
|
|
||||||
interface HeaderProps {
|
interface HeaderProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -10,6 +14,12 @@ export function Header({
|
|||||||
className,
|
className,
|
||||||
...props
|
...props
|
||||||
}: HeaderProps) {
|
}: HeaderProps) {
|
||||||
|
const [isDialogOpen, setDialogOpen] = useState(false);
|
||||||
|
|
||||||
|
const toggleDialog = () => {
|
||||||
|
setDialogOpen(!isDialogOpen);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header
|
<header
|
||||||
{...props}
|
{...props}
|
||||||
@ -20,7 +30,7 @@ export function Header({
|
|||||||
<div className="w-full flex items-center justify-between">
|
<div className="w-full flex items-center justify-between">
|
||||||
<div className="flex items-center"></div>
|
<div className="flex items-center"></div>
|
||||||
<div className="relative flex items-center gap-2">
|
<div className="relative flex items-center gap-2">
|
||||||
<SettingsButton />
|
<SettingsButton onClick={toggleDialog} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -32,6 +42,7 @@ export function Header({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<SettingsDialog open={isDialogOpen} onClose={toggleDialog} />
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipProvider,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "./ui/tooltip";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { SettingsIcon } from "lucide-react";
|
import { SettingsIcon } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip";
|
|
||||||
|
|
||||||
interface SettingsButtonProps {
|
interface SettingsButtonProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
onClick: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SettingsButton({
|
export default function SettingsButton({
|
||||||
className,
|
className,
|
||||||
|
onClick,
|
||||||
...props
|
...props
|
||||||
}: SettingsButtonProps) {
|
}: SettingsButtonProps) {
|
||||||
return (
|
return (
|
||||||
@ -19,7 +26,8 @@ export default function SettingsButton({
|
|||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className={cn("h-8 w-auto p-2",className)}
|
className={cn("h-8 w-auto p-2", className)}
|
||||||
|
onClick={onClick}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<SettingsIcon size={16} aria-hidden="true" />
|
<SettingsIcon size={16} aria-hidden="true" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client";
|
||||||
|
|
||||||
import * as React from "react"
|
import * as React from "react";
|
||||||
import {
|
import {
|
||||||
Bell,
|
Bell,
|
||||||
Check,
|
Check,
|
||||||
@ -14,7 +14,7 @@ import {
|
|||||||
Paintbrush,
|
Paintbrush,
|
||||||
Settings,
|
Settings,
|
||||||
Video,
|
Video,
|
||||||
} from "lucide-react"
|
} from "lucide-react";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Breadcrumb,
|
Breadcrumb,
|
||||||
@ -23,15 +23,13 @@ import {
|
|||||||
BreadcrumbList,
|
BreadcrumbList,
|
||||||
BreadcrumbPage,
|
BreadcrumbPage,
|
||||||
BreadcrumbSeparator,
|
BreadcrumbSeparator,
|
||||||
} from "@/components/ui/breadcrumb"
|
} from "@/components/ui/breadcrumb";
|
||||||
import { Button } from "@/components/ui/button"
|
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
DialogDescription,
|
DialogDescription,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
} from "@/components/ui/dialog";
|
||||||
} from "@/components/ui/dialog"
|
|
||||||
import {
|
import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
SidebarContent,
|
SidebarContent,
|
||||||
@ -41,7 +39,7 @@ import {
|
|||||||
SidebarMenuButton,
|
SidebarMenuButton,
|
||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
SidebarProvider,
|
SidebarProvider,
|
||||||
} from "@/components/ui/sidebar"
|
} from "@/components/ui/sidebar";
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
nav: [
|
nav: [
|
||||||
@ -58,16 +56,16 @@ const data = {
|
|||||||
{ name: "Privacy & visibility", icon: Lock },
|
{ name: "Privacy & visibility", icon: Lock },
|
||||||
{ name: "Advanced", icon: Settings },
|
{ name: "Advanced", icon: Settings },
|
||||||
],
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
interface SettingsDialogProps {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SettingsDialog() {
|
export function SettingsDialog({ open, onClose }: SettingsDialogProps) {
|
||||||
const [open, setOpen] = React.useState(true)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
<Dialog open={open} onOpenChange={onClose}>
|
||||||
<DialogTrigger asChild>
|
|
||||||
<Button size="sm">Open Dialog</Button>
|
|
||||||
</DialogTrigger>
|
|
||||||
<DialogContent className="overflow-hidden p-0 md:max-h-[500px] md:max-w-[700px] lg:max-w-[800px]">
|
<DialogContent className="overflow-hidden p-0 md:max-h-[500px] md:max-w-[700px] lg:max-w-[800px]">
|
||||||
<DialogTitle className="sr-only">Settings</DialogTitle>
|
<DialogTitle className="sr-only">Settings</DialogTitle>
|
||||||
<DialogDescription className="sr-only">
|
<DialogDescription className="sr-only">
|
||||||
@ -125,5 +123,5 @@ export function SettingsDialog() {
|
|||||||
</SidebarProvider>
|
</SidebarProvider>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user