From 3cc51ddb81ef880e2a6e721ccb9c8d73d29a24df Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Fri, 24 May 2024 00:55:10 -0400 Subject: [PATCH] add more fontawesome icons --- packages/ui/fontawesome-cdn/package.json | 21 +++-- .../ui/fontawesome-cdn/src/app/layout.tsx | 16 ++++ .../src/app/sharp-light/[icon]/route.ts | 13 +++ .../src/app/sharp-regular/[icon]/route.ts | 13 +++ .../src/app/sharp-solid/[icon]/route.ts | 13 +++ .../src/app/sharp-thin/[icon]/route.ts | 13 +++ .../src/app/solid/[icon]/route.ts | 5 +- .../src/app/thin/[icon]/route.ts | 13 +++ .../ui/fontawesome-cdn/src/svgResponse.ts | 14 ++- pnpm-lock.yaml | 90 +++++++++++++++---- 10 files changed, 180 insertions(+), 31 deletions(-) create mode 100644 packages/ui/fontawesome-cdn/src/app/layout.tsx create mode 100644 packages/ui/fontawesome-cdn/src/app/sharp-light/[icon]/route.ts create mode 100644 packages/ui/fontawesome-cdn/src/app/sharp-regular/[icon]/route.ts create mode 100644 packages/ui/fontawesome-cdn/src/app/sharp-solid/[icon]/route.ts create mode 100644 packages/ui/fontawesome-cdn/src/app/sharp-thin/[icon]/route.ts create mode 100644 packages/ui/fontawesome-cdn/src/app/thin/[icon]/route.ts diff --git a/packages/ui/fontawesome-cdn/package.json b/packages/ui/fontawesome-cdn/package.json index b237f4cd36..fda2260cbb 100644 --- a/packages/ui/fontawesome-cdn/package.json +++ b/packages/ui/fontawesome-cdn/package.json @@ -33,12 +33,17 @@ }, "dependencies": { "@fortawesome/fontawesome-svg-core": "^6.5.1", - "@fortawesome/free-brands-svg-icons": "^6.5.1", - "@fortawesome/free-solid-svg-icons": "^6.5.1", - "@fortawesome/pro-duotone-svg-icons": "^6.5.1", - "@fortawesome/pro-light-svg-icons": "^6.5.1", - "@fortawesome/pro-regular-svg-icons": "^6.5.1", - "@fortawesome/pro-solid-svg-icons": "^6.5.1", + "@fortawesome/free-brands-svg-icons": "^6.5.2", + "@fortawesome/pro-duotone-svg-icons": "^6.5.2", + "@fortawesome/pro-light-svg-icons": "^6.5.2", + "@fortawesome/pro-regular-svg-icons": "^6.5.2", + "@fortawesome/pro-solid-svg-icons": "^6.5.2", + "@fortawesome/pro-thin-svg-icons": "^6.5.2", + "@fortawesome/react-fontawesome": "^0.2.2", + "@fortawesome/sharp-light-svg-icons": "^6.5.2", + "@fortawesome/sharp-regular-svg-icons": "^6.5.2", + "@fortawesome/sharp-solid-svg-icons": "^6.5.2", + "@fortawesome/sharp-thin-svg-icons": "^6.5.2", "react": "^18.2.0", "react-dom": "^18.2.0" }, @@ -49,11 +54,11 @@ "@types/react": "^18.0.20", "depcheck": "^1.4.3", "eslint": "^8.56.0", - "vitest": "^1.5.0", "next": "^14.2.3", "organize-imports-cli": "^0.10.0", "prettier": "^3.2.4", "stylelint": "^16.1.0", - "typescript": "5.4.3" + "typescript": "5.4.3", + "vitest": "^1.5.0" } } diff --git a/packages/ui/fontawesome-cdn/src/app/layout.tsx b/packages/ui/fontawesome-cdn/src/app/layout.tsx new file mode 100644 index 0000000000..a14e64fcd5 --- /dev/null +++ b/packages/ui/fontawesome-cdn/src/app/layout.tsx @@ -0,0 +1,16 @@ +export const metadata = { + title: 'Next.js', + description: 'Generated by Next.js', +} + +export default function RootLayout({ + children, +}: { + children: React.ReactNode +}) { + return ( + + {children} + + ) +} diff --git a/packages/ui/fontawesome-cdn/src/app/sharp-light/[icon]/route.ts b/packages/ui/fontawesome-cdn/src/app/sharp-light/[icon]/route.ts new file mode 100644 index 0000000000..a7694710cf --- /dev/null +++ b/packages/ui/fontawesome-cdn/src/app/sharp-light/[icon]/route.ts @@ -0,0 +1,13 @@ +import { library } from "@fortawesome/fontawesome-svg-core"; +import { fasl } from "@fortawesome/sharp-light-svg-icons"; +import { NextRequest, NextResponse } from "next/server"; +import { svgResponse } from "../../../svgResponse"; + +const prefix = "fasl"; +library.add(fasl); + +export const runtime = "edge"; + +export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise { + return svgResponse(prefix, params.icon); +} diff --git a/packages/ui/fontawesome-cdn/src/app/sharp-regular/[icon]/route.ts b/packages/ui/fontawesome-cdn/src/app/sharp-regular/[icon]/route.ts new file mode 100644 index 0000000000..2940dd6f2e --- /dev/null +++ b/packages/ui/fontawesome-cdn/src/app/sharp-regular/[icon]/route.ts @@ -0,0 +1,13 @@ +import { library } from "@fortawesome/fontawesome-svg-core"; +import { fasr } from "@fortawesome/sharp-regular-svg-icons"; +import { NextRequest, NextResponse } from "next/server"; +import { svgResponse } from "../../../svgResponse"; + +const prefix = "fasr"; +library.add(fasr); + +export const runtime = "edge"; + +export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise { + return svgResponse(prefix, params.icon); +} diff --git a/packages/ui/fontawesome-cdn/src/app/sharp-solid/[icon]/route.ts b/packages/ui/fontawesome-cdn/src/app/sharp-solid/[icon]/route.ts new file mode 100644 index 0000000000..956c2adce3 --- /dev/null +++ b/packages/ui/fontawesome-cdn/src/app/sharp-solid/[icon]/route.ts @@ -0,0 +1,13 @@ +import { library } from "@fortawesome/fontawesome-svg-core"; +import { fass } from "@fortawesome/sharp-solid-svg-icons"; +import { NextRequest, NextResponse } from "next/server"; +import { svgResponse } from "../../../svgResponse"; + +const prefix = "fass"; +library.add(fass); + +export const runtime = "edge"; + +export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise { + return svgResponse(prefix, params.icon); +} diff --git a/packages/ui/fontawesome-cdn/src/app/sharp-thin/[icon]/route.ts b/packages/ui/fontawesome-cdn/src/app/sharp-thin/[icon]/route.ts new file mode 100644 index 0000000000..27817a183e --- /dev/null +++ b/packages/ui/fontawesome-cdn/src/app/sharp-thin/[icon]/route.ts @@ -0,0 +1,13 @@ +import { library } from "@fortawesome/fontawesome-svg-core"; +import { fast } from "@fortawesome/sharp-thin-svg-icons"; +import { NextRequest, NextResponse } from "next/server"; +import { svgResponse } from "../../../svgResponse"; + +const prefix = "fast"; +library.add(fast); + +export const runtime = "edge"; + +export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise { + return svgResponse(prefix, params.icon); +} diff --git a/packages/ui/fontawesome-cdn/src/app/solid/[icon]/route.ts b/packages/ui/fontawesome-cdn/src/app/solid/[icon]/route.ts index af4b39fbba..0123c1cd06 100644 --- a/packages/ui/fontawesome-cdn/src/app/solid/[icon]/route.ts +++ b/packages/ui/fontawesome-cdn/src/app/solid/[icon]/route.ts @@ -1,11 +1,10 @@ import { library } from "@fortawesome/fontawesome-svg-core"; -import { fas } from "@fortawesome/free-solid-svg-icons"; -import { fas as fasPro } from "@fortawesome/pro-solid-svg-icons"; +import { fas } from "@fortawesome/pro-solid-svg-icons"; import { NextRequest, NextResponse } from "next/server"; import { svgResponse } from "../../../svgResponse"; const prefix = "fas"; -library.add(fas, fasPro); +library.add(fas); export const runtime = "edge"; diff --git a/packages/ui/fontawesome-cdn/src/app/thin/[icon]/route.ts b/packages/ui/fontawesome-cdn/src/app/thin/[icon]/route.ts new file mode 100644 index 0000000000..32c0dc6c27 --- /dev/null +++ b/packages/ui/fontawesome-cdn/src/app/thin/[icon]/route.ts @@ -0,0 +1,13 @@ +import { library } from "@fortawesome/fontawesome-svg-core"; +import { fat } from "@fortawesome/pro-thin-svg-icons"; +import { NextRequest, NextResponse } from "next/server"; +import { svgResponse } from "../../../svgResponse"; + +const prefix = "fat"; +library.add(fat); + +export const runtime = "edge"; + +export async function GET(_req: NextRequest, { params }: { params: { icon: string } }): Promise { + return svgResponse(prefix, params.icon); +} diff --git a/packages/ui/fontawesome-cdn/src/svgResponse.ts b/packages/ui/fontawesome-cdn/src/svgResponse.ts index 80a2890b8d..6e9ce36850 100644 --- a/packages/ui/fontawesome-cdn/src/svgResponse.ts +++ b/packages/ui/fontawesome-cdn/src/svgResponse.ts @@ -1,13 +1,19 @@ -import { AbstractElement, icon, IconPrefix } from "@fortawesome/fontawesome-svg-core"; +import { AbstractElement, findIconDefinition, icon, IconPrefix } from "@fortawesome/fontawesome-svg-core"; import { IconName } from "@fortawesome/free-brands-svg-icons"; import { NextResponse } from "next/server"; -export const runtime = "edge"; - // This gets called on every request export function svgResponse(prefix: IconPrefix, iconName: string): NextResponse { if (!iconName.endsWith(".svg")) { - return new NextResponse(null, { status: 404 }); + const icon = findIconDefinition({ + prefix, + iconName: iconName as IconName, + }); + if (icon === undefined) { + return new NextResponse(null, { status: 404 }); + } + + return NextResponse.json(icon); } const foundIcon = icon({ prefix, iconName: iconName.replace(".svg", "") as IconName }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61c93b9a4a..8dfb7a7b1d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1368,22 +1368,37 @@ importers: specifier: ^6.5.1 version: 6.5.2 '@fortawesome/free-brands-svg-icons': - specifier: ^6.5.1 - version: 6.5.2 - '@fortawesome/free-solid-svg-icons': - specifier: ^6.5.1 + specifier: ^6.5.2 version: 6.5.2 '@fortawesome/pro-duotone-svg-icons': - specifier: ^6.5.1 + specifier: ^6.5.2 version: 6.5.2 '@fortawesome/pro-light-svg-icons': - specifier: ^6.5.1 + specifier: ^6.5.2 version: 6.5.2 '@fortawesome/pro-regular-svg-icons': - specifier: ^6.5.1 + specifier: ^6.5.2 version: 6.5.2 '@fortawesome/pro-solid-svg-icons': - specifier: ^6.5.1 + specifier: ^6.5.2 + version: 6.5.2 + '@fortawesome/pro-thin-svg-icons': + specifier: ^6.5.2 + version: 6.5.2 + '@fortawesome/react-fontawesome': + specifier: ^0.2.2 + version: 0.2.2(@fortawesome/fontawesome-svg-core@6.5.2)(react@18.3.1) + '@fortawesome/sharp-light-svg-icons': + specifier: ^6.5.2 + version: 6.5.2 + '@fortawesome/sharp-regular-svg-icons': + specifier: ^6.5.2 + version: 6.5.2 + '@fortawesome/sharp-solid-svg-icons': + specifier: ^6.5.2 + version: 6.5.2 + '@fortawesome/sharp-thin-svg-icons': + specifier: ^6.5.2 version: 6.5.2 react: specifier: ^18.2.0 @@ -4567,14 +4582,6 @@ packages: '@fortawesome/fontawesome-common-types': 6.5.2 dev: false - /@fortawesome/free-solid-svg-icons@6.5.2: - resolution: {integrity: sha512-QWFZYXFE7O1Gr1dTIp+D6UcFUF0qElOnZptpi7PBUMylJh+vFmIedVe1Ir6RM1t2tEQLLSV1k7bR4o92M+uqlw==, tarball: https://npm.fontawesome.com/@fortawesome/free-solid-svg-icons/-/6.5.2/free-solid-svg-icons-6.5.2.tgz} - engines: {node: '>=6'} - requiresBuild: true - dependencies: - '@fortawesome/fontawesome-common-types': 6.5.2 - dev: false - /@fortawesome/pro-duotone-svg-icons@6.5.2: resolution: {integrity: sha512-U8dWrpPxajix1ijJQI8dWkSRpDPnXS/3/XJnCzQ6RlPLaGtAY7LelsYHM/byKUeHDpqpySfIGN1lLh63PDU9ag==, tarball: https://npm.fontawesome.com/@fortawesome/pro-duotone-svg-icons/-/6.5.2/pro-duotone-svg-icons-6.5.2.tgz} engines: {node: '>=6'} @@ -4607,6 +4614,57 @@ packages: '@fortawesome/fontawesome-common-types': 6.5.2 dev: false + /@fortawesome/pro-thin-svg-icons@6.5.2: + resolution: {integrity: sha512-aKs9VnIQUpVq7WKXG7iGYf6jNdobj3kD3eeJpwRfAlMPlIieHjxbNrGDrXUBzXsclHd66n18+TjpGMTPRvEnkA==, tarball: https://npm.fontawesome.com/@fortawesome/pro-thin-svg-icons/-/6.5.2/pro-thin-svg-icons-6.5.2.tgz} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.5.2 + dev: false + + /@fortawesome/react-fontawesome@0.2.2(@fortawesome/fontawesome-svg-core@6.5.2)(react@18.3.1): + resolution: {integrity: sha512-EnkrprPNqI6SXJl//m29hpaNzOp1bruISWaOiRtkMi/xSvHJlzc2j2JAYS7egxt/EbjSNV/k6Xy0AQI6vB2+1g==, tarball: https://npm.fontawesome.com/@fortawesome/react-fontawesome/-/0.2.2/react-fontawesome-0.2.2.tgz} + peerDependencies: + '@fortawesome/fontawesome-svg-core': ~1 || ~6 + react: '>=16.3' + dependencies: + '@fortawesome/fontawesome-svg-core': 6.5.2 + prop-types: 15.8.1 + react: 18.3.1 + dev: false + + /@fortawesome/sharp-light-svg-icons@6.5.2: + resolution: {integrity: sha512-xQnf7Tlo/HsugwyQHR5qqj/3epgyzbFqE7jh6oPx8yQI5bRtmnYbzIx2u0dS7FMgaDCCXiTPnujr28X7NG9h1g==, tarball: https://npm.fontawesome.com/@fortawesome/sharp-light-svg-icons/-/6.5.2/sharp-light-svg-icons-6.5.2.tgz} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.5.2 + dev: false + + /@fortawesome/sharp-regular-svg-icons@6.5.2: + resolution: {integrity: sha512-wGg2mhWJp4eT+efIPp22YASXpzjDPcJoPwuicRWxi2UmKe11/n111f4HviSPxRtJjp2EGSAgVtRe1bbnJf3vEw==, tarball: https://npm.fontawesome.com/@fortawesome/sharp-regular-svg-icons/-/6.5.2/sharp-regular-svg-icons-6.5.2.tgz} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.5.2 + dev: false + + /@fortawesome/sharp-solid-svg-icons@6.5.2: + resolution: {integrity: sha512-MKa9pkyiTjNl7RNnvAEogZgSJKpxgkhQ//5r0qOV2vi9mZGiANV185I/ddAzpLq552YqW1YJWz+9GUHw2GW6pQ==, tarball: https://npm.fontawesome.com/@fortawesome/sharp-solid-svg-icons/-/6.5.2/sharp-solid-svg-icons-6.5.2.tgz} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.5.2 + dev: false + + /@fortawesome/sharp-thin-svg-icons@6.5.2: + resolution: {integrity: sha512-cpSTY52ycffnWsKTtd79+yyrsLYahU1njqSV5C3bAbEPWK+h3XWtzfDB4rjDpQGhX3n1wCMeLZ8Ak6uE5zFTyw==, tarball: https://npm.fontawesome.com/@fortawesome/sharp-thin-svg-icons/-/6.5.2/sharp-thin-svg-icons-6.5.2.tgz} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.5.2 + dev: false + /@headlessui/react@1.7.19(react-dom@18.3.1)(react@18.3.1): resolution: {integrity: sha512-Ll+8q3OlMJfJbAKM/+/Y2q6PPYbryqNTXDbryx7SXLIDamkF6iQFbriYHga0dY44PvDhvvBWCx1Xj4U5+G4hOw==} engines: {node: '>=10'}