A collection of dynamically generated css display
utility classes.
Class names follow the Emmet abbreviation
syntax, with colons (':') replaced by two dashes (--
) to follow BEM naming
conventions (It modifiies the user agent's default display).
E.g., the display: none
utility class name is .u-d--n
.
Available classes
.u-d--b
(display: block)
.u-d--f
(display: flex)
.u-d--if
(display: inline-flex)
.u-d--i
(display: inline)
.u-d--ib
(display: inline-block)
.u-d--inher
(display: inherit)
.u-d--init
(display: initial)
.u-d--li
(display: list-item)
.u-d--n
(display: none)
.u-d--tb
(display: table)
.u-d--iteb
(display: inline-table)
.u-d--tbcp
(display: table-caption)
.u-d--tbcl
(display: table-column)
.u-d--tbclg
(display: table-column-group)
.u-d--tbhg
(display: table-header-group)
.u-d--tbfg
(display: table-footer-group)
.u-d--tbr
(display: table-row)
.u-d--tbrg
(display: table-row-group)
.u-d--tbc
(display: table-cell)
.u-d--rb
(display: ruby)
.u-d--rbb
(display: ruby-base)
.u-d--rbbg
(display: ruby-base-group)
.u-d--rbt
(display: ruby-text)
.u-d--rbtg
(display: ruby-text-group)
Installation
Using npm:
npm i -S jigsass-utils-display
Usage
Import JigSass Utils Display into your main scss file near its very end, together with all
other utilities (utilities should always be the last to be imported).
@import 'path/to/jigsass-utils-display/scss/index';
Like all other JigSass Utils, JigSass Display does not automatically generate any CSS
when imported. You would need to explicitly indicate that each individual display
class should actually be generated in each component or object it is used in
(clarification: This will include style declarations inside .foo
and .bar
):
// _c.foo.scss
.foo {
@include jigsass-util(u-d, $modifier: b); // <-- display: block
...
}
// _c.bar.scss
.bar {
@include jigsass-util(u-d, $modifier: ib); // <-- display: inline-block
@include jigsass-util(
u-d,
$modifier: f,
$from: large
); // <-- display: flex from large bp an on.
...
}
Doing so helps us a great deal with portability, as no matter where we import component or object
partials, the correct utility classes will be generated. Think of it as a poor man's dependency
management.
Developer communication is also assisted by including "dependencies" wherever they are required,
as anyone going through a partial, can easily understand how it should be marked up with just a
glance.
As far as bloat goes, just don't worry about it - the actual styles will only be generated once,
at the location in the cascade where the Jigsass Clearfix partial was imported into the main file.
JigSass Display classes are responsive-enabled, using JigSass MQ
and the breakpoints defined in the $jigsass-breakpoints variable.
Based on the breakpoint arguments passed to jigsass-util
when including a display class, responsive
modifiers are generated according to the following logic:
.u-d--<modifier>[-[-from-<breakpoint-name>][-until-<breakpoint-name>][-misc-<breakpoint-name>]]
So, assuming the medium
, large
and landscape
breakpoints are defined in $jigsass-breakpoints
as 600px
, 1024px
and (orientation: landscape)
respectively,
@include jigsass-util(u-d, $modifier: f);
will generate the .u-d--f
class, which is not limited to any media-query.
@include jigsass-util(u-d, $modifier: f, $until: medium);
will generate the .u-d--f--until-medium
class, which will be in effect at
(max-width: 37.49em)
and will override styles in the default class until that point.
@include jigsass-util(u-d, $modifier: f, $from: large, $misc: landscape);
will generate the .u-d--f--from-large-when-landscape
class, which will go into
effect at (min-width: 64em) and (orientation: landscape)
and will override styles in the default
class under these conditions.
License: MIT