Skip to content
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

Fix Alpine bug with missing "theme" property, and lazy-load CSS/JS assets #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jackwh
Copy link

@jackwh jackwh commented Mar 2, 2024

This PR fixes two issues raised in #3.

1. theme is undefined

  • When enforcing dark mode in Filament with $panel->darkMode(true, true), theme was undefined. This caused Alpine to throw console errors.
  • I fixed this by initialising the theme property from Filament's localStorage key, falling back to the panel's default theme mode.

2. SyntaxEntry components in a modal seemed to have no effect

  • When opening a modal with a SyntaxEntry I noticed the hljs.highlightElement(el) method wasn't being called, so the new elements were remaining unaffected.
  • The component uses x-load-js and x-load-css, which I assume (?) was added with the intention of lazy-loading the assets.
  • However, the service provider registered its Filament assets without specifying loadedOnRequest().
  • This meant the assets were being bundled on every page (undesirable), and the lazy-loading had no effect.
  • By loading on request, the component now works again when launched inside a modal.

Quick addendum re custom themes:

This package seems tightly coupled to the Filament base theme. Some styles were being overloaded when used with the Filament Minimal Theme. I was able to work around this by publishing the vendor views and commenting out x-load-css, but ideally this could be fixed in a future update.

Previously, they were being bundled regardless of the presence of the SyntaxEntry component.
@jackwh jackwh marked this pull request as ready for review March 2, 2024 21:53
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