Skip to content

Clamping typography for your responsive needs using a combination of JavaScript(ES6) and CSS variables. 2 KB of pure fuel. Supports CommonJS-like environments and AMD module loaders.

Notifications You must be signed in to change notification settings

typeplate/typelock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

TypeLock.js

View Demo

Clamping typography for your responsive needs using a combination of JavaScript(ES6) and CSS variables. 2 KB of pure fuel. Supports CommonJS-like environments and AMD module loaders.

Example

:root {
	--foo-bar: number;
	--bar-foo: number;
}

.element {
	font-size: calc(var(--foo-bar) * factor);
	line-height: calc(var(--bar-foo) * factor);
}

"factor" can be whatever you want to use as a numerical value within your math logic.

<script src="path/to/directory/typelock.js"></script>
<script>
addTypeLock({
	cssvar: '--foo-bar',
	min: number,
	max: number,
	factor: number
});

addTypeLock({
	cssvar: '--bar-foo',
	min: number,
	max: number,
	factor: number
});
</script>

addTypeLock({}) can be called as many times as you need it, but be mindful that you're manipulating CSS with JS so your performance will vary.

©2017 Typeplate. Licensed under MIT. Special thanks to Tommy Hodgins, Chris Wallis and Mathew Chase.

About

Clamping typography for your responsive needs using a combination of JavaScript(ES6) and CSS variables. 2 KB of pure fuel. Supports CommonJS-like environments and AMD module loaders.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published