Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
typorhythm
Advanced tools
Getting Vertical Rhythm as never been so easy! Pass typoRhythm( size )
and it calculates the appropriate font-size
, line-height
in ems.
Available on npm
$ npm install --S typorhythm
See the Pen TypoRhythm on CodePen and the Inline JavaScript Version TypoRhythm JS on CodePen
Parameters:
size
expects a number
e.g. 14, 26, 47, 56
padding
expects a number
e.g. 0.5, 1, 2
* base:24
margin
expects a number
e.g. 0.5, 1, 2
* base:24
line-height
expects a number
e.g. 0.5, 1, 2
* base:24
, should be left to null
unit
expect a string
e.g. em, rem
import typoRhythm from 'typoRhythm'
class Hello extends React.Component {
render() {
return (
<h1 style={ typoRhythm(size: 47, margin: 1) } > Hello World </h1>
)
}
}
Result
{
fontSize: "2.9375em",
padding: null,
marginBottom: "0.5106382978723404em",
lineHeight: 1.0212765957446808
}
Change the default base
or fontsize
:
import {TypoRhythm} from 'typoRhythm'
const typoRhythm = new TypoRhythm(14, 32)
Import typoRhythm in your project
@import 'typorhythm.scss';
Include it in your element
h3 {
@include typoRhythm(21);
}
TypoRhythm will do the rhythmic math for you in ems
and compile to css:
h3 {
font-size: 1.3125rem;
line-height: 1.14286em;
}
Change the default base
or fontsize
:
$typorhythm_base: 24 !default;
$typorhythm_fontsize: 16 !default;
Example:
h3 {
@include typoRhythm(21, $padding: 1, $margin: 2);
}
h3 {
font-size: 1.3125em;
padding: 1.14286em;
margin-bottom: 2.28571em;
line-height: 1.14286;
}
Style multiple elements at once!
$sizeMap: ( h1:47, h2:34, h3:26, h4:21, h5:18, h6:16, p: 16, ul: 16 );
@include typoRhythmGenerator($sizeMap, $margin: 1);
h1 {
font-size: 2.9375rem;
margin-bottom: 0.51064em;
line-height: 1.02128;
}
h2 {
font-size: 2.125rem;
margin-bottom: 0.70588em;
line-height: 1.41176;
}
h3 {
font-size: 1.625rem;
margin-bottom: 0.92308em;
line-height: 1.84615;
}
/*
...
...
You get the gist!
*/
Keep the Rhythm going!
FAQs
A JS module and Sass mixin for Typographic Rhythm
We found that typorhythm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.