chore: Update dependencies and add sync-fetch for theme API
This commit is contained in:
@@ -12,18 +12,17 @@ export default function ThemeCard({
|
||||
theme: ZenTheme;
|
||||
}) {
|
||||
return (
|
||||
<ThemeCardWrapepr onClick={() => {
|
||||
<ThemeCardWrapepr onClick={(event) => {
|
||||
if (event.target instanceof HTMLAnchorElement) return;
|
||||
window.open(`/themes/${theme.id}`, "_self");
|
||||
}} 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 hover:border-blue-500 hover:shadow-lg">
|
||||
<img src={theme.image} alt={theme.name} className="w-full h-32 object-cover rounded-md" />
|
||||
<div className="flex">
|
||||
<h2 className="text-xl font-bold mt-4 overflow-ellipsis text-start">{theme.name}</h2>
|
||||
{theme.homepage && (
|
||||
<a href={theme.homepage} className="text-blue-500 text-md ml-4" target="_blank" rel="noopener noreferrer">
|
||||
Visit Homepage
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
}} className="flex flex-col justify-start p-5 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 hover:border-blue-500 hover:shadow-lg">
|
||||
<img src={theme.image} alt={theme.name} className="w-full h-32 object-cover rounded-lg border shadow" />
|
||||
<h2 className="text-xl font-bold mt-4 overflow-ellipsis text-start">{theme.name}</h2>
|
||||
{theme.homepage && (
|
||||
<a href={theme.homepage} className="text-blue-500 text-md mt-2" target="_blank" rel="noopener noreferrer">
|
||||
Homepage
|
||||
</a>
|
||||
)}
|
||||
<p className="text-md mt-2 overflow-ellipsis text-muted-foreground text-start">{theme.description}</p>
|
||||
</ThemeCardWrapepr>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import fetch from "sync-fetch";
|
||||
|
||||
export interface ZenTheme {
|
||||
name: string
|
||||
@@ -8,17 +9,18 @@ export interface ZenTheme {
|
||||
homepage?: string
|
||||
}
|
||||
|
||||
const THEME_API = "https://zen-browser.github.io/theme-store/themes.json";
|
||||
|
||||
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",
|
||||
},
|
||||
];
|
||||
// Fetch from the API
|
||||
const response = fetch(THEME_API, {});
|
||||
const themes = response.json();
|
||||
// transform in to a ZenTheme[] as it is currently an object
|
||||
let themesArray: ZenTheme[] = [];
|
||||
for (let key in themes) {
|
||||
themesArray.push(themes[key]);
|
||||
}
|
||||
return themesArray;
|
||||
}
|
||||
|
||||
export function getThemesFromSearch(themes: ZenTheme[], query: string): ZenTheme[] {
|
||||
|
||||
Reference in New Issue
Block a user