2025-06-05 21:59:18 +01:00
|
|
|
import React from "react";
|
|
|
|
import { Button, SegmentedControl } from "@mantine/core";
|
2025-06-09 18:38:06 +01:00
|
|
|
import { useRainbowThemeContext } from "./RainbowThemeProvider";
|
2025-06-05 21:59:18 +01:00
|
|
|
import LanguageSelector from "./LanguageSelector";
|
2025-06-19 22:41:05 +01:00
|
|
|
import rainbowStyles from '../../styles/rainbow.module.css';
|
2025-06-05 21:59:18 +01:00
|
|
|
import DarkModeIcon from '@mui/icons-material/DarkMode';
|
|
|
|
import LightModeIcon from '@mui/icons-material/LightMode';
|
2025-06-09 18:38:06 +01:00
|
|
|
import AutoAwesomeIcon from '@mui/icons-material/AutoAwesome';
|
2025-06-05 21:59:18 +01:00
|
|
|
import VisibilityIcon from "@mui/icons-material/Visibility";
|
|
|
|
import EditNoteIcon from "@mui/icons-material/EditNote";
|
|
|
|
import InsertDriveFileIcon from "@mui/icons-material/InsertDriveFile";
|
2025-06-20 17:51:24 +01:00
|
|
|
import FolderIcon from "@mui/icons-material/Folder";
|
2025-06-05 21:59:18 +01:00
|
|
|
import { Group } from "@mantine/core";
|
|
|
|
|
|
|
|
const VIEW_OPTIONS = [
|
|
|
|
{
|
|
|
|
label: (
|
2025-06-08 13:45:45 +01:00
|
|
|
<Group gap={5}>
|
2025-06-05 21:59:18 +01:00
|
|
|
<VisibilityIcon fontSize="small" />
|
|
|
|
</Group>
|
|
|
|
),
|
|
|
|
value: "viewer",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: (
|
|
|
|
<Group gap={4}>
|
|
|
|
<EditNoteIcon fontSize="small" />
|
|
|
|
</Group>
|
|
|
|
),
|
|
|
|
value: "pageEditor",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: (
|
|
|
|
<Group gap={4}>
|
|
|
|
<InsertDriveFileIcon fontSize="small" />
|
|
|
|
</Group>
|
|
|
|
),
|
|
|
|
value: "fileManager",
|
|
|
|
},
|
2025-06-20 17:51:24 +01:00
|
|
|
{
|
|
|
|
label: (
|
|
|
|
<Group gap={4}>
|
|
|
|
<FolderIcon fontSize="small" />
|
|
|
|
</Group>
|
|
|
|
),
|
|
|
|
value: "fileEditor",
|
|
|
|
},
|
2025-06-05 21:59:18 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
interface TopControlsProps {
|
|
|
|
currentView: string;
|
|
|
|
setCurrentView: (view: string) => void;
|
|
|
|
}
|
|
|
|
|
2025-06-19 19:47:44 +01:00
|
|
|
const TopControls = ({
|
2025-06-05 21:59:18 +01:00
|
|
|
currentView,
|
|
|
|
setCurrentView,
|
2025-06-19 19:47:44 +01:00
|
|
|
}: TopControlsProps) => {
|
2025-06-09 18:38:06 +01:00
|
|
|
const { themeMode, isRainbowMode, isToggleDisabled, toggleTheme } = useRainbowThemeContext();
|
|
|
|
|
|
|
|
const getThemeIcon = () => {
|
|
|
|
if (isRainbowMode) return <AutoAwesomeIcon className={rainbowStyles.rainbowText} />;
|
|
|
|
if (themeMode === "dark") return <LightModeIcon />;
|
|
|
|
return <DarkModeIcon />;
|
|
|
|
};
|
2025-06-05 21:59:18 +01:00
|
|
|
|
|
|
|
return (
|
2025-06-09 18:38:06 +01:00
|
|
|
<div className="absolute left-0 w-full top-0 z-[100] pointer-events-none">
|
2025-06-08 13:45:45 +01:00
|
|
|
<div className="absolute left-4 top-1/2 -translate-y-1/2 pointer-events-auto flex gap-2 items-center">
|
2025-06-05 21:59:18 +01:00
|
|
|
<Button
|
2025-06-09 18:38:06 +01:00
|
|
|
onClick={toggleTheme}
|
2025-06-05 21:59:18 +01:00
|
|
|
variant="subtle"
|
|
|
|
size="md"
|
|
|
|
aria-label="Toggle theme"
|
2025-06-09 18:38:06 +01:00
|
|
|
disabled={isToggleDisabled}
|
|
|
|
className={isRainbowMode ? rainbowStyles.rainbowButton : ''}
|
|
|
|
title={
|
|
|
|
isToggleDisabled
|
|
|
|
? "Button disabled for 3 seconds..."
|
|
|
|
: isRainbowMode
|
|
|
|
? "Rainbow Mode Active! Click to exit"
|
|
|
|
: "Toggle theme (click rapidly 6 times for a surprise!)"
|
|
|
|
}
|
|
|
|
style={isToggleDisabled ? { opacity: 0.5, cursor: 'not-allowed' } : {}}
|
2025-06-05 21:59:18 +01:00
|
|
|
>
|
2025-06-09 18:38:06 +01:00
|
|
|
{getThemeIcon()}
|
2025-06-05 21:59:18 +01:00
|
|
|
</Button>
|
|
|
|
<LanguageSelector />
|
|
|
|
</div>
|
2025-06-06 17:20:06 +01:00
|
|
|
<div className="flex justify-center items-center h-full pointer-events-auto">
|
|
|
|
<SegmentedControl
|
|
|
|
data={VIEW_OPTIONS}
|
|
|
|
value={currentView}
|
|
|
|
onChange={setCurrentView}
|
|
|
|
color="blue"
|
|
|
|
radius="xl"
|
|
|
|
size="md"
|
|
|
|
fullWidth
|
2025-06-09 18:38:06 +01:00
|
|
|
className={isRainbowMode ? rainbowStyles.rainbowSegmentedControl : ''}
|
2025-06-06 17:20:06 +01:00
|
|
|
/>
|
2025-06-05 21:59:18 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2025-06-08 13:45:45 +01:00
|
|
|
export default TopControls;
|