feat: Add themes marketplace page and components
This commit is contained in:
14
src/app/themes/page.tsx
Normal file
14
src/app/themes/page.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
import Footer from "@/components/footer";
|
||||
import MarketplacePage from "@/components/marketplace";
|
||||
import { Navigation } from "@/components/navigation";
|
||||
|
||||
export default function ThemesMarketplace() {
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center justify-start">
|
||||
<MarketplacePage />
|
||||
<Footer />
|
||||
<Navigation /> {/* At the bottom of the page */}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
28
src/components/marketplace.tsx
Normal file
28
src/components/marketplace.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
import React from "react";
|
||||
import ThemesSearch from "./themes-search";
|
||||
import { getAllThemes, getThemesFromSearch, ZenTheme } from "@/lib/themes";
|
||||
import ThemeCard from "./theme-card";
|
||||
|
||||
export default function MarketplacePage() {
|
||||
const [searchInput, setSearchInput] = React.useState("");
|
||||
const [themes, setThemes] = React.useState<ZenTheme[]>([]);
|
||||
|
||||
React.useEffect(() => {
|
||||
setThemes(getAllThemes());
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col w-1/2 items-center justify-center h-full mt-36">
|
||||
<div className="mx-auto w-full text-center">
|
||||
<h1 className="text-7xl font-bold">Themes Marketplace</h1>
|
||||
<ThemesSearch input={searchInput} setInput={setSearchInput} />
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-8 mt-10 w-full">
|
||||
{getThemesFromSearch(themes, searchInput).map((theme) => (
|
||||
<ThemeCard key={theme.name} theme={theme} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -42,6 +42,12 @@ export function MobileNav() {
|
||||
>
|
||||
Download
|
||||
</MobileLink>
|
||||
<MobileLink
|
||||
href="/themes"
|
||||
onOpenChange={setOpen}
|
||||
>
|
||||
Themes
|
||||
</MobileLink>
|
||||
<MobileLink
|
||||
href="/release-notes"
|
||||
onOpenChange={setOpen}
|
||||
|
||||
@@ -29,6 +29,11 @@ export const components: { title: string; href: string; description: string }[]
|
||||
href: "https://discord.gg/nnShMQzR4b",
|
||||
description: "Join our Discord server to chat with the community."
|
||||
},
|
||||
{
|
||||
title: "Source Code",
|
||||
href: "https://github.com/zen-browser",
|
||||
description: "Check out our source code on GitHub and leave a star!"
|
||||
},
|
||||
]
|
||||
|
||||
export function Navigation() {
|
||||
@@ -66,8 +71,8 @@ export function Navigation() {
|
||||
<ListItem href="/download" title="Download">
|
||||
Start using Zen Browser today with just a few clicks.
|
||||
</ListItem>
|
||||
<ListItem href="https://github.com/zen-browser" title="Source Code" target="_blank">
|
||||
View the source code on GitHub and maybe leave a star!
|
||||
<ListItem href="/themes" title="Themes Marketplace">
|
||||
Customize your browser with a variety of themes!
|
||||
</ListItem>
|
||||
<ListItem href="/release-notes" title="Release Notes">
|
||||
Stay up to date with the latest changes.
|
||||
|
||||
41
src/components/theme-card.tsx
Normal file
41
src/components/theme-card.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { ZenTheme } from "@/lib/themes";
|
||||
import styled from "styled-components";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from "./ui/dialog";
|
||||
import { Button } from "./ui/button";
|
||||
|
||||
const ThemeCardWrapepr = styled.div`
|
||||
`;
|
||||
|
||||
export default function ThemeCard({
|
||||
theme
|
||||
}: {
|
||||
theme: ZenTheme;
|
||||
}) {
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger>
|
||||
<ThemeCardWrapepr className="flex flex-col justify-start p-6 rounded-lg shadow-md bg-muted/50 border border-muted w-full hover:shadow-lg transition duration-300 ease-in-out hover:bg-muted/100 hover:border-blue-500 cursor-pointer select-none">
|
||||
<img src={theme.image} alt={theme.name} className="w-full h-32 object-cover rounded-md" />
|
||||
<h2 className="text-xl font-bold mt-4 overflow-ellipsis text-start">{theme.name}</h2>
|
||||
<p className="text-md mt-2 overflow-ellipsis text-muted-foreground text-start">{theme.description}</p>
|
||||
</ThemeCardWrapepr>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<img src={theme.image} alt={theme.name} className="w-full h-32 object-cover rounded-md mb-10" />
|
||||
<DialogTitle>{theme.name}</DialogTitle>
|
||||
<DialogDescription>{theme.description}</DialogDescription>
|
||||
<hr className="!my-4" />
|
||||
<div className="w-full relative flex justify-end">
|
||||
<Button className="hidden install-theme" zen-theme-id={theme.id}>
|
||||
Install Theme
|
||||
</Button>
|
||||
<p className="text-muted-foreground text-sm install-theme-error">
|
||||
You need to have Zen Browser installed to use this theme. <a href="/download" className="text-blue-500">Download</a>
|
||||
</p>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
21
src/components/themes-search.tsx
Normal file
21
src/components/themes-search.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { SearchIcon } from "lucide-react";
|
||||
|
||||
export default function ThemesSearch({
|
||||
input, setInput
|
||||
}: {
|
||||
input: string;
|
||||
setInput: (input: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex w-full p-2 bg-muted/50 rounded-full mt-10 items-center border border-muted">
|
||||
<SearchIcon className="w-6 h-6 mx-4 text-muted" />
|
||||
<input
|
||||
type="text"
|
||||
value={input}
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
placeholder="Search themes"
|
||||
className="w-full bg-transparent border-none focus:outline-none focus:border-none focus:ring-0 text-white placeholder-muted"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
126
src/components/ui/dialog.tsx
Normal file
126
src/components/ui/dialog.tsx
Normal file
@@ -0,0 +1,126 @@
|
||||
'use client'
|
||||
|
||||
import * as React from 'react'
|
||||
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
||||
import { Cross2Icon } from '@radix-ui/react-icons'
|
||||
|
||||
import { ny } from '@/lib/utils'
|
||||
|
||||
const Dialog = DialogPrimitive.Root
|
||||
|
||||
const DialogTrigger = DialogPrimitive.Trigger
|
||||
|
||||
const DialogPortal = DialogPrimitive.Portal
|
||||
|
||||
const DialogClose = DialogPrimitive.Close
|
||||
|
||||
const DialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Overlay
|
||||
ref={ref}
|
||||
className={ny(
|
||||
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<DialogPortal>
|
||||
<DialogOverlay />
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={ny(
|
||||
'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none">
|
||||
<Cross2Icon className="size-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPortal>
|
||||
))
|
||||
DialogContent.displayName = DialogPrimitive.Content.displayName
|
||||
|
||||
function DialogHeader({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<div
|
||||
className={ny(
|
||||
'flex flex-col space-y-1.5 text-center sm:text-left',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
DialogHeader.displayName = 'DialogHeader'
|
||||
|
||||
function DialogFooter({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<div
|
||||
className={ny(
|
||||
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
DialogFooter.displayName = 'DialogFooter'
|
||||
|
||||
const DialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Title>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Title
|
||||
ref={ref}
|
||||
className={ny(
|
||||
'text-lg font-semibold leading-none tracking-tight',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogTitle.displayName = DialogPrimitive.Title.displayName
|
||||
|
||||
const DialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Description>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DialogPrimitive.Description
|
||||
ref={ref}
|
||||
className={ny('text-muted-foreground text-sm', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DialogDescription.displayName = DialogPrimitive.Description.displayName
|
||||
|
||||
export {
|
||||
Dialog,
|
||||
DialogPortal,
|
||||
DialogOverlay,
|
||||
DialogTrigger,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogFooter,
|
||||
DialogTitle,
|
||||
DialogDescription,
|
||||
}
|
||||
25
src/lib/themes.ts
Normal file
25
src/lib/themes.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
export interface ZenTheme {
|
||||
name: string
|
||||
description: string
|
||||
image: string
|
||||
downloadUrl: string
|
||||
id: string
|
||||
}
|
||||
|
||||
export function getAllThemes(): ZenTheme[] {
|
||||
// TODO: Fetch themes from the marketplace (database or JSON file)
|
||||
return [
|
||||
{
|
||||
name: "Zen",
|
||||
description: "The default theme for Zen Browser",
|
||||
downloadUrl: "https://zen-browser.app/download", // idrc
|
||||
id: "zen",
|
||||
image: "https://imgs.search.brave.com/qcDBMGuBLvJGLxWR3IkZyg35vROTSZ2omLn_0iLU2rs/rs:fit:860:0:0:0/g:ce/aHR0cHM6Ly9pLnBp/bmltZy5jb20vb3Jp/Z2luYWxzLzgxL2Mz/LzE0LzgxYzMxNDI5/MmViOGM3YzYxNmY5/ZjM3YTRmZDI5ODU4/LmpwZw",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function getThemesFromSearch(themes: ZenTheme[], query: string): ZenTheme[] {
|
||||
return themes.filter((theme) => theme.name.toLowerCase().includes(query.toLowerCase()));
|
||||
}
|
||||
Reference in New Issue
Block a user