From 6c98aa7de2c5c8937f9595c60cff878b4674d3f7 Mon Sep 17 00:00:00 2001 From: garthdb Date: Wed, 6 Dec 2023 16:02:32 -0700 Subject: [PATCH] feat(site): added static page for list of tokens --- docs/site/components/layout.js | 2 +- docs/site/lib/components.js | 1 + docs/site/lib/tokens.js | 34 +++ docs/site/package.json | 14 +- docs/site/pages/_app.js | 4 +- docs/site/pages/index.js | 4 +- docs/site/pages/tokens/index.js | 187 ++++++++++++++ docs/site/styles/global.css | 16 +- docs/site/styles/sidenav.css | 431 -------------------------------- package.json | 2 +- pnpm-lock.yaml | 245 +++++++++--------- 11 files changed, 371 insertions(+), 569 deletions(-) create mode 100644 docs/site/lib/tokens.js create mode 100644 docs/site/pages/tokens/index.js delete mode 100644 docs/site/styles/sidenav.css diff --git a/docs/site/components/layout.js b/docs/site/components/layout.js index a1cf4bea..c18273c1 100644 --- a/docs/site/components/layout.js +++ b/docs/site/components/layout.js @@ -1,7 +1,7 @@ import Head from "next/head"; import Link from "next/link"; -const name = "Spectrum Tokens"; +const name = "Spectrum Components API"; export const siteTitle = "Next.js Sample Website"; export default function Layout({ children, home }) { diff --git a/docs/site/lib/components.js b/docs/site/lib/components.js index 429fce0e..f4c22447 100644 --- a/docs/site/lib/components.js +++ b/docs/site/lib/components.js @@ -40,6 +40,7 @@ const resolveSchemaDefinitions = (schema, ajv) => { const readJSON = async (filePath) => JSON.parse(await readFile(filePath, "utf8")); + const getValidator = async () => { const schemaDir = "public/schemas"; const ajv = new Ajv(); diff --git a/docs/site/lib/tokens.js b/docs/site/lib/tokens.js new file mode 100644 index 00000000..d3c7b70b --- /dev/null +++ b/docs/site/lib/tokens.js @@ -0,0 +1,34 @@ +import path from "path"; +import { readFile } from "fs/promises"; +import { glob, Glob } from "glob"; + +const readJSON = async (filePath) => + JSON.parse(await readFile(filePath, "utf8")); + +export async function getTokenData() { + const tokenDir = path.resolve( + path.join(process.cwd(), "..", "..", "packages", "tokens", "src"), + ); + let tokenArray = []; + const g = new Glob(`${tokenDir}/*.json`, {}); + for await (const file of g) { + const fileTokenData = await readJSON(file); + const newTokenArray = Object.keys(fileTokenData).map((key) => { + return { + name: key, + ...fileTokenData[key], + }; + }); + tokenArray = [...tokenArray, ...newTokenArray]; + // await fileNames.forEach(async (file) => { + // const fileTokenData = await readJSON(file); + // Object.keys(fileTokenData).forEach((key) => { + // tokenArray.push({ + // name: key, + // token: fileTokenData[key], + // }); + // }); + // }); + } + return tokenArray; +} diff --git a/docs/site/package.json b/docs/site/package.json index ab4a0fb1..e37cc2a8 100644 --- a/docs/site/package.json +++ b/docs/site/package.json @@ -8,16 +8,18 @@ "url": "git+https://github.com/adobe/spectrum-tokens.git" }, "dependencies": { - "@spectrum-css/page": "^5.0.31", - "@spectrum-css/table": "^4.0.60", - "@spectrum-css/tokens": "^11.0.0", - "@spectrum-css/typography": "^5.0.27", + "@spectrum-css/link": "^4.0.74", + "@spectrum-css/page": "^6.0.9", + "@spectrum-css/sidenav": "^4.0.18", + "@spectrum-css/table": "^5.0.10", + "@spectrum-css/tokens": "^13.0.5", + "@spectrum-css/typography": "^5.0.49", "ajv": "^8.12.0", "ajv-formats": "^2.1.1", - "next": "^13.4.10", + "next": "^14.0.3", "react": "^18.2.0", "react-dom": "^18.2.0", - "rimraf": "^5.0.1" + "rimraf": "^5.0.5" }, "license": "Apache-2.0", "bugs": { diff --git a/docs/site/pages/_app.js b/docs/site/pages/_app.js index dec146b4..36351ecf 100644 --- a/docs/site/pages/_app.js +++ b/docs/site/pages/_app.js @@ -1,11 +1,13 @@ import "@spectrum-css/tokens/dist/css/global-vars.css"; import "@spectrum-css/tokens/dist/css/spectrum/custom-vars.css"; +import "@spectrum-css/tokens/dist/css/spectrum/medium-vars.css"; import "@spectrum-css/tokens/dist/css/medium-vars.css"; import "@spectrum-css/tokens/dist/css/light-vars.css"; import "@spectrum-css/page/dist/index-vars.css"; +import "@spectrum-css/link/dist/index-vars.css"; import "@spectrum-css/table/dist/index-vars.css"; import "@spectrum-css/typography/dist/index-vars.css"; -import "../styles/sidenav.css"; +import "@spectrum-css/sidenav/dist/index-vars.css"; export default function App({ Component, pageProps }) { return ; diff --git a/docs/site/pages/index.js b/docs/site/pages/index.js index aa6261fd..7bfff9f8 100644 --- a/docs/site/pages/index.js +++ b/docs/site/pages/index.js @@ -25,7 +25,7 @@ export default function Home({ allComponentsData }) {
-

Spectrum Components

+

Spectrum Components API