From 7f3a9bb00d55f7ff9ace2903c37b376b565fbb5d Mon Sep 17 00:00:00 2001 From: 1aron Date: Mon, 6 Nov 2023 20:08:56 +0800 Subject: [PATCH] Update site --- packages/eslint-plugin/src/config.ts | 5 +++++ packages/react/src/CSSProvider.tsx | 12 +++++++----- pnpm-lock.yaml | 4 +++- tsconfig.json | 1 - .../(root)/docs/text-align/components/Basic.tsx | 2 +- .../[locale]/(root)/sponsor/components/Donors.tsx | 12 +++++++----- website/app/api/generate-page-cache/route.ts | 2 +- website/og-image.tsx | 12 ++++++------ 8 files changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/eslint-plugin/src/config.ts b/packages/eslint-plugin/src/config.ts index e37d6303b..8dd7dc916 100644 --- a/packages/eslint-plugin/src/config.ts +++ b/packages/eslint-plugin/src/config.ts @@ -3,6 +3,11 @@ const config = { '@master/css/class-order': 'warn', '@master/css/class-validation': 'error', '@master/css/class-collision': 'warn' + }, + parserOptions: { + ecmaFeatures: { + jsx: true + } } } as const diff --git a/packages/react/src/CSSProvider.tsx b/packages/react/src/CSSProvider.tsx index b9f20951a..61b7a96ad 100644 --- a/packages/react/src/CSSProvider.tsx +++ b/packages/react/src/CSSProvider.tsx @@ -1,6 +1,6 @@ 'use client' -import MasterCSS, { Config } from '@master/css' +import MasterCSS, { Config, initRuntime } from '@master/css' import { useEffect, useLayoutEffect, createContext, useContext, useState } from 'react' export const CSSContext = createContext(undefined) @@ -20,14 +20,16 @@ export function CSSProvider({ }) { const [css, setCSS] = useState(); (typeof window !== 'undefined' ? useLayoutEffect : useEffect)(() => { - let newCSS: MasterCSS - if (!css) { + let newCSS: MasterCSS = window.masterCSSs?.find((eachCSS) => eachCSS.root === root) + if (newCSS) { + setCSS(newCSS) + } else if (!css) { const init = (resolvedConfig?: Config) => { - const existingCSS = globalThis.masterCSSs.find((eachCSS) => eachCSS.root === root) + const existingCSS = window.masterCSSs.find((eachCSS) => eachCSS.root === root) if (existingCSS) { setCSS(existingCSS) } else { - newCSS = new MasterCSS(resolvedConfig).observe(root) + newCSS = initRuntime(resolvedConfig, root) setCSS(newCSS) } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 509841dce..b012af4ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8134,6 +8134,7 @@ packages: /@types/node@14.18.63: resolution: {integrity: sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==} + dev: true /@types/node@18.18.8: resolution: {integrity: sha512-OLGBaaK5V3VRBS1bAkMVP2/W9B+H8meUfl866OrMNQqt7wDgdpWPp5o6gmIc9pB+lIQHSq4ZL8ypeH1vPxcPaQ==} @@ -8759,7 +8760,7 @@ packages: peerDependencies: vite: ^3.0.0 || ^4.0.0 dependencies: - vite: 4.4.7(@types/node@14.18.63)(less@4.1.3)(sass@1.64.1)(terser@5.19.2) + vite: 4.4.7(@types/node@20.8.10)(less@4.1.3)(sass@1.64.1)(terser@5.19.2) /@vitejs/plugin-react@4.1.1(vite@4.5.0): resolution: {integrity: sha512-Jie2HERK+uh27e+ORXXwEP5h0Y2lS9T2PRGbfebiHGlwzDO0dEnd2aNtOR/qjBlPb1YgxwAONeblL1xqLikLag==} @@ -24916,6 +24917,7 @@ packages: terser: 5.19.2 optionalDependencies: fsevents: 2.3.3 + dev: true /vite@4.4.7(@types/node@20.8.10)(less@4.1.3)(sass@1.64.1)(terser@5.19.2): resolution: {integrity: sha512-6pYf9QJ1mHylfVh39HpuSfMPojPSKVxZvnclX1K1FyZ1PXDOcLBibdq5t1qxJSnL63ca8Wf4zts6mD8u8oc9Fw==} diff --git a/tsconfig.json b/tsconfig.json index 86a1e12da..92d423fde 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,4 @@ { - "extends": "../../tsconfig.json", "compilerOptions": { "experimentalDecorators": true, "baseUrl": ".", diff --git a/website/app/[locale]/(root)/docs/text-align/components/Basic.tsx b/website/app/[locale]/(root)/docs/text-align/components/Basic.tsx index 7d710c32d..a9f522532 100644 --- a/website/app/[locale]/(root)/docs/text-align/components/Basic.tsx +++ b/website/app/[locale]/(root)/docs/text-align/components/Basic.tsx @@ -7,7 +7,7 @@ export default ({ className }: any) =>

- + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et elit dictum, tempor augue quis, rhoncus enim. Nunc lacinia, velit vel convallis tincidunt, ante nisi maximus nunc, at aliquam nisi lectus in mauris.

diff --git a/website/app/[locale]/(root)/sponsor/components/Donors.tsx b/website/app/[locale]/(root)/sponsor/components/Donors.tsx index 184cb63a2..79dd8a38e 100644 --- a/website/app/[locale]/(root)/sponsor/components/Donors.tsx +++ b/website/app/[locale]/(root)/sponsor/components/Donors.tsx @@ -1,14 +1,16 @@ +/* eslint-disable @master/css/class-validation */ + import { Fragment } from 'react'; import Link from 'websites/components/Link' export default function Donors({ sponsorTiers, sponsorsOfLevel }: any) { return sponsorTiers.map((eachSponsorTier: any) => ( -
-

+
+

{eachSponsorTier.name}

-
+
{sponsorsOfLevel[eachSponsorTier.name] && @@ -18,10 +20,10 @@ export default function Donors({ sponsorTiers, sponsorsOfLevel }: any) { key={'sponsor-' + i} alt={'sponsor-' + i} src={eachSponsor.avatarUrl} - className={`object:contain full max-h:${eachSponsorTier.height}`} + className={`max-h: full object:contain${eachSponsorTier.height}`} /> ))} - + diff --git a/website/app/api/generate-page-cache/route.ts b/website/app/api/generate-page-cache/route.ts index cb8e8efe5..330c9a41f 100644 --- a/website/app/api/generate-page-cache/route.ts +++ b/website/app/api/generate-page-cache/route.ts @@ -1,5 +1,5 @@ import * as cheerio from 'cheerio' -import app from '../../../../../../shared/firebase-admin-app' +import app from 'websites/firebase-admin-app' import { getStorage } from 'firebase-admin/storage' import path from 'path' import fs from 'fs' diff --git a/website/og-image.tsx b/website/og-image.tsx index 383997fa9..aea89df92 100644 --- a/website/og-image.tsx +++ b/website/og-image.tsx @@ -11,13 +11,13 @@ import { queryDictionary } from 'websites/dictionaries'; import stringWidth from 'string-width' import fs from 'fs' import path from 'path'; -import mime from 'mime' +import mime from 'mime-types' const readImage = (filename: string) => { - const sharedFolderPath = path.join(process.cwd(), '../../../shared') + const sharedFolderPath = path.join(process.cwd(), '../../../') const filepath = path.join(sharedFolderPath, filename.replace('websites/', '')) const extname = path.extname(filepath); - const mimeType = mime.getType(extname); + const mimeType = mime.lookup(extname); return `data:${mimeType};base64,` + fs.readFileSync(filepath, { encoding: 'base64' }) } const cssLogotypeSrc = readImage('websites/images/css-logotype@light.png') @@ -45,15 +45,15 @@ const fonts = [ }, { name: 'NotoSansTC Regular', - data: fs.readFileSync(path.resolve('../../../shared/fonts/NotoSansTC-Regular.ttf')) + data: fs.readFileSync(path.resolve('../../../fonts/NotoSansTC-Regular.ttf')) }, { name: 'NotoSansTC Medium', - data: fs.readFileSync(path.resolve('../../../shared/fonts/NotoSansTC-Medium.ttf')) + data: fs.readFileSync(path.resolve('../../../fonts/NotoSansTC-Medium.ttf')) }, { name: 'NotoSansTC Black', - data: fs.readFileSync(path.resolve('../../../shared/fonts/NotoSansTC-Black.ttf')) + data: fs.readFileSync(path.resolve('../../../fonts/NotoSansTC-Black.ttf')) } ]