System Specific CSS

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.
UU
Unknown User810d ago
C
Calego810d ago
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 I've got a professional history of being trash at estimating performance impacts, but I bet someone out there has written about this
UU
Unknown User810d ago
C
Calego810d ago
just
UU
Unknown User810d ago
C
Calego810d ago
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 😉
TM
TyphonJS (Michael)810d ago
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'
}));
}
});
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.
UU
Unknown User810d ago
LTL
Leo The League Lion810d ago
@mouse0270 gave vote LeaguePoints™ to @mleahy (#20 • 119) and @calego (#1 • 1427)
UU
Unknown User810d ago
LTL
Leo The League Lion810d ago
@mouse0270 gave vote LeaguePoints™ to @mleahy (#20 • 120)
TM
TyphonJS (Michael)810d ago
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.
C
Calego810d ago
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.
TM
TyphonJS (Michael)810d ago
That and the maintaining a new feature burden that the core team will consider when adding any new feature.
C
Calego810d ago
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.
UU
Unknown User810d ago
C
Calego810d ago
good lord that sounds awful to me 😆 I see what you mean, but jinkies that doesn't sound easier to maintain 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" hence all the "PF2e drag ruler integration" and such modules
TM
TyphonJS (Michael)810d ago
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. 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.
UU
Unknown User810d ago
C
Calego810d ago
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
- my-module.js // common stuff
(imports system specific sub-logic)
- dnd5e.js
- pf2e.js
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...
TM
TyphonJS (Michael)810d ago
heh heh.. for sure re #arguing-about-programming... ;P The traditional OOP way of handling this is the facade pattern.
UU
Unknown User810d ago
C
Calego810d ago
THE REAL SOLUTION Is to have Scss run natively in the browser. Duh Now we're cookin with gas. anismart
UU
Unknown User810d ago
C
Calego810d ago
how fucking hard can it be to just have god damn nested css selectors natively ffs
UU
Unknown User810d ago
C
Calego810d ago
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"
UU
Unknown User810d ago
TM
TyphonJS (Michael)810d ago
Oooo... Looks like nesting for CSS is coming down the pipeline eventually... https://www.w3.org/TR/css-nesting-1/
Want results from more Discord servers?
Add your server
More Posts
advancement-wipCommander register apitalking about permissions, im working on the registering api for the Commander, and I wanted to ask Azgaars Blurry MapHey all. I'm taking a look at my importer for Azgaar's Fantasy Map Generator and wondering how I canccjmk overlaybut for what I wanted I think I *needed* to append it there so that I can overlay the whole screencliits very very early alpha demoMonarch APIAlright, adventurous ones: I have a Beta version of Monarch with the new components API! Manifest: compacted chat cardsModules create problems to solve problems... Today's problem: "When I roll an attack, it eats the whdragdrop shenneneginsRight now, a user can drag a spell onto their character sheet. I store that in a 'spell' array and leffect mini modulesI've gotten to the point where I'm confident in releasing a slurry of tiny no-config Active Effect rdamage application hooksNew 5e Hook ideas, gimme yer thoughts: `Hooks.call('Actor5e.preDamageApplied')` args: `damageAmounthook conventionsRegarding hooks, is the convention that _all_ `pre...` hooks are executed on the machine that initiaexpand arraysIs there a way to `expandObject` except for an Array?edit-owned-item-effectI've made an abomination. This hacks its way past the limitations surrounding editing effects on ownItem Pile feedbackSimple is king!effects to chat@badideasbureau is the `temporary` flag you look for in Effects to Chat a convention from somewhere 5e AEsI've been messing pretty heavily with some Active Effect assumptions and mechanisms in 5e. This is mhero creator ui feedbackI'm trying to refactor the abilities' tab on the hero creation room to accomodate Race ASIs, but I deffect mechanic searchingI need someone to check me on a null hypothesis I'm making. > There are no abilities in 5e RAW whicDialog shennaneginsTIL the button callbacks for `Dialog.prompt` and `Dialog.confirm` can be asynchronous. ```js const Advancement Hooks@kandashi @ccjmk and anyone else who is currently working on modules that would interact with the Ad