Light πŸŒ‡ / Dark πŸŒƒ mode order on web

iamdtms
Sep 22, 2024
DALLE 3 illustration

Theme switch template on Gist

The big question

The mediaSwitch fn. is okay, the btn click fn. also okay, but DOMContentLoad is a bit tricky: If we do not have cookie set, the behaviour is also trivial.

But if cookie set, and another value it has as the current time needed, what is the best value to return?

  var useMode = Cookies.get('mode');

if (useMode == 'light') {
useDark = false;
} if (useMode == 'dark') {
useDark = true;
}
styleSetup();

Is it more important to serve personal view (from cookie) or is it more important to serve time related view?

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

iamdtms
iamdtms

Written by iamdtms

IT specialist, frontend designer

No responses yet

Write a response