Skip to content

Commit

Permalink
implement generalised sizing logic. Fixes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean King committed Aug 21, 2015
1 parent 0c20fc7 commit e3a9242
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ module.exports = postcss.plugin('postcss-responsive-type', function () {
var buildRules = function(rule) {
var rules = {};

// Build the responsive decleration
var sizeDiff = parseFloat(params.maxSize) - parseFloat(params.minSize),
widthDiff = parseFloat(params.maxWidth) - parseFloat(params.minWidth);

rules.responsive = 'calc(' + params.minSize + ' + ' + sizeDiff.toString() + ' * ((100vw - ' + params.minWidth + ') / ' + widthDiff.toString() + '))';
// Build the responsive type decleration
var sizeDiff = (parseFloat(params.maxSize) - parseFloat(params.minSize)) / (parseFloat(params.maxWidth) - parseFloat(params.minWidth));
rules.responsive = 'calc((' + params.minSize + ' - ' + params.minWidth + ' * ' + sizeDiff + ') + ' + sizeDiff * 100 + 'vw)';

// Build the media queries
rules.minMedia = postcss.atRule({
Expand Down

0 comments on commit e3a9242

Please sign in to comment.