chore: Update dependencies and add sync-fetch for theme API
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
"react-markdown": "^9.0.1",
|
"react-markdown": "^9.0.1",
|
||||||
"react-spring": "^9.7.4",
|
"react-spring": "^9.7.4",
|
||||||
"styled-components": "^6.1.12",
|
"styled-components": "^6.1.12",
|
||||||
|
"sync-fetch": "^0.5.2",
|
||||||
"tailwind-merge": "^2.5.1",
|
"tailwind-merge": "^2.5.1",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
"@types/node": "^20.14.15",
|
"@types/node": "^20.14.15",
|
||||||
"@types/react": "^18.3.3",
|
"@types/react": "^18.3.3",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
|
"@types/sync-fetch": "^0.4.3",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-next": "14.2.4",
|
"eslint-config-next": "14.2.4",
|
||||||
"postcss": "^8.4.41",
|
"postcss": "^8.4.41",
|
||||||
|
|||||||
@@ -12,18 +12,17 @@ export default function ThemeCard({
|
|||||||
theme: ZenTheme;
|
theme: ZenTheme;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<ThemeCardWrapepr onClick={() => {
|
<ThemeCardWrapepr onClick={(event) => {
|
||||||
|
if (event.target instanceof HTMLAnchorElement) return;
|
||||||
window.open(`/themes/${theme.id}`, "_self");
|
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">
|
}} 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-md" />
|
<img src={theme.image} alt={theme.name} className="w-full h-32 object-cover rounded-lg border shadow" />
|
||||||
<div className="flex">
|
<h2 className="text-xl font-bold mt-4 overflow-ellipsis text-start">{theme.name}</h2>
|
||||||
<h2 className="text-xl font-bold mt-4 overflow-ellipsis text-start">{theme.name}</h2>
|
{theme.homepage && (
|
||||||
{theme.homepage && (
|
<a href={theme.homepage} className="text-blue-500 text-md mt-2" target="_blank" rel="noopener noreferrer">
|
||||||
<a href={theme.homepage} className="text-blue-500 text-md ml-4" target="_blank" rel="noopener noreferrer">
|
Homepage
|
||||||
Visit Homepage
|
</a>
|
||||||
</a>
|
)}
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<p className="text-md mt-2 overflow-ellipsis text-muted-foreground text-start">{theme.description}</p>
|
<p className="text-md mt-2 overflow-ellipsis text-muted-foreground text-start">{theme.description}</p>
|
||||||
</ThemeCardWrapepr>
|
</ThemeCardWrapepr>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import fetch from "sync-fetch";
|
||||||
|
|
||||||
export interface ZenTheme {
|
export interface ZenTheme {
|
||||||
name: string
|
name: string
|
||||||
@@ -8,17 +9,18 @@ export interface ZenTheme {
|
|||||||
homepage?: string
|
homepage?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const THEME_API = "https://zen-browser.github.io/theme-store/themes.json";
|
||||||
|
|
||||||
export function getAllThemes(): ZenTheme[] {
|
export function getAllThemes(): ZenTheme[] {
|
||||||
// TODO: Fetch themes from the marketplace (database or JSON file)
|
// Fetch from the API
|
||||||
return [
|
const response = fetch(THEME_API, {});
|
||||||
{
|
const themes = response.json();
|
||||||
name: "Zen",
|
// transform in to a ZenTheme[] as it is currently an object
|
||||||
description: "The default theme for Zen Browser",
|
let themesArray: ZenTheme[] = [];
|
||||||
downloadUrl: "https://zen-browser.app/download", // idrc
|
for (let key in themes) {
|
||||||
id: "zen",
|
themesArray.push(themes[key]);
|
||||||
image: "https://imgs.search.brave.com/qcDBMGuBLvJGLxWR3IkZyg35vROTSZ2omLn_0iLU2rs/rs:fit:860:0:0:0/g:ce/aHR0cHM6Ly9pLnBp/bmltZy5jb20vb3Jp/Z2luYWxzLzgxL2Mz/LzE0LzgxYzMxNDI5/MmViOGM3YzYxNmY5/ZjM3YTRmZDI5ODU4/LmpwZw",
|
}
|
||||||
},
|
return themesArray;
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getThemesFromSearch(themes: ZenTheme[], query: string): ZenTheme[] {
|
export function getThemesFromSearch(themes: ZenTheme[], query: string): ZenTheme[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user