[wip] skin.order.loader.enhancements #165

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
6 participants

Loader enhancement that adds an order property to the skin property of config (http://yuilibrary.com/yui/docs/api/classes/config.html#property_skin). Preserves backwards compatibility, and adds the ability to have a fallback system when specifying skins and does not require
the user of the framework to have to remember which modules support which skins:

YUI({
    skin: {
        order: 'night,sam'
    }
}).use('test', 'calendar', function (Y) {...});

This tells the framework to load the first available skin in the ordered list of
skins for each module in the use call. So for calendar it will load the
night skin because calendar supports it and for test it will load the
sam skin since it is the only skin that it supports.

Since the defaultSkin is always included as the last skin in the ordered list,
you can also write (because the default skin is sam):

YUI({
    skin: {
        order: 'night'
    }
}).use('test', 'calendar', function (Y) {...});

For a more extreme example, look at slider-base, it is the only module that supports
9 skins so we could write the following and the framework will load the skins in
that order of preference. Later on, when calendar supports round or
round-dark, there would be no changes needed to the code below.

YUI({
    skin: {
        order: 'round,round-dark,night,sam-dark'
    }
}).use('test', 'calendar', 'slider-base', function (Y) {...});

The addition of the skins.order property is backwards compatible which means
that changing the defaultSkin and using overrides still works as expected.

Metadata for skins (see MOD_SKINS in Loader.js 46-75) generated by comp_skins and could be added to build files (a la requires metadata).

You can play with skin order and overrides here: http://23.21.81.23/yui3configurator/index.php, and run the existing unit tests, along with the additional tests from this pull request, here: http://23.21.81.23/yui/tests/loader/tests/index.html.

Configurator source code available here: https://github.com/ryanvanoss/yui3configurator

davglass was assigned Jun 18, 2012

ryanvanoss added some commits Aug 7, 2012

@ryanvanoss ryanvanoss Merging with yui3 trunk. 1278bbe
@ryanvanoss ryanvanoss Incorporating changes requested by Dav for pull request: Use yui3skin…
…s to calculate each module's supported skins at build time (via meta_join.js), replace all YArray.each calls with plane jane for loops and add missing assertion to a test case.
d1aee2a

It may be better to change the explanation of this feature, I don't think it is conveying its power by just explaining what it does. This feature adds the ability for YUI to support multiple skins per component, and although it is possible today, it is awkward to configure (like slider). If a company wants to use YUI and have different brands for desktop and mobile or even as a user preference, managing multiple skins is very hard. With this feature, you can ask YUI to use skins "foo, bar, sam" in that order, and depending on what skins are supported by the different components, they would be properly loaded without awkward 404 errors because ultimately all YUI components suport 'sam', but if a component supports 'foo' it would be used instead.

Owner

davglass commented Sep 10, 2012

Yes, we know how important it is, but in the current state of this pull request it's not "up to par" with what it needs to get into Loader. I know that @ryanvanoss is working on this and now that we have shifter we should be able to start looking at the build step needed to generate the available skins meta-data that Loader needs.

Hey Dav,

Did you get a chance to look at the latest update that uses the yui3skins npm package to derive the skins list at build time? I think this should have addressed the concerns that you mentioned above.

Cheers,
Ryan

Hey @ryanvanoss perhaps what @davglass means is to do a pull request to merge your yui3skins code directly into his shifter code?

Owner

davglass commented Sep 10, 2012

Wow, Github failed me on this one. It never sent me a notification that you added something to this pull request. I'll pull this and investigate this locally.

Member

juandopazo commented Sep 20, 2012

+1 to this feature!

Hey @juandopazo , no se si me recuerdas, hablamos de convertir components de jQuery a YUI? You gave me some good feedback, thanks!

Hey @davglass and @jenny,

Just wanted to check in and see if this was on track for making the 3.8 release. Let me know if there are any additional concerns.

Cheers,
Ryan

Owner

davglass commented Nov 12, 2012

It's not in 3.8, I'm at YUIConf this week & on vacation next week.
Code Freeze for sprint 3 is the Friday after that so it won't make it
then.

It is first on my list after that sprint tho, now that the loader
metadata infrastructure is in place.

Contributor

solmsted commented Dec 20, 2012

Should skin.order be an array instead of a csv?

Owner

davglass commented Dec 20, 2012

Yes it should be, that's one of the changes I will be making once I get to it. I'm currently getting the infrastructure in place with shifter and yogi in order to support these changes.

Thank you, Dav, I was about to ask! Happy Holidays! BTW we LOVE Shifter and Yogi!

Contributor

clarle commented May 18, 2014

Hi all,

This PR seems to have fallen a bit behind the Loader tree, so I'm going to close it out for now.

Feel free to let me know if you're going to continue to work on it, and I'd definitely recommend rebasing it against the current master branch. Please feel free to let me know if there's anything I can do to help.

Thanks!

clarle closed this May 18, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment