Skip to content

Commit

Permalink
feat: add button to open / close bototm drawer from header
Browse files Browse the repository at this point in the history
  • Loading branch information
1egoman authored and nichochar committed Oct 21, 2024
1 parent b095db8 commit ae96739
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions packages/web/src/components/apps/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import {
ShareIcon,
PlayIcon,
StopCircleIcon,
EllipsisIcon,
PlayCircleIcon,
Code2Icon,
Loader2Icon,
CircleAlertIcon,
PanelBottomOpenIcon,
PanelBottomCloseIcon,
} from 'lucide-react';
import { Link } from 'react-router-dom';
import { SrcbookLogo } from '@/components/logos';
Expand All @@ -32,6 +34,7 @@ import { useState } from 'react';
import { usePreview } from './use-preview';
import { exportApp } from '@/clients/http/apps';
import { toast } from 'sonner';
import { useLogs } from './use-logs';

export type EditorHeaderTab = 'code' | 'preview';

Expand All @@ -47,6 +50,7 @@ export default function EditorHeader(props: PropsType) {
const { start: startPreview, stop: stopPreview, status: previewStatus } = usePreview();
const { status: npmInstallStatus, nodeModulesExists } = usePackageJson();
const [isExporting, setIsExporting] = useState(false);
const { open, togglePane, panelIcon } = useLogs();

const [nameChangeDialogOpen, setNameChangeDialogOpen] = useState(false);

Expand Down Expand Up @@ -198,17 +202,21 @@ export default function EditorHeader(props: PropsType) {
<Button
variant="icon"
size="icon"
onClick={handleExport}
onClick={togglePane}
className="active:translate-y-0"
>
{isExporting ? (
<Loader2Icon size={18} className="animate-spin" />
) : (
<ShareIcon size={18} />
)}
{panelIcon === 'default' && !open ? (
<PanelBottomOpenIcon size={18} />
) : null}
{panelIcon === 'default' && open ? (
<PanelBottomCloseIcon size={18} />
) : null}
{panelIcon === 'error' ? (
<CircleAlertIcon size={18} className="text-red-600" />
) : null}
</Button>
</TooltipTrigger>
<TooltipContent>Export app</TooltipContent>
<TooltipContent>Open logs</TooltipContent>
</Tooltip>
</TooltipProvider>
<TooltipProvider>
Expand All @@ -217,13 +225,17 @@ export default function EditorHeader(props: PropsType) {
<Button
variant="icon"
size="icon"
onClick={() => alert('More options')}
onClick={handleExport}
className="active:translate-y-0"
>
<EllipsisIcon size={18} />
{isExporting ? (
<Loader2Icon size={18} className="animate-spin" />
) : (
<ShareIcon size={18} />
)}
</Button>
</TooltipTrigger>
<TooltipContent>More options</TooltipContent>
<TooltipContent>Export app</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
Expand Down

0 comments on commit ae96739

Please sign in to comment.