Skip to content

Jts js qol #6057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed

Jts js qol #6057

wants to merge 8 commits into from

Conversation

jstirnaman
Copy link
Contributor

@jstirnaman jstirnaman commented May 13, 2025

Closes #

Describe your proposed changes here.

Theming fix:

ThemeSwitch() should pass the component when calling Theme().

Optimize Mermaid using dynamic loading.

fix(diagram): Mermaid.js: dynamic loading, support dark theme, background color for edgeLabel paragraph elements
- Fixes dynamic loading of Mermaid.js
- Adds MutationObserver to handle light/dark theme switching.
- Sets the background-color for edgeLabel p elements to override a white background that obscures text in the dark theme.
image

Refactor feature-callout to a component

Moved to a component, but it appears to be unused? Do we still need it?

Refactor keybindings to a component and replace deprecated detection method

  • Extracted platform detection to its own utils/user-agent-platform reusable utility module
  • Eliminates deprecated Navigator.platform API usage; uses the User-Agent Client Hints API as the primary method when available
  • Handles iOS and Android devices correctly
image

Refactor Flux group keys demo to a component

image

Refactor datetime to module file

Moves datetime.js to a (non-component) module file
image

Refactor release-toc to component

Moves release-toc.js to a ReleaseToc component module.

image

Optimize and improve loading the search script

Refactor Algolia search to component and use async loading of docsearch.min.js:
image
image

e2e test runner

  • Test runner script starts Hugo on port 1315, runs Cypress tests, and then stops Hugo
  • Adds Hugo test config
  • Takes the same --spec and file list arguments as Cypress.

Test shared files

  • If map-files-to-urls.mjs receives a content/shared file it:
    • searches for pages that reference the shared file in their source: attribute and adds the pages to the list of files to test.
    • Doesn't try to test content/shared files directly.

Overhaul link checker

  • Improves broken link reporting:

image

Add test-only frontmatter attribute

  • Add a frontmatter test-only attribute for files like example.md. Don't use draft: true for these files.
  • Add support in index.html for the attribute so that the files are only rendered when running in the testing environment.

jstirnaman added 8 commits May 5, 2025 14:03
- Refactor main.js with a componentRegistry object and clear initialization of components and globals
- Add a standard index.js with all necessary exports.
- Update javascript.html to use the index.js
- Remove jQuery script tag from header javascript.html (remains in footer)
- Update package file to improve module discovery.
- Improve Hugo and ESLint config for module discovery and ES6 syntax
…ooter.js. Exports jQuery ($) to a window global for use by other scripts. Scripts bundled into footer.js didn't reliably load after jQuery.
…to components and utilities. Conditionally imports Mermaid if page has a diagram.
…ound color for edgeLabel paragraph elements

- Fixes dynamic loading of Mermaid.js
- Adds MutationObserver to handle light/dark theme switching.
- Sets the background-color for edgeLabel p elements to override a white background that obscures text in the dark theme.
1. Refactor JavaScript from search.html into a new DocSearch Component Module. The component needs to include: - Asynchronous loading of Algolia docsearch.min.js - Proper Algolia search facets:

  - Nested arrays for AND conditions: In Algolia, filters in the same array are combined with OR, while arrays in an array are combined with AND
  - Space after colon: Algolia's parser expects this specific format
2. Update Search HTML Template: refactor the search.html to use the new component:

3. Register the Component in main.js: update main.js to import and register our new DocSearch component:

Improve SearchInteractions event handler coordination with DocSearch:

- Improve SearchInteractions to dynamically detect the dropdown added by Algolia DocSearch and ensure that blur and focus event handlers are registered after the dropdown loads.

Benefits of This Approach:

Asynchronous Loading: DocSearch.js is now loaded asynchronously, improving page load performance
Search functionality is encapsulated as a component
Clean Separation: HTML template only contains configuration data, not implementation
Event Communication: Components can react to DocSearch initialization via events
SearchInteractions dynamically detects dropdown: Instead of waiting for an event or using setTimeout, we actively observe DOM changes to detect when the dropdown is created.
Nested Observation: A second observer monitors changes to the dropdown itself, allowing code to respond to style changes.
Better Event Handling: The blur handler checks if the related target is inside the search components, preventing unwanted dropdown closing.
Resource Cleanup: The cleanup function disconnects all observers, preventing memory leaks.
Additional Interaction Control: Adds an event listener to the dropdown to prevent unwanted blur events when interacting with search results.
…ion method

- Extracted platform detection to its own  reusable utility module
- Eliminates deprecated Navigator.platform API usage; uses the User-Agent Client Hints API as the primary method when available
- Handles iOS and Android devices correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant