
The problem is, simply, the datalist element doesn't work at all in the preferences panel. This would allow for an autocomplete component to allow the user to either freely enter a Firefox Color URL or select from the autocomplete list an installed theme. Now my toggleTo will receive a constant so that it can handle the updating of the Firefox theme when the CSS expression evaluated value changes.īeyond that bit of code, the background script to the addon re-uses the code from Firefox Color to decode the URL into a theme JavaScript object which can then be used to update the current theme.Īlong with supporting the URLs from Firefox Color, I decided to enumerate the installed themes the user had to let them select a preinstalled theme (which actually allows for a more customised theme as they can support background images).įrustratingly, the UI for this part of the Firefox addon preferences should have used a datalist element bound to an input text box. matchMedia ( '(prefers-color-scheme: dark)' ). This means I can have an event listen to notify when the operating system switches into a dark mode (or light mode) using the following code: window. The nice "today I learned" bit of the project was that the matchMedia JavaScript method inherits events, so along with actually testing whether a CSS expression matches, I can watch for when it starts to match. This is all managed in the plugin preferences so it's tucked away and you don't have to think about it again once setup. Once installed, you can select an existing installed theme for light and dark setup, or you can paste a URL from Firefox Color and it'll automatically parse and activate it.


If you can't wait, then I've uploaded a self signed version of the addon on github which you can install by going to about:addons and then clicking the settings gear on the top right, and selecting "Install Add-on From File." The addon is currently going through the approval process (currently 52 of 52!), but when it's live it will be available here.

I've published 38 videos for new developers, designers, UX, UI, product owners and anyone who needs to conquer the command line today.
