Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCSS calculation fixes #63

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 18 additions & 13 deletions stylesheets/scss/grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ $columns: 12;
// Set $total-width to 100% for a fluid layout
$total-width: gridsystem-width($columns);

// Convenience function for calculating the $total-width / $calculated-width.
@function gridsystem-ratio() {
@return $total-width / gridsystem-width($columns);
}

// Uncomment these two lines and the star-hack width/margin lines below to enable sub-pixel fix for IE6 & 7. See http://tylertate.com/blog/2012/01/05/subpixel-rounding.html
// $min-width: 999999;
// $correction: 0.5 / $min-width * 100;
Expand Down Expand Up @@ -43,25 +48,25 @@ body {
@include clearfix();
}

@mixin row($columns:$columns) {
@mixin row($c:$columns) {
display: block;
width: $total-width*(($gutter-width + gridsystem-width($columns))/gridsystem-width($columns));
margin: 0 $total-width*((($gutter-width*.5)/gridsystem-width($columns))*-1);
// *width: $total-width*(($gutter-width + gridsystem-width($columns))/gridsystem-width($columns))-$correction;
// *margin: 0 $total-width*((($gutter-width*.5)/gridsystem-width($columns))*-1)-$correction;
width: (gridsystem-width($c) * gridsystem-ratio());
margin: 0 (-.5 * $gutter-width * gridsystem-ratio());
// *width: (gridsystem-width($c) * gridsystem-ratio())-$correction;
// *margin: 0 (-.5 * $gutter-width * gridsystem-ratio())-$correction;
@include clearfix();
}
@mixin column($x,$columns:$columns) {
@mixin column($x) {
display: inline;
float: left;
width: $total-width*(((($gutter-width+$column-width)*$x)-$gutter-width) / gridsystem-width($columns));
margin: 0 $total-width*(($gutter-width*.5)/gridsystem-width($columns));
// *width: $total-width*(((($gutter-width+$column-width)*$x)-$gutter-width) / gridsystem-width($columns))-$correction;
// *margin: 0 $total-width*(($gutter-width*.5)/gridsystem-width($columns))-$correction;
width: ((gridsystem-width($x)-$gutter-width) * gridsystem-ratio());
margin: 0 (.5 * $gutter-width * gridsystem-ratio());
// *width: ((gridsystem-width($x)-$gutter-width) * gridsystem-ratio())-$correction;
// *margin: 0 (.5 * $gutter-width * gridsystem-ratio())-$correction;
}
@mixin push($offset:1) {
margin-left: $total-width*((($gutter-width+$column-width)*$offset) / gridsystem-width($columns)) + $total-width*(($gutter-width*.5)/gridsystem-width($columns));
margin-left: ((gridsystem-width($offset) - $gutter-width + ($gutter-width*.5)) * gridsystem-ratio());
}
@mixin pull($offset:1) {
margin-right: $total-width*((($gutter-width+$column-width)*$offset) / gridsystem-width($columns)) + $total-width*(($gutter-width*.5)/gridsystem-width($columns));
}
margin-right: ((gridsystem-width($offset) - $gutter-width + ($gutter-width*.5)) * gridsystem-ratio());
}
52 changes: 52 additions & 0 deletions test/scss/SpecRunner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>

<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.2.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.2.0/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jquery.min.js"></script>

<!-- include source files here... -->
<link rel="stylesheet" type="text/css" href="css/grid.css">

<!-- include spec files here... -->
<script type="text/javascript" src="spec/GridSpec.js"></script>

<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;

var htmlReporter = new jasmine.HtmlReporter();

jasmineEnv.addReporter(htmlReporter);

jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};

var currentWindowOnload = window.onload;

window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};

function execJasmine() {
jasmineEnv.execute();
}

})();
</script>

</head>

<body>
</body>
</html>
Loading