feat: Add themes marketplace page and components

This commit is contained in:
Mauro Balades
2024-08-14 23:12:22 +02:00
parent ca1540a6c5
commit f16a46a290
8 changed files with 268 additions and 2 deletions

View 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>
);
}

View File

@@ -42,6 +42,12 @@ export function MobileNav() {
>
Download
</MobileLink>
<MobileLink
href="/themes"
onOpenChange={setOpen}
>
Themes
</MobileLink>
<MobileLink
href="/release-notes"
onOpenChange={setOpen}

View File

@@ -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.

View 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>
);
}

View 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>
);
}

View 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,
}