diff --git a/.github/workflows/client_tests.js.yml b/.github/workflows/client_tests.js.yml index 3a69e45df..0ae6f75a2 100644 --- a/.github/workflows/client_tests.js.yml +++ b/.github/workflows/client_tests.js.yml @@ -31,7 +31,7 @@ jobs: - name: Lint run: npm run prettier - name: Build - run: npm run build:alpha + run: npm run build - name: Install Playwright run: npx playwright install --with-deps - name: Run CSR tests diff --git a/.github/workflows/ssr_tests.js.yml b/.github/workflows/ssr_tests.js.yml index 1b188eaa2..85ea40f79 100644 --- a/.github/workflows/ssr_tests.js.yml +++ b/.github/workflows/ssr_tests.js.yml @@ -1,11 +1,12 @@ -# # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: SSR Tests on: - push: - branches: [next] + # push: + # branches: [next] + workflow_dispatch: jobs: ssr_test: @@ -30,7 +31,7 @@ jobs: run: npm run prettier - name: Build - run: npm run build:alpha + run: npm run build - name: Install Playwright run: npx playwright install --with-deps diff --git a/.prettierignore b/.prettierignore index fc6f3e81c..52ba57889 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,7 @@ *.hbs *.md +!docs/docs/patterns/**/*.md +docs/docs/patterns/blog-news/post-list.md .cache .github cspell.json @@ -13,3 +15,4 @@ package-lock.json tsconfig.json cdn _site +docs/assets/scripts/prism-downloaded.js diff --git a/cspell.json b/cspell.json index 51c9e5696..09559f4fb 100644 --- a/cspell.json +++ b/cspell.json @@ -148,6 +148,7 @@ "scrollbars", "scrollend", "scroller", + "Scrollers", "Segoe", "semibold", "shadowrootmode", diff --git a/docs/.eleventy.js b/docs/.eleventy.js index 86bba34fd..02f3a1e6f 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -1,14 +1,15 @@ +import * as path from 'node:path'; import { anchorHeadingsPlugin } from './_utils/anchor-headings.js'; import { codeExamplesPlugin } from './_utils/code-examples.js'; import { copyCodePlugin } from './_utils/copy-code.js'; import { currentLink } from './_utils/current-link.js'; import { highlightCodePlugin } from './_utils/highlight-code.js'; import { markdown } from './_utils/markdown.js'; -import { removeDataAlphaElements } from './_utils/remove-data-alpha-elements.js'; // import { formatCodePlugin } from './_utils/format-code.js'; -import litPlugin from '@lit-labs/eleventy-plugin-lit'; +// import litPlugin from '@lit-labs/eleventy-plugin-lit'; import { readFile } from 'fs/promises'; -import componentList from './_data/componentList.js'; +import nunjucks from 'nunjucks'; +// import componentList from './_data/componentList.js'; import * as filters from './_utils/filters.js'; import { outlinePlugin } from './_utils/outline.js'; import { replaceTextPlugin } from './_utils/replace-text.js'; @@ -16,29 +17,36 @@ import { searchPlugin } from './_utils/search.js'; import process from 'process'; -const packageData = JSON.parse(await readFile('./package.json', 'utf-8')); -const isAlpha = process.argv.includes('--alpha'); +import * as url from 'url'; +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); + +const packageData = JSON.parse(await readFile(path.join(__dirname, '..', 'package.json'), 'utf-8')); const isDev = process.argv.includes('--develop'); const globalData = { package: packageData, - isAlpha, layout: 'page.njk', + server: { + head: '', + loginOrAvatar: '', + flashes: '', + }, }; -const passThroughExtensions = ['js', 'css', 'png', 'svg', 'jpg', 'mp4']; -const passThrough = [...passThroughExtensions.map(ext => 'docs/**/*.' + ext)]; - export default function (eleventyConfig) { - // NOTE - alpha setting removes certain pages - if (isAlpha) { - eleventyConfig.ignores.add('**/experimental/**'); - eleventyConfig.ignores.add('**/layout/**'); - eleventyConfig.ignores.add('**/patterns/**'); - eleventyConfig.ignores.add('**/style-utilities/**'); - eleventyConfig.ignores.add('**/components/code-demo.md'); - eleventyConfig.ignores.add('**/components/viewport-demo.md'); - } + /** + * If you plan to add or remove any of these extensions, make sure to let either Konnor or Cory know as these passthrough extensions + * will also need to be updated in the Web Awesome App. + */ + const passThroughExtensions = ['js', 'css', 'png', 'svg', 'jpg', 'mp4']; + + const baseDir = process.env.BASE_DIR || 'docs'; + const passThrough = [...passThroughExtensions.map(ext => path.join(baseDir, '**/*.' + ext))]; + + /** + * This is the guard we use for now to make sure our final built files dont need a 2nd pass by the server. This keeps us able to still deploy the bare HTML files on Vercel until the app is ready. + */ + const serverBuild = process.env.WEBAWESOME_SERVER === 'true'; // Add template data for (let name in globalData) { @@ -55,7 +63,38 @@ export default function (eleventyConfig) { // Shortcodes - {% shortCode arg1, arg2 %} eleventyConfig.addShortcode('cdnUrl', location => { - return `https://early.webawesome.com/webawesome@${packageData.version}/dist/` + location.replace(/^\//, ''); + return `https://early.webawesome.com/webawesome@${packageData.version}/dist/` + (location || '').replace(/^\//, ''); + }); + + // Turns `{% server "foo" %} into `{{ server.foo | safe }}` when the WEBAWESOME_SERVER variable is set to "true" + eleventyConfig.addShortcode('server', function (property) { + if (serverBuild) { + return `{{ server.${property} | safe }}`; + } + + return ''; + }); + + eleventyConfig.addTransform('second-nunjucks-transform', function NunjucksTransform(content) { + // For a server build, we expect a server to run the second transform. + if (serverBuild) { + return content; + } + + // Only run the transform on files nunjucks would transform. + if (!this.page.inputPath.match(/.(md|html|njk)$/)) { + return content; + } + + /** This largely mimics what an app would do and just stubs out what we don't care about. */ + return nunjucks.renderString(content, { + // Stub the server EJS shortcodes. + server: { + head: '', + loginOrAvatar: '', + flashes: '', + }, + }); }); // Paired shortcodes - {% shortCode %}content{% endShortCode %} @@ -63,9 +102,6 @@ export default function (eleventyConfig) { // Helpers - // Remove elements that have [data-alpha="remove"] - eleventyConfig.addPlugin(removeDataAlphaElements({ isAlpha })); - // Use our own markdown instance eleventyConfig.setLibrary('md', markdown); @@ -94,7 +130,7 @@ export default function (eleventyConfig) { eleventyConfig.addPlugin(highlightCodePlugin()); // Add copy code buttons to code blocks - eleventyConfig.addPlugin(copyCodePlugin()); + eleventyConfig.addPlugin(copyCodePlugin); // Various text replacements eleventyConfig.addPlugin( @@ -117,28 +153,14 @@ export default function (eleventyConfig) { ]), ); - // SSR plugin - if (!isDev) { - // - // Problematic components in SSR land: - // - animation (breaks on navigation + ssr with Turbo) - // - mutation-observer (why SSR this?) - // - resize-observer (why SSR this?) - // - tooltip (why SSR this?) - // - const omittedModules = []; - const componentModules = componentList - .filter(component => !omittedModules.includes(component.tagName.split(/wa-/)[1])) - .map(component => { - const name = component.tagName.split(/wa-/)[1]; - return `./dist/components/${name}/${name}.js`; - }); + eleventyConfig.addPreprocessor('unpublished', '*', (data, content) => { + if (data.unpublished && process.env.ELEVENTY_RUN_MODE === 'build') { + // Exclude "unpublished" pages from final builds. + return false; + } - eleventyConfig.addPlugin(litPlugin, { - mode: 'worker', - componentModules, - }); - } + return content; + }); // Build the search index eleventyConfig.addPlugin( @@ -166,6 +188,31 @@ export default function (eleventyConfig) { eleventyConfig.addPassthroughCopy(glob); } + // // SSR plugin + // // Make sure this is the last thing, we don't want to run the risk of accidentally transforming shadow roots with the nunjucks 2nd transform. + // if (!isDev) { + // // + // // Problematic components in SSR land: + // // - animation (breaks on navigation + ssr with Turbo) + // // - mutation-observer (why SSR this?) + // // - resize-observer (why SSR this?) + // // - tooltip (why SSR this?) + // // + // const omittedModules = []; + // const componentModules = componentList + // .filter(component => !omittedModules.includes(component.tagName.split(/wa-/)[1])) + // .map(component => { + // const name = component.tagName.split(/wa-/)[1]; + // const componentDirectory = process.env.UNBUNDLED_DIST_DIRECTORY || path.join('.', 'dist'); + // return path.join(componentDirectory, 'components', name, `${name}.js`); + // }); + // + // eleventyConfig.addPlugin(litPlugin, { + // mode: 'worker', + // componentModules, + // }); + // } + return { markdownTemplateEngine: 'njk', dir: { diff --git a/docs/_data/hueRanges.js b/docs/_data/hueRanges.js new file mode 100644 index 000000000..63d7400a6 --- /dev/null +++ b/docs/_data/hueRanges.js @@ -0,0 +1 @@ +export { hueRanges as default } from '../assets/data/index.js'; diff --git a/docs/_data/hues.json b/docs/_data/hues.json index 1251ab4ec..2e68ebe4b 100644 --- a/docs/_data/hues.json +++ b/docs/_data/hues.json @@ -1 +1 @@ -["red", "yellow", "green", "teal", "blue", "indigo", "violet", "gray"] +["red", "orange", "yellow", "green", "cyan", "blue", "indigo", "purple", "pink", "gray"] diff --git a/docs/_data/palettes.js b/docs/_data/palettes.js index fb231f0e9..3ce705beb 100644 --- a/docs/_data/palettes.js +++ b/docs/_data/palettes.js @@ -1 +1 @@ -export { default as default } from '../../src/styles/color/palettes.js'; +export { default as default } from '../../src/styles/color/scripts/palettes-analyzed.js'; diff --git a/docs/_includes/base.njk b/docs/_includes/base.njk index 3742a94db..bf0e7e466 100644 --- a/docs/_includes/base.njk +++ b/docs/_includes/base.njk @@ -1,24 +1,25 @@ - + {% include 'head.njk' %} - - + {% if hasSidebar %}{% endif %} {# Docs styles #} + + {% block head %}{% endblock %} - + @@ -74,14 +78,19 @@ {% endif %} + {# Main #}
{# Expandable outline #} + {% if hasOutline %} + {% endif %} + +
{% server "flashes" %}
{% block header %} {% include 'breadcrumbs.njk' %} diff --git a/docs/_includes/breadcrumbs.njk b/docs/_includes/breadcrumbs.njk index 5f9fa145b..96d5563e8 100644 --- a/docs/_includes/breadcrumbs.njk +++ b/docs/_includes/breadcrumbs.njk @@ -1,8 +1,11 @@ -{% set breadcrumbs = page.url | breadcrumbs %} -{% if breadcrumbs.length > 0 %} +{% set ancestors = page.url | ancestors %} + +{% if ancestors.length > 0 %} - {% for crumb in breadcrumbs %} - {{ crumb.title }} + {% for ancestor in ancestors %} + {% if ancestor.page.url != "/" %} + {{ ancestor.data.title }} + {% endif %} {% endfor %} {# Current page #} diff --git a/docs/_includes/contrast-table.njk b/docs/_includes/contrast-table.njk index 46e6ff701..9ecdfb852 100644 --- a/docs/_includes/contrast-table.njk +++ b/docs/_includes/contrast-table.njk @@ -1,4 +1,4 @@ - + @@ -12,19 +12,31 @@ {% for hue in hues -%} - + {% for tint_bg in tints -%} {% set color_bg = palettes[paletteId][hue][tint_bg] %} {% for tint_fg in tints | reverse -%} {% set color_fg = palettes[paletteId][hue][tint_fg] %} {% if (tint_fg - tint_bg) | abs == difference %} -