From 0db9ca12e332c4e0e25cf8f6b1e0ad6b574117f9 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 26 Mar 2025 10:45:29 -0400 Subject: [PATCH] Remove unused SSR module and remove first load fade (#835) * disable SSR module in 11ty * remove first load fade --- docs/.eleventy.js | 53 ++++++++++++++--------------- docs/assets/scripts/theme-picker.js | 17 ++++++++- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/docs/.eleventy.js b/docs/.eleventy.js index c75fdf019..fb0dbfd58 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -7,10 +7,10 @@ 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 nunjucks from 'nunjucks'; -import componentList from './_data/componentList.js'; +// 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'; @@ -29,7 +29,6 @@ const globalData = { package: packageData, isAlpha, layout: 'page.njk', - server: { head: '', loginOrAvatar: '', @@ -190,30 +189,30 @@ export default function (eleventyConfig) { eleventyConfig.addPassthroughCopy(glob); } - // SSR plugin - // Make sure this is the last thing, we dont 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, - }); - } + // // 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', diff --git a/docs/assets/scripts/theme-picker.js b/docs/assets/scripts/theme-picker.js index b22a60414..f1d69e1e6 100644 --- a/docs/assets/scripts/theme-picker.js +++ b/docs/assets/scripts/theme-picker.js @@ -1,8 +1,20 @@ +let initialPageLoadComplete = false; + +window.addEventListener('load', () => { + initialPageLoadComplete = true; +}); + // Helper for view transitions -export function domChange(fn, { behavior = 'smooth' } = {}) { +export function domChange(fn, { behavior = 'smooth', ignoreInitialLoad = true } = {}) { const canUseViewTransitions = document.startViewTransition && !window.matchMedia('(prefers-reduced-motion: reduce)').matches; + // Skip transitions on initial page load + if (!initialPageLoadComplete && ignoreInitialLoad) { + fn(false); + return null; + } + if (canUseViewTransitions && behavior === 'smooth') { const transition = document.startViewTransition(() => { fn(true); @@ -10,6 +22,9 @@ export function domChange(fn, { behavior = 'smooth' } = {}) { return new Promise(resolve => setTimeout(resolve, 200)); }); return transition; + } else { + fn(false); + return null; } }