mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 08:33:36 +00:00
feat: enhance sidebar functionality for mobile and compact views
- Introduced a floating toggle button for mobile to show/hide the sidebar when collapsed. - Updated sidebar behavior to completely hide on mobile when the new mobileSidebarHidden state is true. - Added logic to conditionally render sidebar components based on screen size using the new useIsCompact hook. - Enhanced SidebarHeader to include close and expand buttons for mobile views. - Refactored CollapseToggleButton to hide in compact mode. - Implemented HeaderActionsPanel for mobile actions in various views, improving accessibility and usability on smaller screens. These changes improve the user experience on mobile devices by providing better navigation options and visibility controls.
This commit is contained in:
@@ -7,6 +7,10 @@ import { toast } from 'sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { HotkeyButton } from '@/components/ui/hotkey-button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import {
|
||||
HeaderActionsPanel,
|
||||
HeaderActionsPanelTrigger,
|
||||
} from '@/components/ui/header-actions-panel';
|
||||
import {
|
||||
RefreshCw,
|
||||
FileText,
|
||||
@@ -94,6 +98,9 @@ export function ContextView() {
|
||||
const [editDescriptionValue, setEditDescriptionValue] = useState('');
|
||||
const [editDescriptionFileName, setEditDescriptionFileName] = useState('');
|
||||
|
||||
// Actions panel state (for tablet/mobile)
|
||||
const [showActionsPanel, setShowActionsPanel] = useState(false);
|
||||
|
||||
// File input ref for import
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
@@ -691,30 +698,70 @@ export function ContextView() {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleImportClick}
|
||||
disabled={isUploading}
|
||||
data-testid="import-file-button"
|
||||
>
|
||||
<FileUp className="w-4 h-4 mr-2" />
|
||||
Import File
|
||||
</Button>
|
||||
<HotkeyButton
|
||||
size="sm"
|
||||
onClick={() => setIsCreateMarkdownOpen(true)}
|
||||
hotkey={shortcuts.addContextFile}
|
||||
hotkeyActive={false}
|
||||
data-testid="create-markdown-button"
|
||||
>
|
||||
<FilePlus className="w-4 h-4 mr-2" />
|
||||
Create Markdown
|
||||
</HotkeyButton>
|
||||
<div className="flex items-center gap-2">
|
||||
{/* Desktop: show actions inline */}
|
||||
<div className="hidden lg:flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleImportClick}
|
||||
disabled={isUploading}
|
||||
data-testid="import-file-button"
|
||||
>
|
||||
<FileUp className="w-4 h-4 mr-2" />
|
||||
Import File
|
||||
</Button>
|
||||
<HotkeyButton
|
||||
size="sm"
|
||||
onClick={() => setIsCreateMarkdownOpen(true)}
|
||||
hotkey={shortcuts.addContextFile}
|
||||
hotkeyActive={false}
|
||||
data-testid="create-markdown-button"
|
||||
>
|
||||
<FilePlus className="w-4 h-4 mr-2" />
|
||||
Create Markdown
|
||||
</HotkeyButton>
|
||||
</div>
|
||||
{/* Tablet/Mobile: show trigger for actions panel */}
|
||||
<HeaderActionsPanelTrigger
|
||||
isOpen={showActionsPanel}
|
||||
onToggle={() => setShowActionsPanel(!showActionsPanel)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions Panel (tablet/mobile) */}
|
||||
<HeaderActionsPanel
|
||||
isOpen={showActionsPanel}
|
||||
onClose={() => setShowActionsPanel(false)}
|
||||
title="Context Actions"
|
||||
>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="w-full justify-start"
|
||||
onClick={() => {
|
||||
handleImportClick();
|
||||
setShowActionsPanel(false);
|
||||
}}
|
||||
disabled={isUploading}
|
||||
data-testid="import-file-button-mobile"
|
||||
>
|
||||
<FileUp className="w-4 h-4 mr-2" />
|
||||
Import File
|
||||
</Button>
|
||||
<Button
|
||||
className="w-full justify-start"
|
||||
onClick={() => {
|
||||
setIsCreateMarkdownOpen(true);
|
||||
setShowActionsPanel(false);
|
||||
}}
|
||||
data-testid="create-markdown-button-mobile"
|
||||
>
|
||||
<FilePlus className="w-4 h-4 mr-2" />
|
||||
Create Markdown
|
||||
</Button>
|
||||
</HeaderActionsPanel>
|
||||
|
||||
{/* Main content area with file list and editor */}
|
||||
<div
|
||||
className={cn(
|
||||
|
||||
Reference in New Issue
Block a user