Giter VIP home page Giter VIP logo

typographic's Introduction

Typographic is responsive typography made easy. Pick a few font stacks, set a few settings, and you've got beautiful responsive typography - it's that easy.

Installation

  • bower install typographic
  • @import Typographic somewhere in your stylesheet

Usage

It's as easy as setting a few variables in a custom settings file (or letting the defaults do their thing) and then calling the mixin typographic() with no arguments.

Settings

$line-height-ratio   = 1.75
$heading-ratio       = $golden
$body-font           = $helvetica
$body-font-weight    = 300
$body-color          = #666
$heading-font        = $helvetica
$heading-font-weight = 500
$heading-color       = #111
$min-font            = 13px
$max-font            = 20px
$min-width           = 600px
$max-width           = 1000px
$vertical-rhythm     = true

Ratios

The ratios are based off of the ratios used on modular scale.

$minor-second   = 1.067
$major-second   = 1.125
$minor-third    = 1.2
$major-third    = 1.25
$perfect-fourth = 1.333
$aug-fourth     = 1.414
$perfect-fifth  = 1.5
$minor-sixth    = 1.6
$golden         = 1.618
$major-sixth    = 1.667
$minor-seventh  = 1.778
$major-seventh  = 1.875
$octave         = 2
$major-tenth    = 2.5
$major-eleventh = 2.667
$major-twelfth  = 3
$double-octave  = 4

Font Stacks

Stacks are picked from A Way Back's Revised Font Stack.

// Sans-serif

$calibri       = 'Calibri', 'Candara', 'Segoe', 'Segoe UI', 'Optima', 'Arial', 'sans-serif'
$candara       = 'Candara', 'Calibri', 'Segoe', 'Segoe UI', 'Optima', 'Arial', 'sans-serif'
$courier       = 'Courier New', 'Courier', 'Lucida Sans Typewriter', 'Lucida Typewriter', 'monospace'
$franklin      = 'Franklin Gothic Medium', 'Arial', 'sans-serif'
$futura        = 'Futura', 'Trebuchet MS', 'Arial', 'sans-serif'
$geneva        = 'Geneva', 'Tahoma', 'Verdana', 'sans-serif'
$gill-sans     = 'Gill Sans', 'Gill Sans MT', 'Calibri', 'sans-serif'
$helvetica     = 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif'
$lucida-grande = 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Geneva', 'Verdana', 'sans-serif'
$optima        = 'Optima', 'Segoe', 'Segoe UI', 'Candara', 'Calibri', 'Arial', 'sans-serif'
$segoe         = 'Segoe', 'Segoe UI', 'Helvetica Neue', 'Arial', 'sans-serif'
$tahoma        = 'Tahoma', 'Geneva', 'Verdana', 'sans-serif'
$trebuchet     = 'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Tahoma', 'sans-serif'
$verdana       = 'Verdana', 'Geneva', 'sans-serif'


// Serif

$antiqua       = 'Book Antiqua', 'Palatino', 'Palatino Linotype', 'Palatino LT STD', 'Georgia', 'serif'
$baskerville   = 'Baskerville', 'Baskerville old face', 'Hoefler Text', 'Garamond', 'Times New Roman', 'serif'
$bodoni        = 'Bodoni MT', 'Didot', 'Didot LT STD', 'Hoefler Text', 'Garamond', 'Times New Roman', 'serif'
$cambria       = 'Cambria', 'Georgia', 'serif'
$caslon        = 'Big Caslon', 'Book Antiqua', 'Palatino Linotype', 'Georgia', 'serif'
$constantia    = 'Constantia', 'Palatino', 'Palatino Linotype', 'Palatino LT STD', 'Georgia', 'serif'
$didot         = 'Didot', 'Didot LT STD', 'Hoefler Text', 'Garamond', 'Times New Roman', 'serif'
$garamond      = 'Garamond', 'Baskerville', 'Baskerville Old Face', 'Hoefler Text', 'Times New Roman', 'serif'
$goudy         = 'Goudy Old Style', 'Garamond', 'Big Caslon', 'Times New Roman', 'serif'
$hoefler       = 'Hoefler Text', 'Baskerville old face', 'Garamond', 'Times New Roman', 'serif'
$lucida-bright = 'Lucida Bright', 'Georgia', 'serif'
$palatino      = 'Palatino', 'Palatino Linotype', 'Palatino LT STD', "Book Antiqua", 'Georgia', 'serif'

Helpers

Typographic comes equipped with 2 extremely handy helpers. One for previewing your vertical rhythm grid, and another for sizing and spacing elements so they adhere to your vertical rhythm.

The preview grid mixin is easy. It accepts a color and a positive or negative pixel offset parameter (for nudging your lines up to the bottom of text).

grid-overlay(blue, 2)

Note grid-overlay() behaves somewhat funny in smaller viewports when $min-font is set to an odd number. This is due to a floating issue. Just something to keep in mind if your vertical rhythm looks haywire on smaller devices. Fear not, it's fine.

The other helper is the vr-block() function, which returns sizes of your vertical rhythm. For instance, if you want to include an image that takes up 5.25 vertical units height and has a margin-bottom of .25 vertical unit (as in our demo), you could create it like this:

img
  height: vr-block(5.25)
  margin-bottom: vr-block(.25)

vr-block() accepts a second parameter for pixel offsetting to help nudge your elements back onto the vertical rhythm in case they are off by a pixel or two.

Usage with Node

var fs = require('fs'),
    stylus = require('stylus'),
    typographic = require('typographic');

stylus(fs.readFileSync('./css/style.styl', 'utf8'))
  .use(typographic())
  .render(function(err, css){
    if (err) return console.error(err);
    console.log(css);
  });
@import 'typographic'

$min-font: 14px

typographic()

Browser Support

  • Full support for IE9+
  • IE8 doesn't support calc or viewport units or media queries by default so you shouldn't support it (you will get $min-font for all viewport sizes), but if you have a stingy client, you can include these polyfills to at least have it swap between the $max-font and $min-font at your specified breakpoint.

Caveats

  • Slow in Sass because Sass doesn't support calculating decimals in exponents by default. Luckily you only have to change a few variables to get your compiled typography stylesheet then you can un-import Typographic. If lack of solid math in native Sass bothers you, please chime in on this issue.
  • Vertical rhythm doesn't really work with headings. It looks fine on h1, h2, and h3, but the line-height gets out of control on smaller headings. I've added a $vertical-rhythm setting to fall back to decent looking typography that isn't focused on vertical rhythm for just this case.

Credits

typographic's People

Contributors

corysimmons avatar janwirth avatar scottkellum avatar simoncollins 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typographic's Issues

Monotype, script & better notes please

I think your _font-stacks.styl is very handy. Here are some ideas to expand it. Low priority; more like expand as we run across examples on the web.

  • Add Monotype (focus on legible code presentation, but a fancy-typewriter set is welcome
  • Add script (focus on legable, pre-installed fonts & free CDN hosted fonts)
  • Add source of fonts; to help gauge availability. Should show in exported CSS as a comment; expecting final production code to be minified with comments stripped. See example below:
// Monotype-sans
/* Vista+, MS Office Win & Mac | Default Mac | IE 5 & 6, OSX */
consolas = Consolas, Monaco, "Andale Mono", monospace

// Monotype-serif

// Script

Not sure if you're the type of repo manger who is OK with many micro-PRs or prefers larger, more complete PRs?

Todo/Notes

html font-size: 62.5%

Slightly confused how I would go about making sure the html is set to 62.5% using your plugin.

Re-set header sizes

After the original re-set, h1 looks good, h2 looks decent, but as the headers go on, the line-height gets pretty insane. Need to fix this.

h5

Responsive letter-spacing

I'm currently using media queries for responsive letter spacing to increase letter spacing at smaller font sizes but would be great if they could be variables here. I know these are some very minute adjustments but they can make a big difference in overall typographic sexiness.

E.g.:

$min-font            : 12px !default;
$max-font            : 20px !default;
$min-font-spacing    : 1px !default;
$max-font-spacing    : 0px !default;
$header-font-spacing : -0.2em !default;

!default

You should use the !default flag for configurable settings.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Port to PostCSS

Hi, Do you have any plan to port this one to PortCSS as well?

Convert to rem

  • Create rem mixin, convert everything to rem with px fallback
  • Consider creating em option (hard so meh)

Color definitions

Do color definitions really belong into a typographic toolset? I am having conflicts with the reset and normalization included with axis.

Advanced options

In my personal experience, there are two options to a typographic set I adjust almost everytime, that are not included here yet.

  • letter-spacing
  • transformation (uppercase)

Looking forward to any comments & thoughts on this.

Does not work with wiredep

Typographic (specifically the scss version) is not automatically injected by wiredep like your other project, lost.

I suspect this is an issue with the bower.json configuration, but I've not had a chance to look at it in depth. It's a minor annoyance but should probably be fixed!

Arithmetic vs geometric scaling

My understanding is that the modular scale is a geometric sequence, not an arithmetic sequence. If that's the case (and an examination of Tim Brown's scale output suggests it is), then your function:

 t-scale(numbawang = 1, rat = ratio)
   return unit(numbawang * rat, rem)

should probably be something like

 t-scale(numbawang = 1, rat = ratio)
   return unit(rat^(1 - numbawang), rem)

This would set the p, ol, and ul elements to a font-size of 1rem (as expected) instead of 1.618rems (if using the 'golden ratio') and have the headers scale geometrically instead of by a fixed increment (in this case, the product of the 'numbawang' increment and the ratio).

Tim Brown's scale performs this way, with 'numbawang' increments of 1. Increments of 0.5, though, would seem to be more appropriate for headers. With such increments, and using the golden ratio, your output would be
1, 1.272, 1.618, 2.058, 2.618, 3.330 rems
instead of
1.2135, 1.618, 2.0225, 2.427, 2.8315, 3.236 rems

I can submit a PR if this makes sense to you.

Great job on jeet, by the way. I hope to see a companion UI kit soon!

Weird @media behaviour

Hey!

I'm trying to use typographic inside media query, but it seems that in this case the settings are not overridden correctly:

@media (max-width: 320px)
    $header-font    = $geneva
    $body-font      = $geneva
    $body-color     = orange
    typographic()

results in

@media (max-width: 320px) {
  html {
    font-family: 'Helvetica Neue', 'Helvetica', 'Arial', 'sans-serif';
    font-weight: 300;
    color: #666;
    font-size: 12px;
    line-height: 1.75em;
  }
//more code here

As you can see, the font and color remain default.

Safari nested grid gap?

I'm only seeing this in Safari (OS X and iOS), but when nesting a grid, I am getting the attached gap at the end of the nested row. Not an issue in Chrome or Firefox on Mac.

HTML:

<div class="grid-lost-2 om-grid-display">
    <section>
        <div>1</div>
        <div>2</div>
        <div>3
            <section>
                <div>1</div>
                <div>2</div>
                <div>3</div>
                <div>4</div>
            </section>
        </div>
    </section>
</div>

SCSS:

.grid-lost {
    & + & {
        margin-top: 3.2rem;
    }
    section {
        lost-center: 1170px; // Max-width, center and clearfix
    }
    div {
        lost-column: 1/4;
        @media all and (min-width: $break1) {
            lost-column: 1/6;
        }
        @media all and (min-width: $break2) {
            lost-column: 1/12;
        }
    }
}

.grid-lost-2 {
    @extend .grid-lost;
    & > section > div {
        lost-column: 1/4;
    }
    & > section > div:last-child {
        lost-column: 1/2 3;
    }
    & > section > div > section > div {
        lost-column: 1/4;
    }
}

screen shot 2015-12-21 at 10 01 05 am

README.md needs a bit of correction

In the section "Putting it all together" t-headers(helvetica) needs to be above "html". For me it didn't work until I did that.

I need to mentiion that I tested it on a current project with which I began using Typographic 0.1.0 and the issue occured after I updated to 1.0.0.

$golden is used instead of $ratio

All over the stylesheet you use the $golden variable instead of the ratio. This makes the $ratio setting useless in term of definig the actual scale.

Port to SCSS

Waiting until it's a bit more feature-rich in Stylus until I do this.

Remove Preset Colors

At the end of the day, typographic should be a tool that helps you manage typography spacing/sizing/etc. And it does all of that BEAUTIFULLY might I add.

The problem is, with a recent release, you went and added things like:

a
  color: dodgerblue
    &:visited
      color: darken(dodgerblue, 10%)
input[type="submit"], button
    background: darken(white, 3%)
code
    background: darken(white, 2%)
pre
  padding: vr-block(.5)
  background: darken(white, 2%)
code
      background: none

etc.

You are setting all of those up at the core level which take precedence over any class that we create. This is an absolute nightmare when coding.

You should save all of those base colors and backgrounds for your Switch repo because I really don't think typographic is the right place for it. We should be able to use typographic to get JUST a typography solution but you started embedding a bunch of base colors at the core level into it recently which kind of ruins the purpose of what Typographic is trying to be.

Vertical Rhythm/Baseline Grid

Awesome stuff, thanks for doing this.. I have been meaning to create something similar lately. Do you have any plans on adding vertical rhythm/some sort of baseline grid that's more consistent?

Quotes

You should either quote all font names, or none, but not a mix. I'd recommend quoting them all.

Override settings

I'm pretty new to Stylus, been using other preprocessors for years though, so bear with me.

I'm trying to use typographic with gulp the following way:

# Styles.
gulp.task "styles", ->
  source src.stylus + "/app.styl"
    .pipe stylus
      use: [
        "nib"
        "jeet"
        "rupture"
        "typographic"
      ]
    .pipe prefix(
      "last 2 versions"
      "> 1%"
      "ie 9"
      "Android 4"
      "iOS 6"
    )
    .pipe gulpif !!util.env.production, minifycss()
    .pipe gulp.dest dest.css
    .pipe size()
    .pipe notify
      message : "Generated styles: <%= file.relative %>"
      notifier: growlNotifier
      templateOptions:
        date: util.date new Date(), "yyyy-mm-dd hh:mm:ss"

Everything gets imported fine and it works like it should. My problem comes when I try to override the typographic settings. In other preprocessors I've worked with you would use @import and then override the variables. In this case everything already seem loaded and I can't get my custom settings variables to work.

Would love some help and insight on how to do this and what the best practice is. I'm guessing that there is similar issues when compiling Stylus with CLI etc.

NPM package out of date?

package.json in the repository says version 3.0, but the latest NPM package seems to be version 2.9.3.

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.