All Projects → alexerlandsson → scss-font-lock

alexerlandsson / scss-font-lock

Licence: MIT License
This is a SCSS mixin used to create CSS locks for responsive typography. To make in convenient to use it allows you to use both px and em as units and if anything goes wrong, it will let you know during the compile using scss @warn and also print an error message on top of the text in the application or website.

Programming Languages

SCSS
7915 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to scss-font-lock

flexbox-grid-mixins
Sass Mixins to generate Flexbox grid
Stars: ✭ 67 (+272.22%)
Mutual labels:  mixin
apple-emoji-linux
Apple Color Emoji for Linux
Stars: ✭ 392 (+2077.78%)
Mutual labels:  font-size
vue-in-viewport-mixin
Vue 2 mixin to determine when a DOM element is visible in the client window
Stars: ✭ 99 (+450%)
Mutual labels:  mixin
mixomatic
Create mixins which work with instanceof (friendly for unit tests).
Stars: ✭ 21 (+16.67%)
Mutual labels:  mixin
ng2-fittext
An Angular2+ directive that autoscale the font size of an element until it fit the upper level container dimension.
Stars: ✭ 31 (+72.22%)
Mutual labels:  font-size
helm2-mixin
Helm mixin for Porter
Stars: ✭ 14 (-22.22%)
Mutual labels:  mixin
vue-mixin-tween
Vue mixin factory to tween component numerical data
Stars: ✭ 25 (+38.89%)
Mutual labels:  mixin
sloped-edge
Sass mixin that helps you build sloped section edges with a consistent angle.
Stars: ✭ 85 (+372.22%)
Mutual labels:  mixin
vertical-rhythm-reset
A Sass/SCSS library for responsive vertical rhythm grids, modular scale typography, and CSS normalization.
Stars: ✭ 65 (+261.11%)
Mutual labels:  mixin
ModernUI
Modern desktop framework from low-level 3D graphics API to high-level view model, for development of 2D/3D rendering software or game engine, with internationalization support and many new technologies.
Stars: ✭ 168 (+833.33%)
Mutual labels:  mixin
hacker-news-mixin-bot
Post new hot stories from Hacker News to Mixin bot (Mixin ID: 7000100124)
Stars: ✭ 19 (+5.56%)
Mutual labels:  mixin
bot-api-go-client
🤖️ Mixin API for Go
Stars: ✭ 65 (+261.11%)
Mutual labels:  mixin
python-pyfields
Define fields in python classes. Easily.
Stars: ✭ 39 (+116.67%)
Mutual labels:  mixin
pando
Pando is a decentralized financial network built with the MTG technology, and its underlying financial algorithm is inspired by Maker and Synthetix.
Stars: ✭ 12 (-33.33%)
Mutual labels:  mixin
accessibility-buttons
Buttons to add/remove contrast and increase/decrease font size.
Stars: ✭ 61 (+238.89%)
Mutual labels:  font-size
mixin-sdk-go
Golang sdk for Mixin Network & Mixin Messenger
Stars: ✭ 36 (+100%)
Mutual labels:  mixin
fancy-textfill
Fast implementation for resizing text to fill its container.
Stars: ✭ 17 (-5.56%)
Mutual labels:  font-size
ClientAPI
API designed to make Minecraft "Utility Mods" have Universal Support
Stars: ✭ 58 (+222.22%)
Mutual labels:  mixin
vue-component-style
A Vue mixin to add style section to components.
Stars: ✭ 16 (-11.11%)
Mutual labels:  mixin
mixin bot
A simple API wrapper for Mixin Network in Ruby
Stars: ✭ 12 (-33.33%)
Mutual labels:  mixin

SCSS Font Lock

This is a SCSS mixin used to create CSS locks for responsive typography. To make in convenient to use it allows you to use both px and em as units and if anything goes wrong, it will let you know during the compile using scss @warn.

Demo: https://alexerlandsson.github.io/scss-font-lock/demo/demo.html

What is a CSS lock?

A CSS lock is a technique used to smooth change the font size depending on viewport width between to breakpoints.

How to use?

Add the mixin in your SCSS file and use @include to include it to where you want it to be used.

@include scss-font-lock($min-size, $max-size, $min-width, $max-width);

Change the variables to desired values in either px or em. Please not that the output will be presented in px. The mixin contains a calculation of em to px with the default font-size of 16px. However, you can change that base value by include another variable in the mixin with the new value. Example:

@include scss-font-lock($min-size, $max-size, $min-width, $max-width, 14px);

Example

This example demonstrate a CSS lock where the font size will be 16px up to a vieport width of 375px and then scale up to 60px which locks at 1024px:

@include scss-font-lock(16px, 60px, 375px, 1024px);

Variables

Variable Description
$min-size Font minimum size. Will be displayed on viewport smaller than $min-width.
$max-size Font maximum size. Will be displayed on viewport larger than $max-width.
$min-width Breakpoint where the font reaches its minimal font size.
$max-width Breakpoint where the font reaches its maximum font size.
$base-font-size Optional. Base font size used to calculate values set in em. Default 16px if not passed into the mixin.

Error handling

This mixin is built to handle errors. If variables are set it non-compatible units, it will let you know when you compile into css using SCSS @warn. Another feature is that the mixin will ignore an output on error and instead display an error message on top of the text.

Browser Compatibility

Chrome Safari Firefox Opera IE
Yes
Yes
Yes
Yes
9+

License

The MIT License (MIT)

Copyright (c) 2016 Alexander Erlandsson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].