Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

Refactor: Adjust NotesWindow dimensions and update styling

itzadetunjib3470e2b1853
diff --git a/electron/windows.ts b/electron/windows.ts
index 70bacbee2..2f87e6c3d 100644
--- a/electron/windows.ts
+++ b/electron/windows.ts
@@ -326,7 +326,7 @@ export function createNotesWindow(): BrowserWindow {
const win = new BrowserWindow({
width: 400,
height: 540,
- minWidth: 320,
+ minWidth: 360,
minHeight: 400,
maxWidth: 640,
maxHeight: 720,
diff --git a/src/components/launch/NotesToolbar.tsx b/src/components/launch/NotesToolbar.tsx
new file mode 100644
index 000000000..546d76440
--- /dev/null
+++ b/src/components/launch/NotesToolbar.tsx
@@ -0,0 +1,139 @@
+import type { Editor } from "@tiptap/react";
+import { Bold, Code, Italic, List, ListOrdered, Quote, Strikethrough } from "lucide-react";
+import { type ReactNode, useEffect, useReducer } from "react";
+import { cn } from "@/lib/utils";
+
+type NotesToolbarProps = {
+ editor: Editor | null;
+};
+
+type ToolbarButtonProps = {
+ "aria-label": string;
+ active?: boolean;
+ disabled?: boolean;
+ onClick: () => void;
+ children: ReactNode;
+};
+
+function ToolbarButton({
+ "aria-label": ariaLabel,
+ active = false,
+ disabled = false,
+ onClick,
+ children,
+}: ToolbarButtonProps) {
+ return (
+ <button
+ type="button"
+ aria-label={ariaLabel}
+ aria-pressed={active}
+ disabled={disabled}
+ onClick={onClick}
+ className={cn(
+ "shrink-0 inline-flex h-8 w-8 items-center justify-center rounded-md border-0 bg-transparent text-gray-700 transition-colors hover:bg-gray-200 hover:text-gray-900 disabled:cursor-not-allowed disabled:opacity-35",
+ active && "bg-gray-900 text-white hover:bg-gray-800 hover:text-white",
+ )}
+ >
+ {children}
+ </button>
+ );
+}
+
+function useEditorRevision(editor: Editor | null): void {
+ const [, bumpRevision] = useReducer((revision: number) => revision + 1, 0);
+
+ useEffect(() => {
+ if (!editor) {
+ return;
+ }
+
+ const handleUpdate = () => {
+ bumpRevision();
+ };
+
+ editor.on("selectionUpdate", handleUpdate);
+ editor.on("transaction", handleUpdate);
+
+ return () => {
+ editor.off("selectionUpdate", handleUpdate);
+ editor.off("transaction", handleUpdate);
+ };
+ }, [editor]);
+}
+
+export function NotesToolbar({ editor }: NotesToolbarProps) {
+ useEditorRevision(editor);
+
+ return (
+ <div className="flex items-center gap-1 rounded-[0.625rem] max-w-fit border border-gray-200 bg-gray-50 p-1.5 overflow-scroll no-scrollbar">
+ <div className="flex items-center justify-between flex-1 shrink-0 gap-1">
+ <ToolbarButton
+ aria-label="Bold"
+ active={editor?.isActive("bold") ?? false}
+ disabled={!editor?.can().chain().focus().toggleBold().run()}
+ onClick={() => editor?.chain().focus().toggleBold().run()}
+ >
+ <Bold size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label="Italic"
+ active={editor?.isActive("italic") ?? false}
+ disabled={!editor?.can().chain().focus().toggleItalic().run()}
+ onClick={() => editor?.chain().focus().toggleItalic().run()}
+ >
+ <Italic size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label="Strikethrough"
+ active={editor?.isActive("strike") ?? false}
+ disabled={!editor?.can().chain().focus().toggleStrike().run()}
+ onClick={() => editor?.chain().focus().toggleStrike().run()}
+ >
+ <Strikethrough size={16} />
+ </ToolbarButton>
+ </div>
+ <div className="flex items-center justify-between flex-1 shrink-0 gap-1">
+ <div className="h-8 w-5 grid place-content-center">
+ <span className="mx-0.5 h-5 w-px bg-gray-300" aria-hidden="true" />
+ </div>
+ <ToolbarButton
+ aria-label="Bullet list"
+ active={editor?.isActive("bulletList") ?? false}
+ disabled={!editor?.can().chain().focus().toggleBulletList().run()}
+ onClick={() => editor?.chain().focus().toggleBulletList().run()}
+ >
+ <List size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label="Numbered list"
+ active={editor?.isActive("orderedList") ?? false}
+ disabled={!editor?.can().chain().focus().toggleOrderedList().run()}
+ onClick={() => editor?.chain().focus().toggleOrderedList().run()}
+ >
+ <ListOrdered size={16} />
+ </ToolbarButton>
+ </div>
+ <div className="flex items-center justify-between flex-1 shrink-0 gap-1">
+ <div className="h-8 w-5 grid place-content-center">
+ <span className="mx-0.5 h-5 w-px bg-gray-300" aria-hidden="true" />
+ </div>
+ <ToolbarButton
+ aria-label="Blockquote"
+ active={editor?.isActive("blockquote") ?? false}
+ disabled={!editor?.can().chain().focus().toggleBlockquote().run()}
+ onClick={() => editor?.chain().focus().toggleBlockquote().run()}
+ >
+ <Quote size={16} />
+ </ToolbarButton>
+ <ToolbarButton
+ aria-label="Code block"
+ active={editor?.isActive("codeBlock") ?? false}
+ disabled={!editor?.can().chain().focus().toggleCodeBlock().run()}
+ onClick={() => editor?.chain().focus().toggleCodeBlock().run()}
+ >
+ <Code size={16} />
+ </ToolbarButton>
+ </div>
+ </div>
+ );
+}
diff --git a/src/components/launch/NotesWindow.module.css b/src/components/launch/NotesWindow.module.css
index ee5821362..b0b0cf38a 100644
--- a/src/components/launch/NotesWindow.module.css
+++ b/src/components/launch/NotesWindow.module.css
@@ -1,15 +1,3 @@
-.notesWindow {
- background: #ffffff;
- height: 100vh;
- width: 100vw;
- padding: 1rem 1.5rem;
- overflow: hidden;
-}
-
-.notesEditor {
- height: 100%;
-}
-
/* Tiptap sets class="tiptap" on the ProseMirror root — must be :global to escape CSS modules. */
:global(.tiptap) {
height: 100%;
diff --git a/src/components/launch/NotesWindow.tsx b/src/components/launch/NotesWindow.tsx
index 3829d9638..ea6f9b2a3 100644
--- a/src/components/launch/NotesWindow.tsx
+++ b/src/components/launch/NotesWindow.tsx
@@ -1,6 +1,10 @@
import { EditorContent, useEditor } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
-import styles from "./NotesWindow.module.css";
+import { ChevronDown } from "lucide-react";
+import { useState } from "react";
+import { cn } from "@/lib/utils";
+import { NotesToolbar } from "./NotesToolbar";
+import "./NotesWindow.module.css";
function getInitialNotesContent(): string {
const stored = localStorage.getItem("notes");
@@ -33,8 +37,12 @@ export function NotesWindow() {
});
return (
- <div className={styles.notesWindow}>
- <EditorContent editor={editor} className={styles.notesEditor} />
+ <div className="flex h-screen w-screen flex-col overflow-hidden bg-white px-6 pb-4 pt-3 gap-4">
+ <div className="shrink-0 flex justify-center">
+ <NotesToolbar editor={editor} />
+ </div>
+
+ <EditorContent editor={editor} className="min-h-0 flex-1" />
</div>
);
}