orockwell

joined 2 years ago
[–] orockwell@lemmy.world 21 points 1 month ago (4 children)

unicorn literally means one horn how dare you mock this institution with your duocorn rhinoceros

[–] orockwell@lemmy.world 1 points 1 month ago

hence the comment about tracking ;) anything more than recording your events as they happen are a security and privacy risk

[–] orockwell@lemmy.world 13 points 1 month ago (4 children)

great example of a code smell, too! JS needs to know about styles?

shouldn't be styling in JS! make it asd/remove a class instead

need to know whether to load content or not? save it to local/session storage! don't make a server call if it already exists!

need to enhance your tracking? include it with your payloads as it happens, you're asking for race conditions

client side disabled local caching? great! working as intended. make a graceful fall-back

everything here is a short term problem that belies long term tech debt. tight coupling sounds sexy, but SOLID principals and The Law of Demeter exist to stop our codebases from rotting if we can't change it, then it's not software it's hardware

[–] orockwell@lemmy.world 9 points 1 month ago

I blame Eastern Thom Yorke

[–] orockwell@lemmy.world 2 points 2 months ago

HELL YEAH! nice work 👏🏼

[–] orockwell@lemmy.world 0 points 3 months ago* (last edited 3 months ago) (4 children)

Tokenise your styles with variable layers. Eg: put a class on your body tag for each theme, eg: dark-mode, high-contrast

Then define your components by abstract style variables, eg: button-color, heading-weight,

Then define the style variables for each theme:

body { --button-color: green; }

body.dark-mode { --button-color: blue; }

button { backgroud: var(--button-color); }

Then all you need to do is a simple JS function to set the appropriate theme class on your document body!

This way your components are compliant to your style guide, without needing to know the implementation details of your themeing Very SRP, much Demeter, such OCP

Apologies for psudocode, LMK if you have any furthers :)