Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,33 @@ $('body').flowtype({
});
```

## FlowType Sass Mixin ##

FlowType is also available as a Sass Mixin. The mixin provides the FlowType functionality using only CSS.

To use the mixin, include the FlowType.scss file into your project and compile using your preferred Sass compiler. You may want to tweak the default settings found in the FlowType.scss file:

```scss
$fontRatio: 35;
$lineRatio: 1.45;
$maxFont: 36;
$minFont: 12;
$maximum: 1000;
$minimum: 1;
```

Then, simply `@include` the mixin into your project:

```scss
body {
@include flowtype($fontRatio, $lineRatio, $maxFont, $minFont, $maximum, $minimum);
}
```

The mixin will apply all necessary media queries to enable the FlowType functionality.

## Brought to you by... ##

This wonderful piece of magic has been brought to you by the team at [Simple Focus](http://simplefocus.com). Follow Simple Focus on Twitter: [@simplefocus](http://twitter.com/simplefocus).

FlowType.JS is licensed under the MIT License. See the LICENSE.txt file for copy permission.
FlowType.JS is licensed under the MIT License. See the LICENSE.txt file for copy permission.
50 changes: 50 additions & 0 deletions flowtype.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* FlowType Sass Mixin 1.1
*/

// Establish default settings/variables
// ====================================
$maximum: 1000;
$minimum: 1;
$maxFont: 36;
$minFont: 12;
$fontRatio: 35;

// Mixin start
// ===========
@mixin flowtype($maximum, $minimum, $maxFont, $minFont, $fontRatio) {
$fontSize: $maxFont;
$tempFontSize: $fontSize;

// Output media query for minimum size
// ===================================
@media screen and (max-width: #{$minimum}px) {
font-size: #{$minFont}px;
}

// Do the magic math
// =================
@for $i from $minimum through $maximum {
$fontBase: floor($i / $fontRatio);

@if $fontBase > $maxFont {
$fontSize: $maxFont;
}
@else if $fontBase < $minFont {
$fontSize: $minFont;
}
@else {
$fontSize: $fontBase;
}

// Output media queries
// ====================
@if $tempFontSize != $fontSize {
@media screen and (min-width: #{$i}px) {
font-size: #{$fontSize}px;
}
}

$tempFontSize: $fontSize;
}
}