Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions apps/desktop2/src/components/main/body/daily.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { format } from "date-fns";
import { CalendarIcon, CheckSquare, Mail, Sun } from "lucide-react";

import { type Tab } from "../../../store/zustand/tabs";
import { type TabItem, TabItemBase } from "./shared";

export const TabItemDaily: TabItem = ({ tab, handleClose, handleSelect }) => {
return (
<TabItemBase
icon={<Sun className="w-4 h-4" />}
title={tab.type === "daily" ? format(tab.date, "MMM d, yyyy") : "Daily Note"}
active={tab.active}
handleClose={() => handleClose(tab)}
handleSelect={() => handleSelect(tab)}
/>
);
};

export function TabContentDaily({ tab }: { tab: Tab }) {
if (tab.type !== "daily") {
return null;
}

return (
<div className="h-full rounded-lg border bg-white p-6">
<h1 className="text-2xl font-semibold mb-6">{format(tab.date, "MMM d, yyyy")}</h1>

<div className="grid grid-cols-2 gap-6">
<div>
<h2 className="text-lg font-semibold mb-4">Task</h2>
<div className="space-y-2">
{[1, 2, 3].map((i) => (
<div key={i} className="flex items-center gap-2 p-2 hover:bg-neutral-50 rounded">
<CheckSquare className="w-4 h-4 text-neutral-400" />
<span className="text-sm">task {i}</span>
</div>
))}
</div>
</div>

<div>
<h2 className="text-lg font-semibold mb-4">Email</h2>
<div className="space-y-2">
{[1, 2, 3].map((i) => (
<div key={i} className="flex items-center gap-2 p-2 hover:bg-neutral-50 rounded">
<Mail className="w-4 h-4 text-neutral-400" />
<span className="text-sm">email {i}</span>
</div>
))}
</div>
</div>

<div className="col-span-2">
<h2 className="text-lg font-semibold mb-4">Event</h2>
<div className="space-y-2">
{[1, 2, 3].map((i) => (
<div key={i} className="flex items-center gap-2 p-2 hover:bg-neutral-50 rounded">
<CalendarIcon className="w-4 h-4 text-neutral-400" />
<span className="text-sm">event {i}</span>
</div>
))}
</div>
</div>
</div>
</div>
);
}
7 changes: 7 additions & 0 deletions apps/desktop2/src/components/main/body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { type Tab, uniqueIdfromTab, useTabs } from "../../../store/zustand/tabs"
import { useLeftSidebar } from "@hypr/utils/contexts";
import { TabContentCalendar, TabItemCalendar } from "./calendars";
import { TabContentContact, TabItemContact } from "./contacts";
import { TabContentDaily, TabItemDaily } from "./daily";
import { TabContentEvent, TabItemEvent } from "./events";
import { TabContentFolder, TabItemFolder } from "./folders";
import { TabContentHuman, TabItemHuman } from "./humans";
Expand Down Expand Up @@ -93,6 +94,9 @@ function TabItem(
if (tab.type === "humans") {
return <TabItemHuman tab={tab} handleClose={handleClose} handleSelect={handleSelect} />;
}
if (tab.type === "daily") {
return <TabItemDaily tab={tab} handleClose={handleClose} handleSelect={handleSelect} />;
}

if (tab.type === "calendars") {
return <TabItemCalendar tab={tab} handleClose={handleClose} handleSelect={handleSelect} />;
Expand All @@ -117,6 +121,9 @@ function Content({ tab }: { tab: Tab }) {
if (tab.type === "humans") {
return <TabContentHuman tab={tab} />;
}
if (tab.type === "daily") {
return <TabContentDaily tab={tab} />;
}

if (tab.type === "calendars") {
return <TabContentCalendar tab={tab} />;
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop2/src/components/main/body/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function TabItemBase(
<div
onClick={handleSelect}
className={clsx([
"flex items-center gap-2 cursor-pointer",
"flex items-center gap-2 cursor-pointer group",
"min-w-[100px] max-w-[200px] h-full px-2",
active
? "bg-background text-foreground rounded-lg border"
Expand All @@ -40,10 +40,10 @@ export function TabItemBase(
handleClose();
}}
className={clsx([
"text-xs flex-shrink-0",
"text-xs flex-shrink-0 transition-opacity",
active
? "text-muted-foreground hover:text-foreground"
: "opacity-0 pointer-events-none",
: "opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-foreground",
])}
>
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop2/src/components/main/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { clsx } from "clsx";
import { PanelLeftCloseIcon } from "lucide-react";

import { useLeftSidebar } from "@hypr/utils/contexts";
import { NewNoteButton } from "./new-note-button";
import { ProfileSection } from "./profile";
import { TimelineView } from "./timeline";

Expand All @@ -27,6 +28,7 @@ export function LeftSidebar() {
</header>

<div className="flex flex-col flex-1 overflow-hidden p-1 gap-1">
<NewNoteButton />
<TimelineView />
<ProfileSection />
</div>
Expand Down
34 changes: 34 additions & 0 deletions apps/desktop2/src/components/main/sidebar/new-note-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { PencilIcon } from "lucide-react";
import { useCallback } from "react";

import { Button } from "@hypr/ui/components/ui/button";
import { cn } from "@hypr/ui/lib/utils";
import { useTabs } from "../../../store/zustand/tabs";

export function NewNoteButton() {
const { openNew } = useTabs();

const handleCreateNote = useCallback(() => {
openNew({
type: "sessions",
id: crypto.randomUUID(),
active: true,
state: { editor: "raw" },
});
}, [openNew]);

return (
<Button
className={cn(
"w-full",
"rounded-lg py-3",
"flex items-center justify-center gap-2",
"text-white bg-gray-900 hover:bg-gray-900/90",
)}
onClick={handleCreateNote}
>
<PencilIcon className="w-4 h-4" />
Create new note
</Button>
);
}
4 changes: 2 additions & 2 deletions apps/desktop2/src/components/main/sidebar/profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export function ProfileSection() {
}, [openNew, closeMenu]);

const handleClickDailyNote = useCallback(() => {
console.log("Daily note");
openNew({ type: "daily", date: new Date(), active: true });
closeMenu();
}, [closeMenu]);
}, [openNew, closeMenu]);

const menuItems = [
{ icon: FolderOpen, label: "Folders", onClick: handleClickFolders },
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop2/src/store/zustand/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export const tabSchema = z.discriminatedUnion("type", [
type: z.literal("calendars"),
month: z.coerce.date(),
}),
baseTabSchema.extend({
type: z.literal("daily"),
date: z.coerce.date(),
}),
]);

export type Tab = z.infer<typeof tabSchema>;
Expand All @@ -187,6 +191,7 @@ export const rowIdfromTab = (tab: Tab): string => {
return tab.id;
case "calendars":
case "contacts":
case "daily":
throw new Error("invalid_resource");
case "folders":
if (!tab.id) {
Expand All @@ -210,6 +215,8 @@ export const uniqueIdfromTab = (tab: Tab): string => {
return `calendars-${tab.month.getFullYear()}-${tab.month.getMonth()}`;
case "contacts":
return `contacts`;
case "daily":
return `daily-${tab.date.getFullYear()}-${tab.date.getMonth()}-${tab.date.getDate()}`;
case "folders":
return `folders-${tab.id ?? "all"}`;
}
Expand Down
Loading