IMO, there are two kinds of CSS for Royale: multi-platform and 
platform-specific.

The reason most SWCs have a .css file is mainly for multi-platform CSS so that 
the compiler can process it and encode it for ValuesManager.  A second reason 
is to make it easier for folks to grab and modify.

For platform-specific CSS, IOW, CSS that won't really be needed on other 
platforms, you don't have to have a separate .CSS file.  A static initializer 
for a class could inject the CSS.  It might even result in smaller downloads 
because the CSS won't be encoded for ValuesManager.  I don't think we have any 
examples of this right now.

Inject_html was mainly targeted towards injecting HTML for externs.  If you 
have classes wrapping elements, the normal way we associate CSS with classes 
should work.

I had a pattern that worked for including/excluding class selectors, but people 
didn't like it.  It might be that we should come up with a better way of 
handling that because that will also help HelloWorld drop some unused CSS.

In summary, I'm not quite sure what you are trying to do, but improving 
inject_html may not be the best way of doing it since you are wrapping 
elements.  We want better association of class selectors to the classes that 
need them, and that may solve your problem.

HTH,
-Alex

On 1/6/20, 1:02 AM, "Harbs" <[email protected]> wrote:

    I was just working on improving 
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Funhurdle%2Fspectrum-royale%2Ftree%2Finclude-css&amp;data=02%7C01%7Caharui%40adobe.com%7C1dfe32c564d7493d2f1408d792871725%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637138981214067604&amp;sdata=8A4Opc4Yj3AkchQ5lv5oLVBSloJlup5oPyre65fILHM%3D&amp;reserved=0
    
    Basically, for the Spectrum components to work, there is CSS which needs to 
be included in the application.
    
    Spectrum divides the css into components, so you can include only the CSS 
you need for specific components.
    
    I modified all the classes to use inject_html to add headers for each of 
the CSS files needed for each component.
    
    This now works (with some caveats which I’m not going into here).
    
    I ran into a few issues while doing this which I wanted to discuss here:
    
    1. inject_html is a bit “fragile” in that it only works if the comment is 
immediately proceeding the constructor.
    2. If you have multiple classes which require the same css file, you get a 
<link> for each class even though it’s required once.
    3. This ends up with many small css files linked in the app. This can make 
for slower startup times for apps loaded using HTML/1.1.
    4. The only way I was able to get this to work was by having a rigid folder 
structure that all apps using the library adhere to.
    
    Ideally, here’s what I would like to do:
    
    1. Have a way of declaring that a class requires a specific CSS file.
    2. Include all the possibly required CSS files in the lib swc.
    3. When the css for the app is compiled, the required css files should be 
concatenated to the main app CSS (and minified)
    
    Any ideas on how to achieve this goal and thoughts on how hard it would be?
    
    Thanks,
    Harbs

Reply via email to