Skip to content

Commit

Permalink
add onboard for sqlite client
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Sep 28, 2024
1 parent a7ffe8f commit 8dcd50b
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 39 deletions.
72 changes: 72 additions & 0 deletions src/app/(theme)/playground/client/page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,77 @@ import {
DropdownMenuItem,
DropdownMenuSeparator,
} from "@/components/ui/dropdown-menu";
import { Button } from "@/components/ui/button";

function OverlayAround({
x,
y,
w,
h,
}: {
x: number;
y: number;
w: number;
h: number;
}) {
return (
<>
<div
className="opacity-40 bg-black fixed z-30"
style={{ left: 0, width: x + "px", top: 0, bottom: 0 }}
></div>
<div
className="opacity-40 bg-black fixed z-30"
style={{ left: x + w + "px", right: 0, top: 0, bottom: 0 }}
></div>
<div
className="opacity-40 bg-black fixed z-30"
style={{ left: x + "px", top: 0, height: y, width: w }}
></div>
<div
className="opacity-40 bg-black fixed z-30"
style={{ left: x + "px", top: y + h + "px", bottom: 0, width: w }}
></div>
</>
);
}

function Onboarding() {
const [onboard, setOnboard] = useState(
() => !localStorage.getItem("sqlite-onboard-v1")
);

if (!onboard) return null;

return (
<>
<OverlayAround x={15} y={8} w={50} h={50} />
<div
className="fixed z-40 bg-background p-3 rounded-lg shadow-lg text-sm"
style={{ top: 10, left: 75 }}
>
<h2 className="font-semibold text-lg">There is more!</h2>
<ul className="list-disc mt-2 mb-4 mx-4">
<li>
You can <strong>open</strong> and <strong>save</strong> your SQLite
database here.
</li>
<li>Switch dark and light mode</li>
<li>And many more in the future</li>
</ul>
<Button
size={"sm"}
onClick={() => {
setOnboard(false);
localStorage.setItem("sqlite-onboard-v1", "1");
}}
>
Got it
</Button>
</div>
</>
);
}

export default function PlaygroundEditorBody({
preloadDatabase,
Expand Down Expand Up @@ -255,6 +326,7 @@ export default function PlaygroundEditorBody({
<>
<Script src="/sqljs/sql-wasm.js" onReady={onReady} />
<ScreenDropZone onFileDrop={setHandler} />
<Onboarding />
{dom}
</>
);
Expand Down
36 changes: 0 additions & 36 deletions src/components/gui/sidebar-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,42 +51,6 @@ export default function SidebarTab({ tabs }: Readonly<SidebarTabProps>) {
return (
<div className={cn("flex h-full border-l-8", bgPrimary)}>
<div className={cn("shrink-0")}>
{/* <div className="text-sm my-2 px-3 font-semibold flex">
{config.onBack && (
<div
className="flex items-center -ml-2 mr-2 cursor-pointer hover:text-blue-500"
onClick={config.onBack}
>
<LucideChevronLeft />
</div>
)}
<div className="flex-grow flex items-center">
<div className="line-clamp-1 text-ellipsis">{config.name}</div>
</div>
{!disableToggle && (
<div className="flex justify-center items-center">
<button
onClick={() => toggleTheme()}
className="text-xs font-normal flex gap-0.5 border rounded px-2 py-1 bg-background"
>
{theme === "dark" ? (
<>
<LucideMoon className={cn("w-4 h-4")} />
Dark
</>
) : (
<>
<LucideSun className={cn("w-4 h-4")} />
Light
</>
)}
</button>
</div>
)}
</div> */}

<div className="flex flex-col border-r h-full p-2 gap-2">
<DropdownMenu modal={false}>
<DropdownMenuTrigger>
Expand Down
3 changes: 0 additions & 3 deletions src/components/gui/sortable-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type WindowTabItemButtonProps = ButtonProps & {
onClose?: () => void;
isDragging?: boolean;
index: number;
tabCount: number;
};

export const WindowTabItemButton = forwardRef<
Expand Down Expand Up @@ -78,7 +77,6 @@ export const WindowTabItemButton = forwardRef<

export function SortableTab({
index,
tabCount,
tab,
selected,
onSelectChange,
Expand Down Expand Up @@ -108,7 +106,6 @@ export function SortableTab({
onClose={onClose}
style={style}
index={index}
tabCount={tabCount}
isDragging={isDragging}
{...attributes}
{...listeners}
Expand Down

0 comments on commit 8dcd50b

Please sign in to comment.