Financial-Times / o-grid

Responsive grid system
http://registry.origami.ft.com/components/o-grid
93 stars 14 forks source link

Forcing inclusion of required selectors from within modules #31

Closed wheresrhys closed 9 years ago

wheresrhys commented 10 years ago

So that e.g. if a product that isn't laid out with the grid wants to use a module which itself makes use of limited subset of o-grid's classes, then the product can safely turn on silent classes but be sure the module will still render correctly

Possible implementation grid styles

$_o-grid-required-selectors: null !default;

@mixin oGridRequireSelectors($selectors, $belatedly: false;) {
if !$belatedly {
   $_o-grid-required-selectors = append($_o-grid-required-selectors, $selectors, comma);
} else {
  createGrid( ... , $selectors: $selectors);
}
}

\\ then when building the grid's classes, for each one

@(if not $is-silent or $current-selector in $_o-grid-required-selectors) {
    // output loud styles
} @else {
   // output silent styles
}

module styles

oGridRequireSelectors(6 s12);
kaelig commented 9 years ago

I really like the idea… but: the overhead of loading the full grid helper classes is negligible, so no products nor modules should force-turn silent classes back on. Only turning silent mode off is allowed.