Border Utils

Introduction

A collection of dynamically generated border utility classes.

JigSass Utils Border works in tandem with JigSass Tools typography, providing utility classes which add borders that don't mess up vertical rhythm.

Border utils can be limited to a certain state (i.e., hover, focus, etc.)

The syntax for generating a border util is: $modifier: '<width-in-pixels>[(<rhythm-units>,<border-style>,<border-color>)][:state]'

Class names follow the Emmet abbreviation syntax, with colons (':') replaced by two dashes (--) to follow BEM naming conventions, e.g, bdb--1px(2,solid,#ccc) for setting border-bottom of 1px, a padding-bottom of two typographic lines minus the border width, border-style of solid and border-color or #ccc.

Available classes

Border Width

  • u-bd--<width> (example: u-bd--2px, sets a border of 2 pixels around an element)
  • u-bd--<width>(<rhythm-units>,<style>,<color>) (example: u-bd--1px(1,dotted,#ccc), sets a border of 1px around an element, padding of 1 rhythm unit minus 1px, a border-style of dotted and border color of #ccc)
  • u-bdt--<width> (example: u-bd--2px, sets a border of 2 pixels above an element)
  • u-bdt--<width>(<rhythm-units>,<style>,<color>) (example: u-bd--1px(1,dotted,#ccc), sets a border of 1px above an element, padding of 1 rhythm unit minus 1px, a border-style of dotted and border color of #ccc)
  • u-bde--<width> (example: u-bd--2px, sets a border of 2 pixels at the horizontal end an element)
  • u-bde--<width>(<rhythm-units>,<style>,<color>) (example: u-bd--1px(1,dotted,#ccc), sets a border of 1px at the horizontal end of an element, padding of 1 rhythm unit minus 1px, a border-style of dotted and border color of #ccc)
  • u-bdr--<width> (example: u-bd--2px, sets a border of 2 pixels at the right end of an element)
  • u-bdr--<width>(<rhythm-units>,<style>,<color>) (example: u-bd--1px(1,dotted,#ccc), sets a border of 1px at the right end of an element, padding of 1 rhythm unit minus 1px, a border-style of dotted and border color of #ccc)
  • u-bdb--<width> (example: u-bd--2px, sets a border of 2 pixels below an element)
  • u-bdb--<width>(<rhythm-units>,<style>,<color>) (example: u-bd--1px(1,dotted,#ccc), sets a border of 1px below an element, padding of 1 rhythm unit minus 1px, a border-style of dotted and border color of #ccc)
  • u-bds--<width> (example: u-bd--2px, sets a border of 2 pixels at the horizontal start an element)
  • u-bds--<width>(<rhythm-units>,<style>,<color>) (example: u-bd--1px(1,dotted,#ccc), sets a border of 1px at the horizontal start of an element, padding of 1 rhythm unit minus 1px, a border-style of dotted and border color of #ccc)
  • u-bdl--<width> (example: u-bd--2px, sets a border of 2 pixels at the left end of an element)
  • u-bdl--<width>(<rhythm-units>,<style>,<color>) (example: u-bd--1px(1,dotted,#ccc), sets a border of 1px at the left end of an element, padding of 1 rhythm unit minus 1px, a border-style of dotted and border color of #ccc)

    Border Radius

  • u-bdrs--<radius> (example: u-bd--2px, sets a border of 2 pixels at the left end of an element)

Installation

Using npm:

npm i -S jigsass-utils-border

Usage

Import JigSass Utils Border 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-border/scss/index';

Like all other JigSass Utils, JigSass Utils Border does not automatically generate any CSS when imported. You would need to explicitly indicate that each individual border 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-bds, $modifier: '2px(1,solid,#4c4)');

  ...
}
// _c.bar.scss
.bar {
  @include jigsass-util(u-bdb, $modifier: '1px(1,dotted,#4c4):hover');
  @include jigsass-util(u-bdb, $modifier: '2px(1,dotted,#4c4):hover', $from: large);

  ...
}

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 Utils Border partial was imported into the main file.

JigSass Utils Border 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 class, responsive modifiers are generated according to the following logic:

.u-bd-<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-bd, $modifier: 1px);

will generate the u-bd--1px class, which is not limited to any media-query.

@include jigsass-util(u-bd, $modifier: '1px(1,solid)', $until: medium);

will generate the u-bd--1px(1,solid)--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-bd, $modifier: 2px(2):focus, $from: large, $misc: landscape);

will generate the u-bd--2px(2):focus--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

u-bd--6px

A utility class to set an element's border

Include with:

@include jigsass-util(u-bd, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bd--6px'></div>

u-bd--6px(2,solid,#0784ae)

A utility class to set an element's border and padding so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bd, $modifier: 6px(2,solid,#0784ae) [, $from, $until, $misc]);

Example

<div class='fpo  u-bd--6px(2,solid,#0784ae)'></div>

u-bd--6px(2,solid,#0784ae):hover

A utility class to set an element's border and padding on :hover so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bd, $modifier: 6px(2,solid,#0784ae):hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bd--6px(2,solid,#0784ae):hover'></div>

u-bdt--6px

A utility class to set an element's border-top

Include with:

@include jigsass-util(u-bdt, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bdt--6px'></div>

u-bdt--6px(2,solid,#0784ae)

A utility class to set an element's border-top and padding so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdt, $modifier: 6px(2,solid,#0784ae) [, $from, $until, $misc]);

Example

<div class='fpo  u-bdt--6px(2,solid,#0784ae)'></div>

u-bdt--6px(2,solid,#0784ae):hover

A utility class to set an element's border-top and padding on :hover so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdt, $modifier: 6px(2,solid,#0784ae):hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bdt--6px(2,solid,#0784ae):hover'></div>

u-bde--6px

A utility class to set an element's border-end

Include with:

@include jigsass-util(u-bde, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bde--6px'></div>

u-bde--6px(2,solid,#0784ae)

A utility class to set an element's border-end and padding so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bde, $modifier: 6px(2,solid,#0784ae) [, $from, $until, $misc]);

Example

<div class='fpo  u-bde--6px(2,solid,#0784ae)'></div>

u-bde--6px(2,solid,#0784ae):hover

A utility class to set an element's border-end and padding on :hover so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bde, $modifier: 6px(2,solid,#0784ae):hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bde--6px(2,solid,#0784ae):hover'></div>

u-bdr--6px

A utility class to set an element's border-right

Include with:

@include jigsass-util(u-bdr, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bdr--6px'></div>

u-bdr--6px(2,solid,#0784ae)

A utility class to set an element's border-right and padding so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdr, $modifier: 6px(2,solid,#0784ae) [, $from, $until, $misc]);

Example

<div class='fpo  u-bdr--6px(2,solid,#0784ae)'></div>

u-bdr--6px(2,solid,#0784ae):hover

A utility class to set an element's border-right and padding on :hover so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdr, $modifier: 6px(2,solid,#0784ae):hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bdr--6px(2,solid,#0784ae):hover'></div>

u-bdb--6px

A utility class to set an element's border-bottom

Include with:

@include jigsass-util(u-bdb, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bdb--6px'></div>

u-bdb--6px(2,solid,#0784ae)

A utility class to set an element's border-bottom and padding so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdb, $modifier: 6px(2,solid,#0784ae) [, $from, $until, $misc]);

Example

<div class='fpo  u-bdb--6px(2,solid,#0784ae)'></div>

u-bdb--6px(2,solid,#0784ae):hover

A utility class to set an element's border-bottom and padding on :hover so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdb, $modifier: 6px(2,solid,#0784ae):hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bdb--6px(2,solid,#0784ae):hover'></div>

u-bds--6px

A utility class to set an element's border-start

Include with:

@include jigsass-util(u-bds, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bds--6px'></div>

u-bds--6px(2,solid,#0784ae)

A utility class to set an element's border-start and padding so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bds, $modifier: 6px(2,solid,#0784ae) [, $from, $until, $misc]);

Example

<div class='fpo  u-bds--6px(2,solid,#0784ae)'></div>

u-bds--6px(2,solid,#0784ae):hover

A utility class to set an element's border-start and padding on :hover so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bds, $modifier: 6px(2,solid,#0784ae):hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bds--6px(2,solid,#0784ae):hover'></div>

u-bdl--6px

A utility class to set an element's border-left

Include with:

@include jigsass-util(u-bdl, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bdl--6px'></div>

u-bdl--6px(2,solid,#0784ae)

A utility class to set an element's border-left and padding so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdl, $modifier: 6px(2,solid,#0784ae) [, $from, $until, $misc]);

Example

<div class='fpo  u-bdl--6px(2,solid,#0784ae)'></div>

u-bdl--6px(2,solid,#0784ae):hover

A utility class to set an element's border-left and padding on :hover so that it does not mess up the vertical rhythm

Include with:

@include jigsass-util(u-bdl, $modifier: 6px(2,solid,#0784ae):hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bdl--6px(2,solid,#0784ae):hover'></div>

u-bdrs--6px

A utility class to set an element's border-radius.

Include with:

@include jigsass-util(u-bdrs, $modifier: 6px [, $from, $until, $misc]);

Example

<div class='fpo  u-bdrs--6px'></div>

u-bdrs--50%

A utility class to set an element's border-radius.

Include with:

@include jigsass-util(u-bdrs, $modifier: 50% [, $from, $until, $misc]);

Example

<div class='fpo  u-bdrs--50%'></div>

u-bdrs--50%:hover

A utility class to set an element's border-radiuson :hover .

Include with:

@include jigsass-util(u-bdrs, $modifier: 50%:hover [, $from, $until, $misc]);

Example

<div class='fpo  u-bdrs--50%:hover'></div>