-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lib package, static dashboard UI components
- Loading branch information
1 parent
07f9e71
commit d7b6fe4
Showing
17 changed files
with
252 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
apps/web/src/features/routing/routes/dashboard/components/dashboard-header/aphorism.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getRandomElement } from "@manifold/lib/utils/array"; | ||
|
||
const SOURCES = { | ||
dashboard: [ | ||
"Do you feel lucky?", | ||
"You're in the right place.", | ||
"What chance will fate decide today?", | ||
] as const satisfies string[], | ||
} as const; | ||
|
||
export function Aphorism({ | ||
source, | ||
className, | ||
}: { | ||
source: keyof typeof SOURCES; | ||
className?: string; | ||
}) { | ||
return <span className={className}>{getRandomElement(SOURCES[source])}</span>; | ||
} |
47 changes: 47 additions & 0 deletions
47
apps/web/src/features/routing/routes/dashboard/components/dashboard-header/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useSession } from "@manifold/auth/client"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "@manifold/ui/components/ui/card"; | ||
import { cn } from "@manifold/ui/lib/utils"; | ||
|
||
import { QuickLauncher } from "../quick-launcher"; | ||
import { Aphorism } from "./aphorism"; | ||
|
||
function getGreeting(isAuthenticated: boolean, name?: string) { | ||
if (isAuthenticated && name) { | ||
return `Hello, ${name.split(" ")[0]} ✌️`; | ||
} | ||
|
||
return "Hello, stranger! 👋"; | ||
} | ||
|
||
export function DashboardHeader({ className }: { className?: string }) { | ||
const auth = useSession(); | ||
|
||
return ( | ||
<Card className={cn("flex flex-col sm:flex-row sm:gap-16", className)}> | ||
<CardHeader> | ||
<CardTitle> | ||
{getGreeting(auth.status === "authenticated", auth.data?.user?.name)} | ||
</CardTitle> | ||
|
||
<CardDescription> | ||
<Aphorism source="dashboard" /> | ||
</CardDescription> | ||
</CardHeader> | ||
|
||
<CardContent | ||
flush={false} | ||
className="flex-grow pt-0 sm:!p-16 overflow-auto" | ||
> | ||
<QuickLauncher /> | ||
</CardContent> | ||
</Card> | ||
); | ||
|
||
// <h2 className="mb-16">{greeting}</h2>; | ||
} |
42 changes: 42 additions & 0 deletions
42
apps/web/src/features/routing/routes/dashboard/components/quick-launcher/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Button } from "@manifold/ui/components/ui/button"; | ||
import { Card, CardContent } from "@manifold/ui/components/ui/card"; | ||
|
||
const ITEMS = [ | ||
{ | ||
title: "Cryptids", | ||
}, | ||
{ | ||
title: "UFOs", | ||
}, | ||
{ | ||
title: "Ghosts", | ||
}, | ||
{ | ||
title: "Deities", | ||
}, | ||
{ | ||
title: "Potions", | ||
}, | ||
]; | ||
|
||
export function QuickLauncher() { | ||
return ( | ||
<section className="flex gap-12 sm:gap-16"> | ||
{ITEMS.map((item) => { | ||
return <QuickLaunchTile key={item.title} item={item} />; | ||
})} | ||
</section> | ||
); | ||
} | ||
|
||
function QuickLaunchTile({ item }: { item: { title: string } }) { | ||
return ( | ||
<Card> | ||
<CardContent className="!p-0 flex items-center h-full"> | ||
<Button className="w-full h-full p-24" variant="link"> | ||
<h3>{item.title}</h3> | ||
</Button> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
63 changes: 63 additions & 0 deletions
63
apps/web/src/features/routing/routes/dashboard/components/table-list/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Button } from "@manifold/ui/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardHeader, | ||
CardTitle, | ||
} from "@manifold/ui/components/ui/card"; | ||
|
||
const TABLES = [ | ||
{ | ||
id: 1, | ||
title: "Cryptids", | ||
}, | ||
{ | ||
id: 2, | ||
title: "UFOs", | ||
}, | ||
{ | ||
id: 3, | ||
title: "Ghosts", | ||
}, | ||
{ | ||
id: 4, | ||
title: "Deities", | ||
}, | ||
{ | ||
id: 5, | ||
title: "Potions", | ||
}, | ||
]; | ||
|
||
export function TableList() { | ||
return ( | ||
<Card> | ||
<CardHeader> | ||
{/* @TODO: Maybe this is a dropdown - recent/created at/used */} | ||
<CardTitle>Recently Edited:</CardTitle> | ||
</CardHeader> | ||
|
||
<CardContent className="grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] gap-12 sm:gap-16"> | ||
{TABLES.map((table) => { | ||
return ( | ||
<div key={table.id} className="border rounded-sm"> | ||
<div className="w-full aspect-square"> | ||
<Button | ||
className="group w-full h-full flex flex-col items-center justify-center p-16 gap-6 !no-underline" | ||
variant="link" | ||
> | ||
<h3 className="text-lg sm:text-xl group-hover:underline decoration-from-font underline-offset-2"> | ||
{table.title} | ||
</h3> | ||
<span className="text-gray-500 text-sm text-balance text-center"> | ||
Last edited 2 days ago | ||
</span> | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
import { useSession } from "@manifold/auth/client"; | ||
|
||
import { Editor } from "#features/editor/editor.tsx"; | ||
import { DashboardHeader } from "./components/dashboard-header"; | ||
import { TableList } from "./components/table-list"; | ||
|
||
export function Component() { | ||
const auth = useSession(); | ||
|
||
let greeting = "Hello"; | ||
if (auth.status === "authenticated") { | ||
greeting = `Hello, ${auth.data?.user?.name.split(" ")[0]} ✌️`; | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col grow p-12 sm:p-16 min-h-0"> | ||
<h2 className="mb-16">{greeting}</h2> | ||
<Editor /> | ||
<div className="flex flex-col grow p-12 sm:p-16 min-h-0 space-y-12 sm:space-y-16"> | ||
<DashboardHeader /> | ||
<TableList /> | ||
</div> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
root: true, | ||
extends: ["@manifold/eslint-config/index.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# `@manifold/lib` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@manifold/lib", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"imports": { | ||
"#*": "./src/*" | ||
}, | ||
"exports": { | ||
".": "./src/index.ts", | ||
"./*": "./src/*.ts" | ||
}, | ||
"scripts": { | ||
"dev": "echo 'Add dev script here'", | ||
"build": "echo 'Add build script here'", | ||
"test": "echo 'Add test script here'", | ||
"lint": "echo 'Add lint script here'" | ||
}, | ||
"devDependencies": { | ||
"@manifold/eslint-config": "*", | ||
"@manifold/typescript-config": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function getRandomElement<T>(arr: T[]): T { | ||
return arr[Math.floor(Math.random() * arr.length)]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "@manifold/typescript-config/base.json", | ||
"include": ["src"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters