From 85c31ee8d278ac6fa1f0ba143b78d65e5f665f32 Mon Sep 17 00:00:00 2001 From: Tyler Flowers Date: Sun, 26 Nov 2023 15:57:52 -0500 Subject: initial cleanup --- apps/website/src/components/logos/Logo.astro | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'apps/website/src/components/logos') diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro index 2fd6bea..0b72b91 100644 --- a/apps/website/src/components/logos/Logo.astro +++ b/apps/website/src/components/logos/Logo.astro @@ -1,7 +1,5 @@ --- import type { LogoType } from "@webtypes/Config"; -import { dirname } from "path"; -import { fileURLToPath } from "url"; import type { HTMLAttributes } from "astro/types"; export interface Props extends HTMLAttributes<"svg"> { @@ -20,7 +18,7 @@ let svg: string | undefined; try { if (logo == undefined) return; - const dir = dirname(fileURLToPath(import.meta.url)) + "/../../../public/media"; + const dir = "../../../public/media"; svg = (await import(`${dir}/${logo.replaceAll(".", "/")}.svg?raw` /* @vite-ignore */)).default; if (svg == undefined) return; @@ -44,7 +42,8 @@ try { svg = svg.replace(/ `${key}="${value}"`).join(" ")}`); } catch (err) { - + console.error(`Error occurred while loading SVG. Logo name is ${logo}.`) + console.error(err); } --- -- cgit From e9d485fe3b5db8c426ac03b30ed8917df0baa62d Mon Sep 17 00:00:00 2001 From: Pauline Date: Sun, 26 Nov 2023 17:13:07 -0500 Subject: feat(lint): switch to eslint config and formatting (use vscode for autoformat) --- apps/website/src/components/logos/Logo.astro | 78 +++++++++++++++------------- 1 file changed, 41 insertions(+), 37 deletions(-) (limited to 'apps/website/src/components/logos') diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro index 0b72b91..ad41aad 100644 --- a/apps/website/src/components/logos/Logo.astro +++ b/apps/website/src/components/logos/Logo.astro @@ -1,51 +1,55 @@ --- -import type { LogoType } from "@webtypes/Config"; -import type { HTMLAttributes } from "astro/types"; +import type { LogoType } from '@webtypes/Config'; +import type { HTMLAttributes } from 'astro/types'; -export interface Props extends HTMLAttributes<"svg"> { - logo: LogoType, - size?: number | [number, number], - silent?: boolean, +export interface Props extends HTMLAttributes<'svg'> { + logo: LogoType + size?: number | [number, number] + silent?: boolean } const { - logo, - silent = false, - size = undefined, - ...attr + logo, + silent = false, + size = undefined, + ...attr } = Astro.props; let svg: string | undefined; try { - if (logo == undefined) return; - const dir = "../../../public/media"; - svg = (await import(`${dir}/${logo.replaceAll(".", "/")}.svg?raw` /* @vite-ignore */)).default; - - if (svg == undefined) return; - - if (typeof size == "number" || Array.isArray(size)) { - // SVG main element regex - const svgElementRegex = /]*>/; - - svg = svg.replace(svgElementRegex, (match) => { - let newMatch = match; - if (typeof size == "number") { - newMatch = newMatch.replace(/width="[^"]*"/, `width="${size}"`); - newMatch = newMatch.replace(/height="[^"]*"/, `height="${size}"`); - } else if (Array.isArray(size)) { - newMatch = newMatch.replace(/width="[^"]*"/, `width="${size[0]}"`); - newMatch = newMatch.replace(/height="[^"]*"/, `height="${size[1]}"`); - } - return newMatch; - }); - } - - svg = svg.replace(/ `${key}="${value}"`).join(" ")}`); -} catch (err) { - console.error(`Error occurred while loading SVG. Logo name is ${logo}.`) + if (logo == undefined) + return; + const dir = '../../../public/media'; + svg = (await import(`${dir}/${logo.replaceAll('.', '/')}.svg?raw` /* @vite-ignore */)).default; + + if (svg == undefined) + return; + + if (typeof size == 'number' || Array.isArray(size)) { + // SVG main element regex + const svgElementRegex = /]*>/; + + svg = svg.replace(svgElementRegex, (match) => { + let newMatch = match; + if (typeof size == 'number') { + newMatch = newMatch.replace(/width="[^"]*"/, `width="${size}"`); + newMatch = newMatch.replace(/height="[^"]*"/, `height="${size}"`); + } + else if (Array.isArray(size)) { + newMatch = newMatch.replace(/width="[^"]*"/, `width="${size[0]}"`); + newMatch = newMatch.replace(/height="[^"]*"/, `height="${size[1]}"`); + } + return newMatch; + }); + } + + svg = svg.replace(/ `${key}="${value}"`).join(' ')}`); +} +catch (err) { + console.error(`Error occurred while loading SVG. Logo name is ${logo}.`); console.error(err); } --- - + -- cgit From 8e85be96a154b371b4cf1fb1924155d96150f949 Mon Sep 17 00:00:00 2001 From: Pauline Date: Wed, 20 Dec 2023 01:58:22 -0500 Subject: chore(lint): bump deps and fix linting/format --- apps/website/src/components/logos/Logo.astro | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'apps/website/src/components/logos') diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro index ad41aad..52bfe34 100644 --- a/apps/website/src/components/logos/Logo.astro +++ b/apps/website/src/components/logos/Logo.astro @@ -10,19 +10,18 @@ export interface Props extends HTMLAttributes<'svg'> { const { logo, - silent = false, size = undefined, ...attr } = Astro.props; let svg: string | undefined; try { - if (logo == undefined) + if (logo === undefined) return; const dir = '../../../public/media'; svg = (await import(`${dir}/${logo.replaceAll('.', '/')}.svg?raw` /* @vite-ignore */)).default; - if (svg == undefined) + if (svg === undefined) return; if (typeof size == 'number' || Array.isArray(size)) { @@ -52,4 +51,4 @@ catch (err) { --- - + -- cgit From 6dbef7946abd350bbfb5cfe21d5f6c1b5e969011 Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:31:57 +0100 Subject: Update Icon Types + fix type issues in oneconfig page --- apps/website/src/components/logos/Logo.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/website/src/components/logos') diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro index 52bfe34..c2333e1 100644 --- a/apps/website/src/components/logos/Logo.astro +++ b/apps/website/src/components/logos/Logo.astro @@ -19,7 +19,7 @@ try { if (logo === undefined) return; const dir = '../../../public/media'; - svg = (await import(`${dir}/${logo.replaceAll('.', '/')}.svg?raw` /* @vite-ignore */)).default; + svg = (await import(/* @vite-ignore */ `${dir}/${logo.replaceAll('.', '/')}.svg?raw`)).default; if (svg === undefined) return; -- cgit From 530634fea254c344684d42fe7a1d5b4020f6a3ab Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:29:16 +0100 Subject: Footer + small tweaks --- apps/website/src/components/logos/Logo.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/website/src/components/logos') diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro index c2333e1..7988092 100644 --- a/apps/website/src/components/logos/Logo.astro +++ b/apps/website/src/components/logos/Logo.astro @@ -51,4 +51,4 @@ catch (err) { --- - + -- cgit From 0225e2e17d12a32467bc12f33b2402287c79e23f Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Sat, 20 Jan 2024 11:27:36 +0100 Subject: Fixed icon system --- apps/website/src/components/logos/Logo.astro | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'apps/website/src/components/logos') diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro index 7988092..6b085fa 100644 --- a/apps/website/src/components/logos/Logo.astro +++ b/apps/website/src/components/logos/Logo.astro @@ -1,4 +1,6 @@ --- +import { readFile } from 'node:fs/promises'; +import { join } from 'node:path'; import type { LogoType } from '@webtypes/Config'; import type { HTMLAttributes } from 'astro/types'; @@ -18,8 +20,9 @@ let svg: string | undefined; try { if (logo === undefined) return; - const dir = '../../../public/media'; - svg = (await import(/* @vite-ignore */ `${dir}/${logo.replaceAll('.', '/')}.svg?raw`)).default; + + const dir = new URL(join('..', '..', '..', 'public', 'media'), import.meta.url).pathname; + svg = (await readFile(`${dir}/${logo.replaceAll('.', '/')}.svg`, { encoding: 'utf8' })); if (svg === undefined) return; -- cgit From 55548a94b61ce7d1ca0ca8da69db7566f937cfeb Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Sat, 20 Jan 2024 17:26:36 +0100 Subject: FIX THE ICON SYSTEM --- apps/website/src/components/logos/Logo.astro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/website/src/components/logos') diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro index 6b085fa..cd780ad 100644 --- a/apps/website/src/components/logos/Logo.astro +++ b/apps/website/src/components/logos/Logo.astro @@ -18,11 +18,11 @@ const { let svg: string | undefined; try { - if (logo === undefined) + if (logo === '' || logo === undefined) return; const dir = new URL(join('..', '..', '..', 'public', 'media'), import.meta.url).pathname; - svg = (await readFile(`${dir}/${logo.replaceAll('.', '/')}.svg`, { encoding: 'utf8' })); + svg = (await readFile(`${dir}/${logo.replaceAll('.', '/')}.svg`)).toString(); if (svg === undefined) return; -- cgit