From 997b850967df8dc03a7321b167dc9f7b52f98c7a Mon Sep 17 00:00:00 2001 From: Pauline Date: Sat, 14 Oct 2023 14:24:27 -0400 Subject: migrate(web): migrate from website/new-website to nexus/apps/website --- apps/website/astro.config.ts | 8 +- apps/website/config.ts | 93 ++++++++++++++++++++++ apps/website/package.json | 8 +- apps/website/public/media/oneconfig/minimal.svg | 5 ++ apps/website/public/media/polyfrost/full.svg | 12 +++ apps/website/public/media/polyfrost/minimal.svg | 3 + apps/website/public/media/polyfrost/minimal_bg.svg | 4 + apps/website/src/components/base/Header.astro | 57 +++++++++++++ apps/website/src/components/base/Navbar.astro | 21 +++++ .../src/components/base/NavbarElement.astro | 86 ++++++++++++++++++++ .../src/components/base/ScreenOverlay.astro | 16 ++++ .../base/ScrollbarOverlayContainer.astro | 51 ++++++++++++ apps/website/src/components/base/Tag.astro | 14 ++++ .../website/src/components/icons/ChevronDown.astro | 16 ++++ apps/website/src/components/logos/Logo.astro | 52 ++++++++++++ apps/website/src/layouts/Layout.astro | 38 +++++++++ apps/website/src/pages/index.astro | 10 +++ apps/website/src/styles/global.css | 11 +++ apps/website/src/types/Config.d.ts | 34 ++++++++ 19 files changed, 536 insertions(+), 3 deletions(-) create mode 100644 apps/website/config.ts create mode 100644 apps/website/public/media/oneconfig/minimal.svg create mode 100644 apps/website/public/media/polyfrost/full.svg create mode 100644 apps/website/public/media/polyfrost/minimal.svg create mode 100644 apps/website/public/media/polyfrost/minimal_bg.svg create mode 100644 apps/website/src/components/base/Header.astro create mode 100644 apps/website/src/components/base/Navbar.astro create mode 100644 apps/website/src/components/base/NavbarElement.astro create mode 100644 apps/website/src/components/base/ScreenOverlay.astro create mode 100644 apps/website/src/components/base/ScrollbarOverlayContainer.astro create mode 100644 apps/website/src/components/base/Tag.astro create mode 100644 apps/website/src/components/icons/ChevronDown.astro create mode 100644 apps/website/src/components/logos/Logo.astro create mode 100644 apps/website/src/layouts/Layout.astro create mode 100644 apps/website/src/pages/index.astro create mode 100644 apps/website/src/styles/global.css create mode 100644 apps/website/src/types/Config.d.ts diff --git a/apps/website/astro.config.ts b/apps/website/astro.config.ts index 882e651..c929648 100644 --- a/apps/website/astro.config.ts +++ b/apps/website/astro.config.ts @@ -1,4 +1,10 @@ import { defineConfig } from 'astro/config'; +import tailwind from '@astrojs/tailwind'; + // https://astro.build/config -export default defineConfig({}); +export default defineConfig({ + integrations: [ + tailwind(), + ] +}); diff --git a/apps/website/config.ts b/apps/website/config.ts new file mode 100644 index 0000000..1b45557 --- /dev/null +++ b/apps/website/config.ts @@ -0,0 +1,93 @@ +import type { Config, NavbarDropdown, NavbarElement, Project } from "@webtypes/Config"; + +export const configConst = { + projects: getProjects(), + logos: [ + "oneconfig.minimal", + "polyfrost.full", + "polyfrost.minimal", + "polyfrost.minimal_bg", + ], + navbar: { + left: [ + { + logo: ["polyfrost.full", -1], + path: "/", + } + ], + right: [ + { + text: "Home", + path: "/", + }, + { + text: "Projects", + dropdown: (getProjects().map((project) => { + (project as any).path = `/projects/${project.name.toLowerCase()}`; + return project; + }) as unknown as NavbarDropdown[]) + } + ] + } +} as const satisfies Config; + +function getProjects(): Project[] { + return [ + { + name: "OneConfig", + description: "The next-generation config library for Forge and Fabric", + logo: "oneconfig.minimal", + tag: "BETA" + }, + { + name: "OneLauncher", + description: "The next-generation launcher for Forge and Fabric", + logo: "polyfrost.minimal", + tag: "SOON" + }, + { + name: "OneConfig", + description: "The next-generation config library for Forge and Fabric", + logo: "oneconfig.minimal", + tag: "BETA" + }, + { + name: "OneLauncher", + description: "The next-generation launcher for Forge and Fabric", + logo: "polyfrost.minimal", + tag: "SOON" + }, + { + name: "OneConfig", + description: "The next-generation config library for Forge and Fabric", + logo: "oneconfig.minimal", + tag: "BETA" + }, + { + name: "OneLauncher", + description: "The next-generation launcher for Forge and Fabric", + logo: "polyfrost.minimal", + tag: "SOON" + }, + { + name: "OneConfig", + description: "The next-generation config library for Forge and Fabric", + logo: "oneconfig.minimal", + tag: "BETA" + }, + { + name: "OneLauncher", + description: "The next-generation launcher for Forge and Fabric", + logo: "polyfrost.minimal", + tag: "SOON" + }, + ] +} + + + + + + +// -------------------- NO TOUCH --------------------- // +export default configConst as unknown as Config; diff --git a/apps/website/package.json b/apps/website/package.json index eab7226..059363c 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -1,5 +1,6 @@ { "name": "@polyfrost/website", + "type": "module", "private": true, "scripts": { "dev": "astro dev", @@ -8,9 +9,12 @@ "preview": "astro preview" }, "dependencies": { - "astro": "^2.10.12" + "@astrojs/tailwind": "^5.0.2", + "astro": "^3.3.0", + "tailwindcss": "^3.3.3" }, "devDependencies": { - "typescript": "^5.1.6" + "@types/node": "^18.0.0", + "typescript": "^5.2.2" } } diff --git a/apps/website/public/media/oneconfig/minimal.svg b/apps/website/public/media/oneconfig/minimal.svg new file mode 100644 index 0000000..cba37ab --- /dev/null +++ b/apps/website/public/media/oneconfig/minimal.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/apps/website/public/media/polyfrost/full.svg b/apps/website/public/media/polyfrost/full.svg new file mode 100644 index 0000000..8c51156 --- /dev/null +++ b/apps/website/public/media/polyfrost/full.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/apps/website/public/media/polyfrost/minimal.svg b/apps/website/public/media/polyfrost/minimal.svg new file mode 100644 index 0000000..82d8e36 --- /dev/null +++ b/apps/website/public/media/polyfrost/minimal.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/website/public/media/polyfrost/minimal_bg.svg b/apps/website/public/media/polyfrost/minimal_bg.svg new file mode 100644 index 0000000..f949e8d --- /dev/null +++ b/apps/website/public/media/polyfrost/minimal_bg.svg @@ -0,0 +1,4 @@ + + + + diff --git a/apps/website/src/components/base/Header.astro b/apps/website/src/components/base/Header.astro new file mode 100644 index 0000000..ad8267b --- /dev/null +++ b/apps/website/src/components/base/Header.astro @@ -0,0 +1,57 @@ +--- +import type { HTMLAttributes } from "astro/types" + +const sizes = { + "xl": "h1", + "lg": "h2", + "md": "h3", + "sm": "h4", + "xs": "h5", + "xxs": "h6" +}; + +type Headers = "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; + +interface Props extends HTMLAttributes { + size: keyof typeof sizes; +} + +const { size, ...attr } = Astro.props; +const Element = sizes[size] as any; // Unfortunately gotta do this +--- + + + + + + \ No newline at end of file diff --git a/apps/website/src/components/base/Navbar.astro b/apps/website/src/components/base/Navbar.astro new file mode 100644 index 0000000..f4f2f49 --- /dev/null +++ b/apps/website/src/components/base/Navbar.astro @@ -0,0 +1,21 @@ +--- +import config from "config"; +import type { Config } from "@webtypes/Config"; +import NavbarElement from "./NavbarElement.astro"; + +--- + +
+ +
\ No newline at end of file diff --git a/apps/website/src/components/base/NavbarElement.astro b/apps/website/src/components/base/NavbarElement.astro new file mode 100644 index 0000000..4f82e8b --- /dev/null +++ b/apps/website/src/components/base/NavbarElement.astro @@ -0,0 +1,86 @@ +--- +import ChevronDown from "@components/icons/ChevronDown.astro"; +import type { LogoType, NavbarElement } from "@webtypes/Config"; +import ScreenOverlay from "./ScreenOverlay.astro"; +import Header from "./Header.astro"; +import Tag from "./Tag.astro"; +import Logo from "@components/logos/Logo.astro"; +import ScrollbarOverlayContainer from "./ScrollbarOverlayContainer.astro"; + +interface Props { + element: NavbarElement; + index: number; +} + +const { + element, + index +} = Astro.props; +--- + +
  • + +
  • \ No newline at end of file diff --git a/apps/website/src/components/base/ScreenOverlay.astro b/apps/website/src/components/base/ScreenOverlay.astro new file mode 100644 index 0000000..7be8bc5 --- /dev/null +++ b/apps/website/src/components/base/ScreenOverlay.astro @@ -0,0 +1,16 @@ +--- +import type { HTMLAttributes } from "astro/types"; + +interface Props extends HTMLAttributes<"div"> { + zIndex?: number; +} + +const { + zIndex = 0, + ...rest +} = Astro.props; +--- + +
    +
    +
    \ No newline at end of file diff --git a/apps/website/src/components/base/ScrollbarOverlayContainer.astro b/apps/website/src/components/base/ScrollbarOverlayContainer.astro new file mode 100644 index 0000000..d8d315d --- /dev/null +++ b/apps/website/src/components/base/ScrollbarOverlayContainer.astro @@ -0,0 +1,51 @@ +--- +import type { HTMLAttributes } from "astro/types"; + +interface Props extends HTMLAttributes<"div"> { + +} + +const { ...attr } = Astro.props; +--- + +
    + +
    + + \ No newline at end of file diff --git a/apps/website/src/components/base/Tag.astro b/apps/website/src/components/base/Tag.astro new file mode 100644 index 0000000..e6fd34f --- /dev/null +++ b/apps/website/src/components/base/Tag.astro @@ -0,0 +1,14 @@ +--- +import type { HTMLAttributes } from "astro/types"; + +interface Props extends HTMLAttributes<"span"> {} + +const { ...attr } = Astro.props; +--- + +
    + + + +
    + diff --git a/apps/website/src/components/icons/ChevronDown.astro b/apps/website/src/components/icons/ChevronDown.astro new file mode 100644 index 0000000..5cb98e4 --- /dev/null +++ b/apps/website/src/components/icons/ChevronDown.astro @@ -0,0 +1,16 @@ +--- +import type { HTMLAttributes } from 'astro/types'; + +interface Props extends HTMLAttributes<"svg"> { + size?: number; +} + +const { + size = 16, + ...attr +} = Astro.props; +--- + + + + \ No newline at end of file diff --git a/apps/website/src/components/logos/Logo.astro b/apps/website/src/components/logos/Logo.astro new file mode 100644 index 0000000..0532396 --- /dev/null +++ b/apps/website/src/components/logos/Logo.astro @@ -0,0 +1,52 @@ +--- +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"> { + logo: LogoType, + size?: number | [number, number], + silent?: boolean, +} + +const { + logo, + silent = false, + size = undefined, + ...attr +} = Astro.props; +let svg: string | undefined; + +try { + if (logo == undefined) return; + const dir = dirname(fileURLToPath(import.meta.url)) + "/../../../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) { + if (typeof silent != "boolean" || silent == false) console.error(err); +} + +--- + + diff --git a/apps/website/src/layouts/Layout.astro b/apps/website/src/layouts/Layout.astro new file mode 100644 index 0000000..a648f08 --- /dev/null +++ b/apps/website/src/layouts/Layout.astro @@ -0,0 +1,38 @@ +--- +import "../styles/global.css"; +import Navbar from "../components/base/Navbar.astro"; +import Favicon from "/media/polyfrost/minimal_bg.svg?url"; + +interface Props { + title?: string; + favicon?: string; +} + +const { + title = 'Polyfrost', + favicon = Favicon +} = Astro.props; +--- + + + + + + + + + + + + + + + {title} + + + + + + + + diff --git a/apps/website/src/pages/index.astro b/apps/website/src/pages/index.astro new file mode 100644 index 0000000..a484172 --- /dev/null +++ b/apps/website/src/pages/index.astro @@ -0,0 +1,10 @@ +--- +import Header from "@components/base/Header.astro"; +import Layout from "../layouts/Layout.astro"; +import Logo from "@components/logos/Logo.astro"; +--- + + +
    test
    +
    Test
    +
    diff --git a/apps/website/src/styles/global.css b/apps/website/src/styles/global.css new file mode 100644 index 0000000..51f3c19 --- /dev/null +++ b/apps/website/src/styles/global.css @@ -0,0 +1,11 @@ +@tailwind base; + +* { + font-family: 'Poppins', sans-serif; +} + +@layer base { + :focus-visible { + @apply outline-none ring ring-blue-500; + } +} \ No newline at end of file diff --git a/apps/website/src/types/Config.d.ts b/apps/website/src/types/Config.d.ts new file mode 100644 index 0000000..82eb4d7 --- /dev/null +++ b/apps/website/src/types/Config.d.ts @@ -0,0 +1,34 @@ +import { type configConst } from "config"; + +export type LogoType = typeof configConst.logos[number]; + +export interface Project { + name: string, + description: string, + logo?: LogoType, + tag?: string, +} + +export type NavbarDropdown = { + name: string, + description: string, + path: string, + logo?: LogoType, + tag?: string +} + +export type NavbarElement = { + text?: string, + logo?: [string, number], + path?: string, + dropdown?: NavbarDropdown[], +} + +export interface Config { + projects: Project[], + logos: string[], + navbar: { + left: NavbarElement[], + right: NavbarElement[], + }, +} \ No newline at end of file -- cgit