Skip to content

Commit

Permalink
feature(web): Add dark mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Mar 23, 2024
1 parent b552f60 commit 47bd449
Show file tree
Hide file tree
Showing 31 changed files with 138 additions and 39 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ A self-hostable bookmark-everything app with a touch of AI for the data hoarders
- ✨ AI-based (aka chatgpt) automatic tagging.
- 🔖 [Chrome plugin](https://chromewebstore.google.com/detail/hoarder/kgcjekpmcjjogibpjebkhaanilehneje) for quick bookmarking.
- 📱 An iOS app that's pending apple's review.
- 🌙 Dark mode support.
- 💾 Self-hosting first.
- [Planned] Archiving the content for offline reading.

Expand Down
11 changes: 6 additions & 5 deletions apps/web/app/dashboard/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useRouter } from "next/navigation";
import { ActionButton } from "@/components/ui/action-button";
import { Separator } from "@/components/ui/separator";
import LoadingSpinner from "@/components/ui/spinner";
import {
Table,
Expand Down Expand Up @@ -96,7 +97,7 @@ function ServerStatsSection() {
</TableRow>
</TableBody>
</Table>
<hr />
<Separator />
<p className="text-xl">Background Jobs</p>
<Table className="w-1/2">
<TableBody>
Expand Down Expand Up @@ -190,13 +191,13 @@ export default function AdminPage() {
}

return (
<div className="m-4 flex flex-col gap-5 rounded-md border bg-white p-4">
<div className="m-4 flex flex-col gap-5 rounded-md border bg-background p-4">
<p className="text-2xl">Admin</p>
<hr />
<Separator />
<ServerStatsSection />
<hr />
<Separator />
<UsersSection />
<hr />
<Separator />
<ActionsSection />
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/dashboard/bookmarks/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import TopNav from "@/components/dashboard/bookmarks/TopNav";
import UploadDropzone from "@/components/dashboard/UploadDropzone";
import { Separator } from "@/components/ui/separator";

export default function BookmarksLayout({
children,
Expand All @@ -13,7 +14,7 @@ export default function BookmarksLayout({
<div>
<TopNav />
</div>
<hr />
<Separator />
<div className="my-4 flex-1 pb-4">{children}</div>
</div>
</UploadDropzone>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function Dashboard({
<div className="hidden flex-none sm:flex">
<Sidebar />
</div>
<main className="flex-1 bg-gray-100 sm:overflow-y-auto">
<main className="flex-1 bg-muted sm:overflow-y-auto">
{serverConfig.demoMode && <DemoModeBanner />}
<div className="block w-full sm:hidden">
<MobileSidebar />
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/dashboard/lists/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AllListsView from "@/components/dashboard/lists/AllListsView";
import { Separator } from "@/components/ui/separator";
import { api } from "@/server/api/client";

export default async function ListsPage() {
Expand All @@ -7,7 +8,7 @@ export default async function ListsPage() {
return (
<div className="container mt-4 flex flex-col gap-3">
<p className="text-2xl">📋 All Lists</p>
<hr />
<Separator />
<AllListsView initialData={lists.lists} />
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/web/app/dashboard/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Suspense, useRef } from "react";
import BookmarksGrid from "@/components/dashboard/bookmarks/BookmarksGrid";
import { SearchInput } from "@/components/dashboard/search/SearchInput";
import { Separator } from "@/components/ui/separator";
import { useBookmarkSearch } from "@/lib/hooks/bookmark-search";

import Loading from "../bookmarks/loading";
Expand All @@ -16,7 +17,7 @@ function SearchComp() {
return (
<div className="container flex flex-col gap-3 p-4">
<SearchInput ref={inputRef} autoFocus={true} />
<hr />
<Separator />
{data ? <BookmarksGrid bookmarks={data.bookmarks} /> : <Loading />}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/dashboard/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChangePassword } from "@/components/dashboard/settings/ChangePassword";

export default async function Settings() {
return (
<div className="m-4 flex flex-col space-y-2 rounded-md border bg-white p-4">
<div className="m-4 flex flex-col space-y-2 rounded-md border bg-background p-4">
<p className="text-2xl">Settings</p>
<ChangePassword />
<ApiKeySettings />
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/dashboard/tags/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getServerAuthSession } from "@/server/auth";
function TagPill({ name, count }: { name: string; count: number }) {
return (
<Link
className="flex gap-2 rounded-md border border-gray-200 bg-white px-2 py-1 text-foreground hover:bg-foreground hover:text-background"
className="flex gap-2 rounded-md border border-border bg-background px-2 py-1 text-foreground hover:bg-foreground hover:text-background"
href={`/dashboard/tags/${name}`}
>
{name} <Separator orientation="vertical" /> {count}
Expand Down Expand Up @@ -38,7 +38,7 @@ export default async function TagsPage() {
return (
<div className="container mt-2 space-y-3">
<span className="text-2xl">All Tags</span>
<hr />
<Separator />
<div className="flex flex-wrap gap-3">{tagPill}</div>
</div>
);
Expand Down
11 changes: 7 additions & 4 deletions apps/web/components/dashboard/bookmarks/BookmarkPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import Image from "next/image";
import Link from "next/link";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
import {
Tooltip,
Expand Down Expand Up @@ -82,7 +83,7 @@ function LinkHeader({ bookmark }: { bookmark: ZBookmark }) {
<span className="my-auto">View Original</span>
<ExternalLink />
</Link>
<hr />
<Separator />
</div>
);
}
Expand All @@ -103,15 +104,17 @@ function TextContentSection({ bookmark }: { bookmark: ZBookmark }) {
dangerouslySetInnerHTML={{
__html: bookmark.content.htmlContent || "",
}}
className="prose mx-auto"
className="prose dark:prose-invert mx-auto"
/>
);
}
break;
}
case "text": {
content = (
<Markdown className="prose mx-auto">{bookmark.content.text}</Markdown>
<Markdown className="prose dark:prose-invert mx-auto">
{bookmark.content.text}
</Markdown>
);
break;
}
Expand Down Expand Up @@ -195,7 +198,7 @@ export default function BookmarkPreview({
<div className="row-span-2 h-full w-full overflow-hidden p-2 md:col-span-2 lg:row-auto">
{isBookmarkStillCrawling(bookmark) ? <ContentLoading /> : content}
</div>
<div className="lg:col-span1 row-span-1 flex flex-col gap-4 bg-gray-100 p-4 lg:row-auto">
<div className="lg:col-span1 row-span-1 flex flex-col gap-4 bg-accent p-4 lg:row-auto">
{linkHeader}
<CreationTime createdAt={bookmark.createdAt} />
<div className="flex gap-2">
Expand Down
3 changes: 2 additions & 1 deletion apps/web/components/dashboard/bookmarks/Bookmarks.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { redirect } from "next/navigation";
import { Separator } from "@/components/ui/separator";
import { api } from "@/server/api/client";
import { getServerAuthSession } from "@/server/auth";

Expand Down Expand Up @@ -27,7 +28,7 @@ export default async function Bookmarks({
return (
<div className="container flex flex-col gap-3">
{header}
{showDivider && <hr />}
{showDivider && <Separator />}
<UpdatableBookmarksGrid
query={query}
bookmarks={bookmarks}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/bookmarks/BookmarksGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import TextCard from "./TextCard";

function BookmarkCard({ children }: { children: React.ReactNode }) {
return (
<Slot className="border-grey-100 mb-4 border bg-gray-50 duration-300 ease-in hover:shadow-lg hover:transition-all">
<Slot className="mb-4 border border-border bg-card duration-300 ease-in hover:shadow-lg hover:transition-all">
{children}
</Slot>
);
Expand Down
5 changes: 3 additions & 2 deletions apps/web/components/dashboard/bookmarks/EditorCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { SubmitErrorHandler, SubmitHandler } from "react-hook-form";
import { ActionButton } from "@/components/ui/action-button";
import { Form, FormControl, FormField, FormItem } from "@/components/ui/form";
import { Separator } from "@/components/ui/separator";
import { Textarea } from "@/components/ui/textarea";
import { toast } from "@/components/ui/use-toast";
import { api } from "@/lib/trpc";
Expand Down Expand Up @@ -55,12 +56,12 @@ export default function EditorCard({ className }: { className?: string }) {
<form
className={cn(
className,
"flex h-96 flex-col gap-2 rounded-xl bg-white p-4",
"flex h-96 flex-col gap-2 rounded-xl bg-card p-4",
)}
onSubmit={form.handleSubmit(onSubmit, onError)}
>
<p className="text-sm">NEW ITEM</p>
<hr />
<Separator />
<FormField
control={form.control}
name="text"
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/bookmarks/LinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function LinkCard({
<div className="mt-1 flex justify-between text-gray-500">
<div className="my-auto">
<Link
className="line-clamp-1 hover:text-black"
className="line-clamp-1 hover:text-foreground"
href={link.url}
target="_blank"
>
Expand Down
26 changes: 23 additions & 3 deletions apps/web/components/dashboard/bookmarks/TagsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ export function TagsEditor({ bookmark }: { bookmark: ZBookmark }) {
closeMenuOnSelect={false}
isClearable={false}
isLoading={isExistingTagsLoading || isMutating}
theme={(theme) => ({
...theme,
// This color scheme doesn't support disabled options.
colors: {
...theme.colors,
primary: "hsl(var(--accent))",
primary50: "hsl(var(--accent))",
primary75: "hsl(var(--accent))",
primary25: "hsl(var(--accent))",
},
})}
styles={{
multiValueRemove: () => ({
"background-color": "transparent",
Expand All @@ -110,6 +121,14 @@ export function TagsEditor({ bookmark }: { bookmark: ZBookmark }) {
overflowY: "auto",
scrollbarWidth: "none",
}),
control: (styles) => ({
...styles,
"background-color": "hsl(var(--background))",
"border-color": "hsl(var(--border))",
":hover": {
"border-color": "hsl(var(--border))",
},
}),
}}
components={{
MultiValueContainer: ({ children, data }) => (
Expand All @@ -118,7 +137,7 @@ export function TagsEditor({ bookmark }: { bookmark: ZBookmark }) {
"flex min-h-8 space-x-1 rounded px-2",
(data as { attachedBy: string }).attachedBy == "ai"
? "bg-gradient-to-tr from-purple-500 to-purple-400 text-white"
: "bg-gray-200",
: "bg-accent",
)}
>
{children}
Expand All @@ -137,8 +156,9 @@ export function TagsEditor({ bookmark }: { bookmark: ZBookmark }) {
}}
classNames={{
multiValueRemove: () => "my-auto",
valueContainer: () => "gap-2",
menuList: () => "text-sm",
valueContainer: () => "gap-2 bg-background",
menuList: () => "text-sm bg-background",
option: () => "text-red-500",
}}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/bookmarks/TextCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function TextCard({
),
)}
>
<Markdown className="prose grow overflow-hidden">
<Markdown className="prose dark:prose-invert grow overflow-hidden">
{bookmarkedText.text}
</Markdown>
<div className="mt-4 flex flex-none flex-wrap gap-1 overflow-hidden">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/lists/AllListsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ListItem({
}) {
return (
<Link href={path}>
<div className="rounded-md border border-gray-200 bg-background px-4 py-2 text-lg">
<div className="rounded-md border border-border bg-background px-4 py-2 text-lg">
<p className="text-nowrap">
{icon} {name}
</p>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/components/dashboard/settings/ApiKeySettings.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Separator } from "@/components/ui/separator";
import {
Table,
TableBody,
Expand All @@ -16,7 +17,7 @@ export default async function ApiKeys() {
return (
<div className="pt-4">
<span className="text-xl">API Keys</span>
<hr className="my-2" />
<Separator className="my-2" />
<div className="flex flex-col space-y-3">
<div className="flex flex-1 justify-end">
<AddApiKey />
Expand Down
3 changes: 2 additions & 1 deletion apps/web/components/dashboard/settings/ChangePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import { toast } from "@/components/ui/use-toast";
import { api } from "@/lib/trpc";
import { zodResolver } from "@hookform/resolvers/zod";
Expand Down Expand Up @@ -55,7 +56,7 @@ export function ChangePassword() {
return (
<div className="w-full pt-4">
<span className="text-xl">Change Password</span>
<hr className="my-2" />
<Separator className="my-2" />
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/dashboard/sidebar/ModileSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SidebarProfileOptions from "./SidebarProfileOptions";
export default async function MobileSidebar() {
return (
<aside className="w-full">
<ul className="flex justify-between space-x-2 border-b-black bg-gray-100 px-5 py-2 pt-5">
<ul className="flex justify-between space-x-2 border-b-black px-5 py-2 pt-5">
<MobileSidebarItem logo={<PackageOpen />} path="/dashboard/bookmarks" />
<MobileSidebarItem logo={<Search />} path="/dashboard/search" />
<MobileSidebarItem logo={<ClipboardList />} path="/dashboard/lists" />
Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/dashboard/sidebar/ModileSidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default function MobileSidebarItem({
return (
<li
className={cn(
"flex w-full rounded-lg hover:bg-gray-50",
path == currentPath ? "bg-gray-50" : "",
"flex w-full rounded-lg hover:bg-background",
path == currentPath ? "bg-background" : "",
)}
>
<Link href={path} className="mx-auto px-3 py-2">
Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/dashboard/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export default async function Sidebar() {
return (
<aside className="flex h-screen w-60 flex-col gap-5 border-r p-4">
<Link href={"/dashboard/bookmarks"}>
<div className="flex items-center rounded-lg px-1 text-slate-900">
<div className="flex items-center rounded-lg px-1 text-foreground">
<PackageOpen />
<span className="ml-2 text-base font-semibold">Hoarder</span>
</div>
</Link>
<hr />
<Separator />
<div>
<ul className="space-y-2 text-sm font-medium">
<SidebarItem
Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/dashboard/sidebar/SidebarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default function SidebarItem({
return (
<li
className={cn(
"rounded-lg px-3 py-2 hover:bg-slate-100",
path == currentPath ? "bg-gray-50" : "",
"rounded-lg px-3 py-2 hover:bg-accent",
path == currentPath ? "bg-accent/50" : "",
className,
)}
>
Expand Down
Loading

0 comments on commit 47bd449

Please sign in to comment.