PostCSS Typography [![Build Status][ci-img]][ci]
PostCSS plugin to support responsive typography shorthands..
Input:
@custom-media --mobile-m (min-width: 420px);
@custom-media --mobile-l (min-width: 600px);
@custom-media --tablet (min-width: 768px);
@custom-media --tablet-l (min-width: 1024px);
@custom-media --desktop (min-width: 1280px);
@custom-media --desktop-l (min-width: 1440px);
.foo {
@type 10px 15px 1px;
@type --mobile-m 12px / 0;
@type --desktop / 1.875 0.01em;
}
Output:
@custom-media --mobile-m (min-width: 420px);
@custom-media --mobile-l (min-width: 600px);
@custom-media --tablet (min-width: 768px);
@custom-media --tablet-l (min-width: 1024px);
@custom-media --desktop (min-width: 1280px);
@custom-media --desktop-l (min-width: 1440px);
.foo {
font-size: 10px 1.5 0.1em;
font-size: 0.615rem 1.5 0.1em;
@media (--mobile-m) {
font-size: 12px;
letter-spacing: 0;
}
@media (--desktop) {
line-height: 1.875;
letter-spacing: 0.01em;
}
}
Usage
Because this plugin relies on custom media queries, you are recommended to run it before postcss-cssnext or postcss-custom-media
postcss([ require('postcss-type')({rootSize: '16px'}), require('postcss-custom-media') ])
See PostCSS docs for examples for your environment.