System Specific CSS

CCalego2/7/2022
I'm not 100% about this, but it is worth watching out that your solution doesn't actually end up being more performance intensive than having a bunch of css rules which are completely ignored by the browser. AFAIK, CSS is pretty light in that regard.
UUUnknown User2/7/2022
Message Not Public
Sign In & Join Server To View
CCalego2/7/2022
My point is that even if core did this, it might end up being worse for the browser opposed to simply loading all of the css and some of it going unused
CCalego2/7/2022
I've got a professional history of being trash at estimating performance impacts, but I bet someone out there has written about this
UUUnknown User2/7/2022
Message Not Public
Sign In & Join Server To View
CCalego2/7/2022
:just:
UUUnknown User2/7/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego2/7/2022
I trust my lord and savior scss to help me maintain my css rats nests. 🙂

But this could be a good api GL request. Maybe poke around and come up with a couple solid use cases which are currently a pain to implement.

It'd be great if you could find some research showing that excessive css rules are bad for paint times.

And I would strongly recommend you make no assertions about the simplicity of a request when writing up the GL for it 😉
MMLeahy2/7/2022
Just append your system specific stylesheet during the init hook. Like this:

const systemCSS = {
   wfrp4e: '/modules/<your module name>/css/wfrp4e.css'
};

Hooks.once('init', () =>
{
   const href = systemCSS[game.system.id];

   if (href)
   {
      document.getElementsByTagName('head')[0].append(Object.assign(document.createElement('link'), {
         href,
         rel: 'stylesheet',
         type: 'text/css',
         media: 'all'
      }));
   }
});


There should be no performance penalty.
UUUnknown User2/7/2022
2 Messages Not Public
Sign In & Join Server To View
LTLLLeo The League Lion2/7/2022
@Mouse0270 gave :vote: LeaguePoints™ to @MLeahy (#20 • 119) and @Calego (#1 • 1427)
UUUnknown User2/7/2022
2 Messages Not Public
Sign In & Join Server To View
LTLLLeo The League Lion2/7/2022
@Mouse0270 gave :vote: LeaguePoints™ to @MLeahy (#20 • 120)
MMLeahy2/7/2022
You might be waiting a while for it to get added to core if it ever does; I suppose still worth filing an issue to document the request. When there is an easy shim for a feature that very few would use I think it'd be rather low priority.

Of course I should note that the href part should probably be tested on at least the Forge. You might have to scan through the links in head and find your main style sheet then do a string replacement just so you get the right base HREF.
CCalego2/7/2022
Consider also that this usecase doesn't come up very often. So that plays into the "how much value does this add to core" weight that the Foundry Gaming devs think about.

It's mostly with large scale UI changes or skins, which have a propensity to conflict with opinionated systems.
MMLeahy2/7/2022
That and the maintaining a new feature burden that the core team will consider when adding any new feature.
CCalego2/7/2022
Personally, I'll throw out a :just: in that you can :just: use a preprocessor to combine all your stylesheets into one for the distributed module.
UUUnknown User2/7/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego2/7/2022
good lord that sounds awful to me
CCalego2/7/2022
😆
CCalego2/7/2022
I see what you mean, but jinkies that doesn't sound easier to maintain
CCalego2/7/2022
I think mostly the attitude Foundry Gaming has here is that "If a module is so different as to want different files for different systems, it should be split into multiple modules with different required systems"
CCalego2/7/2022
hence all the "PF2e drag ruler integration" and such modules
MMLeahy2/7/2022
I'll be doing custom loading of code with the TyphonJS Plugin Manager which is part of the new runtime library I'm putting out. You'll be able to define a system & module data structure that optionally will load plugins of interest when any given system or module is active.

This for instance will be used for any external module integrations for say time / calendar handling in the new quest log.
MMLeahy2/7/2022
Things can start to get nasty when you pepper your code w/ conditional logic. if this module active / load this. and then elsewhere in the code you have explicit connections between any of the module specific code as you'll be peppering your code w/ conditional logic that is hard to maintain.
UUUnknown User2/7/2022
Message Not Public
Sign In & Join Server To View
CCalego2/7/2022
LMRTFY does(or did) some system specific code, I don't remember exactly how it worked it out.

The limitation is that you're expecting a different root file for each system, where in reality I think most applications have a "child" file (in esmodules cases) which is different for each system.

- my-module.js // common stuff
  (imports system specific sub-logic)
  - dnd5e.js
  - pf2e.js
CCalego2/7/2022
I've just become keenly aware of how close we're edging to #arguing-about-programming and how projects are organized is super subjective. lol why is this so hard...
MMLeahy2/7/2022
heh heh.. for sure re #arguing-about-programming... ;P The traditional OOP way of handling this is the facade pattern.
UUUnknown User2/7/2022
Message Not Public
Sign In & Join Server To View
CCalego2/7/2022
THE REAL SOLUTION
Is to have Scss run natively in the browser. Duh
CCalego2/7/2022
Now we're cookin with gas. :anismart:
UUUnknown User2/7/2022
Message Not Public
Sign In & Join Server To View
CCalego2/7/2022
how fucking hard can it be to :just: have god damn nested css selectors natively ffs
UUUnknown User2/7/2022
2 Messages Not Public
Sign In & Join Server To View
CCalego2/7/2022
hahaha i know that feel. Seeing it from afar you're like "woooah", but then the high-information-density designer in you starts saying "man that's a lot of wasted space"
UUUnknown User2/7/2022
Message Not Public
Sign In & Join Server To View
MMLeahy2/7/2022
Oooo... Looks like nesting for CSS is coming down the pipeline eventually... https://www.w3.org/TR/css-nesting-1/