Skip to content

Commit

Permalink
desktop v2 (#5)
Browse files Browse the repository at this point in the history
* desktop v2 basics complete

* rich text task builder

* original build text to retrieve text + trim title text

* add icons on mark

* sort the tasks by default and refetches after actions

* command center + more shortcuts + desktop icons

* fixed the cursor not showing up

* fix small error on delete task dialog + slight UI fixes
  • Loading branch information
vuvincent authored Sep 5, 2023
1 parent 016b820 commit aedd242
Show file tree
Hide file tree
Showing 45 changed files with 7,564 additions and 87 deletions.
3 changes: 3 additions & 0 deletions apps/desktop-v2/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
35 changes: 35 additions & 0 deletions apps/desktop-v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
34 changes: 34 additions & 0 deletions apps/desktop-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
47 changes: 47 additions & 0 deletions apps/desktop-v2/app/alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { ReactNode, useEffect } from "react";
import * as Dialog from "@radix-ui/react-dialog";
import { Button } from "../components/button";
import { Kbd } from "../components/kbd";
import Mousetrap from "mousetrap";

export const AlertDialog = ({
description,
open,
setOpen,
handleSubmit,
}: {
open: boolean;
setOpen: (open: boolean) => void;
description: ReactNode;
handleSubmit: () => void;
}) => {
useEffect(() => {
Mousetrap.bind("enter", (e) => {
e.preventDefault();
handleSubmit();
setOpen(false);
});
return () => {
Mousetrap.unbind("enter");
};
}, [handleSubmit, setOpen]);

return (
<Dialog.Root open={open} onOpenChange={setOpen}>
<Dialog.Portal>
<Dialog.Overlay className={`bg-gray-400 opacity-50 fixed inset-0`} />
<Dialog.Content
className={`bg-white p-3 data-[state=open]:animate-contentShow fixed top-[50%] left-[50%] max-h-[85vh] w-[90vw] max-w-[450px] translate-x-[-50%] translate-y-[-50%] rounded-[6px] shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none`}
>
<div className="flex flex-col">{description}</div>
<div className="flex justify-end">
<Button className="gap-1 pb-2 bg-red-600" onClick={handleSubmit}>
Submit
<Kbd></Kbd>
</Button>
</div>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
);
};
106 changes: 106 additions & 0 deletions apps/desktop-v2/app/command-center.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import * as Dialog from "@radix-ui/react-dialog";
import { Command } from "cmdk";
import Mousetrap from "mousetrap";
import Image from "next/image";
import React from "react";
import { Kbd } from "../components/kbd";
import { SupernovaCommand } from "../types/command";
import { ISupernovaTask } from "../types/supernova-task";
import { twMerge } from "tailwind-merge";
import { ibmPlexMono } from "../components/fonts";

export const SupernovaCommandCenter = ({
commands,
context,
}: {
commands: SupernovaCommand[];
context: {
chosenTask: ISupernovaTask | null;
};
}) => {
const [open, setOpen] = React.useState(false);

React.useEffect(() => {
// open the menu when ⌘K is pressed
const down = (e: Mousetrap.ExtendedKeyboardEvent) => {
e.preventDefault();
setOpen((open) => !open);
};

Mousetrap.bind("mod+k", down);
return () => {
Mousetrap.unbind("mod+k");
};
}, []);

return (
<Dialog.Root open={open} onOpenChange={setOpen}>
<Dialog.Portal>
<Dialog.Overlay className={`bg-gray-400 opacity-50 fixed inset-0`} />
<Dialog.Content
className={`data-[state=open]:animate-contentShow fixed top-[50%] left-[50%] max-h-[85vh] w-[90vw] max-w-[450px] translate-x-[-50%] translate-y-[-50%] rounded-[6px] shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] focus:outline-none`}
>
<Command className="bg-white rounded-lg p-4 flex flex-col gap-2">
{context.chosenTask !== null && (
<div>
<p
className={twMerge(
"text-xs text-slate-300",
ibmPlexMono.className
)}
>
{">"}{" "}
{context.chosenTask !== null
? '"' + context.chosenTask.title + '"'
: "No task selected"}
</p>
</div>
)}
<div className="flex items-center gap-2">
<Image
src={"/supernova-globe.svg"}
width={20}
height={20}
alt="Supernova's logo"
priority
/>
<Command.Input
placeholder="Find a command..."
className="outline-none"
autoFocus
/>
</div>
<Command.Separator alwaysRender className="h-[1px] bg-gray-300" />
<Command.List className="flex flex-col gap-2">
<Command.Empty className="text-slate-300 text-center">
No results found.
</Command.Empty>

{commands.map((command) => (
<Command.Item
key={command.label}
className=" data-[selected='true']:bg-slate-100 flex items-center gap-2 justify-between hover:bg-slate-200 rounded-md px-2 py-1"
onSelect={() => {
setOpen(false);
command.cb();
}}
>
<p>{command.label}</p>
{Array.isArray(command.shortcut) ? (
<div className="flex items-center gap-2">
{command.shortcut.map((key) => (
<Kbd key={key}>{key}</Kbd>
))}
</div>
) : (
<Kbd>{command.shortcut}</Kbd>
)}
</Command.Item>
))}
</Command.List>
</Command>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
);
};
Binary file added apps/desktop-v2/app/favicon.ico
Binary file not shown.
7 changes: 7 additions & 0 deletions apps/desktop-v2/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

body {
background-color: white;
}
7 changes: 7 additions & 0 deletions apps/desktop-v2/app/icons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Image from "next/image";

export const arrowRightPath = "/icons/arrow-right.svg";

export const ArrowRightIcon = () => (
<Image src={arrowRightPath} width={20} height={20} alt="Arrow Right" />
);
25 changes: 25 additions & 0 deletions apps/desktop-v2/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import "./globals.css";
import type { Metadata } from "next";
import { Manrope } from "next/font/google";

const manrope = Manrope({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Supernova",
};

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={manrope.className}>
{/* drag region because titlebar is overlay */}
<div data-tauri-drag-region="self" className="h-5" />
{children}
</body>
</html>
);
}
1 change: 1 addition & 0 deletions apps/desktop-v2/app/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const homeRoute = "/";
Loading

0 comments on commit aedd242

Please sign in to comment.