ReVanced / revanced-website

🌐 Website for ReVanced
https://revanced.app
GNU General Public License v3.0
279 stars 43 forks source link

feat: event-based theme #227

Open madkarmaa opened 4 months ago

madkarmaa commented 4 months ago

What is this?

Read #226

Description

I've created a simple JS library called DateTrigger, which executes given code on given dates, just like the issue describes. The library is now added to the dependencies, and used in +layout.svelte so the changes can be globalized. While the library itself doesn't do anything on its own, it got supplied with a default set of events which, once again, fullfill #226 at least partially (changing CSS color variables). The variables selection can be tweaked according to your liking, and if the default events aren't enough or don't feel right, custom events can be created.

How to test if it works?

Change the parameter passed to DateTriggerEventsHandler with the following:

{
    TEST_EVENT: new DateTriggerEvent(new Date(), 10, () => {
        document.documentElement.style.setProperty('--text', '#e6e8fe');
        document.documentElement.style.setProperty('--accent', '#f62e65');
        document.documentElement.style.setProperty('--secondary', '#960670');
        document.documentElement.style.setProperty('--background', '#010215');
        document.documentElement.style.setProperty('--primary', '#7082f9');
    })
}

The event should fire immediately.

A little concern fixed in f3aeadc

The library cannot work (with default events) if it doesn't have access to the document object, but using browser from $app/environment is really slow, at least on my end.

madkarmaa commented 4 months ago

TODO

madkarmaa commented 4 months ago

@KTibow is this ( 97e3092 ) what you wanted here ?

madkarmaa commented 4 months ago

colors look a bit odd but I hope they're decent. if not, they can be tweaked

Ushie commented 1 week ago

Hey!

I would like to take a different approach than this, the shifting in the theme is very noticeable! I don't think there's any way to prevent that, so instead it would make sense to handle this at build time

We would have a theme deployer that runs on the build of the website, that creates the theme that the website will use, and we can then assign cronjobs (or something else) to redeploy the site during events automatically

I looked into what method to use to deploy the theme, whether we would manually create a file or so, but it seems like there's a package called svelte-preprocess which seems fitting

oSumAtrIX commented 1 week ago

Build time has previously been dismissed as unsuitable. If the theme shifting is noticeable, add a transition if it is not preventable.

Ushie commented 1 week ago

Build time has previously been dismissed as unsuitable

Why? I opened all the previous reviews and I saw nothing related to this, I don't see any reason why build time would be considered unsuitable, it is the most elegant and seamless route

oSumAtrIX commented 1 week ago

It was discussed on Discord. The reason is that it needs re-building the project.

Ushie commented 1 week ago

Why is that a problem? it's hardly 10 times a year

oSumAtrIX commented 1 week ago

The final product does not include the source. If your product depends on its source after building it, you are doing something wrong.