Layouts

Star
The Trowel project is abandonned. Trowel core and the Trowel components are no more maintained or supported. More infos

Download

You can fetch Trowel Layouts with npm, yarn or bower.

# With bower
$ bower install --save trowel-layouts

# With npm
$ npm install --save trowel-layouts

# With yarn
$ yarn add trowel-layouts

You can also download a zip archive right here.

Installation

SCSS

The main scss file to include to your main .scss file is located at the ./src/scss/Layouts.scss. As a Trowel Component, it also requires two dependencies to compile the scss code. Here an scss installation snippet.

// Trowel core (need to be imported first)
@import './path/to/dependencies/trowel-core/src/trowel';

// Trowel Layouts
@import './path/to/dependencies/trowel-layouts/src/scss/layouts';

Usage

Containers

Use the .container class to contain your content in a fixed width.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<div class="container">
  ...
</div>

With the $container--width you can control the width of the container, and for example do fluid containers by setting up 100% as designed by default on the flag -fluid.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<div class="container container--fluid">
  ...
</div>

Grids

You can layout your content as grid, by first creating a .grid DOM element, then for each column a .grid__col and then specify the size of the column depending of the viewport width configured in the $trowel-config variable like .grid__col--xs-2.

col
col
col
col
<div class="grid">
  <div class="grid__col grid__col--xs-2 grid__col--sm-10"></div>
  <div class="grid__col grid__col--xs-4 grid__col--sm-2"></div>
  <div class="grid__col grid__col--xs-6 grid__col--sm-4"></div>
  <div class="grid__col grid__col--xs-12 grid__col--sm-8"></div>
</div>

Flex grids

You can also create a grid with flexbox. Wrap your columns with a .flex-grid DOM element. Then for each col use the .flex-grid__col class.

You will be able to custom the behavior of your flex-grid through *Trowel variables* but by default a `.flex-grid__col--grow-1` element-modifier class is available to make a column fill all the remaining space available.

col
col
col
col
<div class="flex-grid">
  <div class="flex-grid__col">
    <div class="grid-showoff">col</div>
  </div>

  <div class="flex-grid__col flex-grid__col--grow-1">
    <div class="grid-showoff">col</div>
  </div>

  <div class="flex-grid__col">
    <div class="grid-showoff">col</div>
  </div>

  <div class="flex-grid__col">
    <div class="grid-showoff">col</div>
  </div>
</div>

Sass reference

Syntax variables

You can override the global syntax config for a specific component with the following variables

VARIABLE DEFAULT VALUE DESCRIPTION
$layout--synthax null syntax config for .container, .grid and .flex-grid blocks

Enables

You can avoid the generation of some css with the following variables

VARIABLE DEFAULT VALUE DESCRIPTION
$container--enable true enable the generation of style rules for the .container block
$grid--enable true enable the generation of style rules for the .grid block
$flexgrid--enable true enable the generation of style rules for the .flex-grid block

Component variables

Container

VARIABLE DEFAULT VALUE DESCRIPTION
$container--padding-x 1rem Sets the left and right padding for the .container block
$container--width (
  'default': (
    '@sm': 540px,
    '@md': 720px,
  ),
  '-fluid': 100%,
)
Sets the width for the .container block

Grid

VARIABLE DEFAULT VALUE DESCRIPTION
$grid–gutter $container--padding-x sets the gutter space between two col
$grid–columns 12 not a trowel variable sets the max numbers of columns on a grid row

Flex-grid

VARIABLE DEFAULT VALUE DESCRIPTION
$flexgrid--gutter 0.5em sets the gutter space between two col
$flexgrid--flex-wrap wrap sets the flex-wrap property on block
$flexgrid--align-items null sets the align-items property on block
$flexgrid--justify-content null sets the justify-content property on block
$flexcol--flex-shrink null sets the flex-shrink property on .flex-grid__col elements
$flexcol--flex-basis null sets the flex-basis property on .flex-grid__col elements
$flexcol--flex-grow (
  'default': null,
  '~grow-1': 1,
)
sets the flex-grow property on .flex-grid__col elements