GithubHelp home page GithubHelp logo

hiulit / sassy-gridlover Goto Github PK

View Code? Open in Web Editor NEW
220.0 11.0 12.0 734 KB

Super easy to use Sass mixins to establish a typographic system with modular scale and vertical rhythm. Based on the Gridlover app.

Home Page: https://hiulit.github.io/Sassy-Gridlover/sassdoc/

License: MIT License

CSS 39.03% HTML 48.51% JavaScript 12.09% Ruby 0.37%
sass sass-mixins gridlover typography modular-scale vertical-rhythm

sassy-gridlover's Introduction

Sassy-Gridlover Build Status

Super easy to use Sass mixins to establish a typographic system with modular scale and vertical rhythm. Based on the Gridlover app.

Gridlover gives you adjustable CSS for font sizes, line heights and margins. The default CSS output is for html, body, h1-h6, p, ul, ol, etc. but you can of course apply your adjusted values to any element by editing the CSS later.

First of all

Go play around with the awesome Gridlover app!

It's so much fun! ๐Ÿ˜„

Installation

Install Sassy-Gridlover via bower.

$ bower install sassy-gridlover

Install Sassy-Gridlover via npm.

$ npm install sassy-gridlover

Install Sassy-Gridlover via yarn.

$ yarn add sassy-gridlover

or Download the repository and include the sassy-gridlover folder to your Sass directory.

Getting started

Sassy-Gridlover consists of 7 configurable variables:

$sgl-base-font-size;
$sgl-base-line-height;
$sgl-base-unit;
$sgl-scale-factor;
$sgl-debug-mode;
$sgl-debug-mode-max-width;
$sgl-extras;

and 4 mixins:

@mixin sgl-html();
@mixin sgl-body();
@mixin sgl-heading();
@mixin sgl-margins();

These are the 4 functionalities of the Gridlover app that you (should) have been playing with ;)

Setup

Import _sassy-gridlover.scss to your main style sheet.

@import "sassy-gridlover";

Change the configurable variables values in _config.scss to your liking.

I would encourage you not to change them directly here, though. It would be better to declare them in your _variables.scss, _config.scss or the like.

Mixins

By default, all the mixins (except sgl-html) will output em. But you can also choose to output px, rem or pxrem.

sgl-html()

This mixin is mandatory for the all the other mixins to work.

To use on <html>.

Outputs font-size and line-height always in px.

html {
    @include sgl-html($font-size: $sgl-base-font-size);
}

Parameters

Name Description Type Default value
$font-size Root font size. Number $sgl-base-font-size

sgl-body()

To use on <body>.

Outputs font-size and line-height.

body {
    @include sgl-body($line-height-step: 0, $unit: $sgl-base-unit);
}

Parameters

Name Description Type Default value
$line-height-step Multiplies the step number by the base line-height (from sgl-html). If 0 is set, it will actually multiply by 1. Number 0
$unit Unit to output (px, em, rem, pxrem). String $sgl-base-unit

sgl-heading()

To use on headings <h1> - <h6>.

Outputs font-size, line-height, margin-top and margin-bottom.

@include sgl-heading($font-size-step, $line-height-step, $margin-top-step, $margin-bottom-step, $unit: $sgl-base-unit, $base-value: $sgl-base-font-size)

Parameters

Name Description Type Default value
$font-size-step Creates an exponent of the base font-size (from sgl-html) in conjunction with sgl-scale-factor. 0 is the base font-size. Number -
$line-height-step Multiplies the step number by the base line-height (from sgl-html). If 0 is set, the line-height will grow with the font-size accordingly. Number -
$margin-top-step Multiplies the step number by the base line-height (from sgl-html). Number -
$margin-bottom-step Multiplies the step number by the base line-height (from sgl-html). Number -
$unit Unit to output (px, em, rem, pxrem). String $sgl-base-unit
$base-value Optional parameter for a different base font size when using em. Number $sgl-base-font-size

sgl-margins()

To use on <p>, <ul>, <ol>, <pre>, <table>, <blockquote>, etc.

Outputs margin-bottom and margin-top.

@include sgl-margins($margin-top-step, $margin-bottom-step, $unit: $sgl-base-unit, $base-value: $sgl-base-font-size)

Parameters

Name Description Type Default value
$margin-top-step Multiplies the step number by the base line-height (from sgl-html). Number -
$margin-bottom-step Multiplies the step number by the base line-height (from sgl-html). Number -
$unit Unit to output (px, em, rem, pxrem). String $sgl-base-unit
$base-value Optional parameter for a different base font size when using em. Number $sgl-base-font-size

Debug mode

Enables/disables debug mode.

Outputs background lines imitating a notebook's sheet.

Parameters

Name Description Type Default value
$sgl-debug-mode Enables/disables debug mode. Boolean false

Declare it in your own _variables.scss, _config.scss or the like. Basically, it must be declared before the @import "sassy-gridlover".

Example

Example of Sassy-Gridlover's debug mode

Extras

Styles to make sure everything is aligned.

Outputs extra reset styles.

Parameters

Name Description Type Default value
$sgl-extras Outputs styles to make sure everything is aligned. Boolean false

Declare it in your own _variables.scss, _config.scss or the like. Basically, it must be declared before the @import "sassy-gridlover".

CSS output

html hr,
html .hr {
    border: 1px solid;
    margin: -1px 0;
}

html a,
html b,
html i,
html strong,
html em,
html small,
html code {
    line-height: 0;
}

html sub,
html sup {
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

html sup {
    top: -0.5em;
}

html sub {
    bottom: -0.25em;
}

Example usage

SCSS

$sgl-debug-mode: false;
// $sgl-debug-mode-max-width: 1024; // Only needed if `$sgl-debug-mode` is `true`.
$sgl-extras: false;

@import "../../sassy-gridlover/sassy-gridlover";

html {
    @include sgl-html;
}

body {
    @include sgl-body;
}

h1 {
    @include sgl-heading(3, 0, 1, 2);
}

h2 {
    @include sgl-heading(2, 0, 1, 1);
}

h3 {
    @include sgl-heading(1, 0, 1, 0);
}

h4 {
    @include sgl-heading(0, 0, 1, 0);
}

h5 {
    @include sgl-heading(0, 0, 1, 0);
}

p,
ul,
ol,
pre,
table,
blockquote {
    @include sgl-margins(0, 1);
}

ul ul,
ol ol,
ul ol,
ol ul {
    @include sgl-margins(0, 0);
}

CSS output

html {
  font-size: 18px;
  line-height: 23px;
}

body {
  font-size: 1em;
  line-height: 1.27778em;
}

h1 {
  font-size: 4.22223em;
  line-height: 1.21053em;
  margin-top: 0.30264em;
  margin-bottom: 0.60527em;
}

h2 {
  font-size: 2.61112em;
  line-height: 1.46809em;
  margin-top: 0.48937em;
  margin-bottom: 0.48937em;
}

h3 {
  font-size: 1.61112em;
  line-height: 1.58621em;
  margin-top: 0.79311em;
  margin-bottom: 0em;
}

h4 {
  font-size: 1em;
  line-height: 1.27778em;
  margin-top: 1.27778em;
  margin-bottom: 0em;
}

h5 {
  font-size: 1em;
  line-height: 1.27778em;
  margin-top: 1.27778em;
  margin-bottom: 0em;
}

p,
ul,
ol,
pre,
table,
blockquote {
  margin-top: 0em;
  margin-bottom: 1.27778em;
}

ul ul,
ol ol,
ul ol,
ol ul {
  margin-top: 0em;
  margin-bottom: 0em;
}

Changelog

See CHANGELOG.

Contributing

See CONTRIBUTING.

Authors

Inspiration and alternatives

  • Gridlover app - The tool to establish a typographic system with modular scale and vertical rhythm on which Sassy-gridlover is based.
  • Knife - Nail vertical rhythm, modular scale, and REMs like a boss with this simple set of SASS/SCSS variables, functions and mixins.
  • gridlover-mixin - A mixin to generate modular scale and vertical rhythm for your typography.

Credits

Thanks to:

License

MIT License.

sassy-gridlover's People

Contributors

hiulit avatar tbaddade avatar walmokrani avatar xavier-gomez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sassy-gridlover's Issues

Use !default in your variables _config.scss

http://robots.thoughtbot.com/sass-default

This will allow me to use _sass-gridlover.scss but define my own config that overrides these preset defaults.

Maybe also consider name spacing your variables.

...
// Default font size.
// Don't change this variable!
$sgl-defaultFontSize: 16;

// Configurable variables.
// Ok... You can change these variables! :D
$sgl-baseFontSize: 18 !default;
$sgl-baseLineHeight: 1.2 !default;
$sgl-scaleFactor: $sgl-goldenSection !default;

Error: Invalid null operation: "null times 2.36859"

Hello there, first of all, thank u so much for this awesome tool. I've used old version but now I've some troubles at compile. The error shows:
Error: Invalid null operation: "null times 2.36859".
on line 192 of ../scss/vendors/sassy-gridlover/_sassy-gridlover.scss, in mixin sgl-heading
from line 29 of ../scss/pages/_single.scss
from line 41 of ../scss/main.scss

$computed-font-size: round($font-size * sgl-exponent($scale, $font-size-

-------------------------------^

I'm using npm 5.5.1
node v9.3.0
gulp 3.9.1

Use pow() when available

You could make your exponent() function use pow for Compass, Sassy-Math or whatever when available.

@function exponent($base, $exponent) {
    @if pow(2, 2) == 4 {
        @return pow($base, $exponent);
    }

    // Resets value.
    $value: $base;
    // Positive intergers get multiplied.
    @if $exponent > 1 {
        @for $i from 2 through $exponent {
            $value: $value * $base; } }
    // Negatives intergers get divided. A number divided by itself is 1.
    @if $exponent < 1 {
        @for $i from 0 through -$exponent {
            $value: $value / $base; } }
    // Return the last value written.
    @return $value;
}

npm publish

pls publish the new version to npm ;)
thanks!

Line Heights with Ems

Hi, thanks for making this, it's very useful!

So, I'm just working on a site where I'm using EMs for font sizing. I've noticed that when using headers that break on to more than one line, the layout is going slightly off the grid. (it seems to work fine if I switch the units to rems or px but that breaks the ease of modifying the body font size)

Here's my Sass

$sgl-base-font-size: 12
$sgl-base-line-height: 2
$sgl-base-unit: 'em'
$sgl-scale-factor: $GOLDEN_SECTION

html
  background-image: linear-gradient(to bottom, hsla(200, 100%, 50%, .3) 1px, transparent 1px)
  background-position: left -1px
  background-repeat: repeat
  background-size: round(($sgl-base-font-size * $sgl-base-line-height)) * 1px round(($sgl-base-font-size * $sgl-base-line-height)) * 1px

body
  +sgl-body

h1
  +sgl-heading(3)

And some example HTML

<h1>Some long text that will wrap on to more than one line. Some more long text that will wrap on to more than one line. Some more long text that will wrap on to more than one line</h1>
<p>Content</p>

I wonder if one of the calculations is a bit off or if some of the roundings are putting a bit out of whack. Interestingly, if you set the base font size to 48px it lines up correctly.

Also, even though I was setting the debug option to true, it wasn't outputting the CSS for the html so I had to add it in manually.

Thanks,

Chris

use less generic functions names

IMO functions should be prefixed, because names are too generic. It can cause conflicts. For example rem-calc() may cause conflict with foundation framework. I suggest to prefix all the functions with $sgl-*

Rewrite $step3 on sgl-heading mixins ?

When I use steps more than 3, let say 5 to 0, I need to re-adjust sgl-heading mixins. Change margin-bottom to 0.
Because when I use step 3 for H3 it will be make more margin bottom.
What do you think?

Using em instead rem

First of all thx for your work it's very usefull.
How about em? Can I re-config Gridlover to use em instead rem?

dart-sass: deprecation warning: !global assignments won't be able to declare new variables

Expected behavior

No deprecation warnings in the console.

Actual behavior

dart-sass (v 1.17.2) is reporting deprecation warnings.

DEPRECATION WARNING: As of Dart Sass 2.0.0, !global assignments won't be able to
declare new variables. Consider adding `$sgl-root-font-size: null` at the top level.

Steps to reproduce the behaviour

Use the official sass module instead of an unofficial node-sass module to compile the code.

Default export

It would be cool to add path to main file in package.json, so importing with bundlers won't be so painful like this:
@import '~sassy-gridlover/sassy-gridlover/sassy-gridlover';

for example, how it implements in normalize.css

NPM Package?

would be really nice if you would also publish this package on npm, we stripped bower and now we only use npm for our dependencies.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.