singularitygs 0.1.alpha → 1.0.alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/singularitygs.rb +2 -2
- data/stylesheets/_singularitygs.scss +68 -0
- data/stylesheets/singularitygs/_background-grid.scss +49 -0
- data/stylesheets/singularitygs/_column.scss +51 -0
- data/stylesheets/singularitygs/_grid-plugins.scss +3 -0
- data/stylesheets/singularitygs/{_grid-test.sass → _grid-test.scss} +22 -13
- data/stylesheets/singularitygs/_grid.scss +6 -0
- data/stylesheets/singularitygs/_gutter.scss +45 -0
- data/stylesheets/singularitygs/_helpers.scss +3 -0
- data/stylesheets/singularitygs/_mixins.scss +7 -0
- data/stylesheets/singularitygs/grid-plugins/_compound.scss +49 -0
- data/stylesheets/singularitygs/grid-plugins/_ratio-spiral.scss +42 -0
- data/stylesheets/singularitygs/grid-plugins/_ratio.scss +4 -0
- data/stylesheets/singularitygs/grid-structure/_display-table.scss +1 -0
- data/stylesheets/singularitygs/grid-structure/_flexbox.scss +0 -0
- data/stylesheets/singularitygs/grid-structure/_float.scss +94 -0
- data/stylesheets/singularitygs/grid-structure/_grid-layout.scss +1 -0
- data/stylesheets/singularitygs/grid-structure/_isolation.scss +145 -0
- data/stylesheets/singularitygs/helpers/_grids.scss +34 -0
- data/stylesheets/singularitygs/helpers/_gridsets.scss +362 -0
- data/stylesheets/singularitygs/helpers/_lists.scss +29 -0
- data/stylesheets/singularitygs/mixins/_base-font-size.scss +63 -0
- data/stylesheets/singularitygs/mixins/_container.scss +63 -0
- data/stylesheets/singularitygs/mixins/_grid-build.scss +16 -0
- data/stylesheets/singularitygs/mixins/_grid-objects.scss +26 -0
- data/stylesheets/singularitygs/mixins/_grid-padding.scss +8 -0
- data/stylesheets/singularitygs/mixins/_grid-span.scss +9 -0
- data/stylesheets/singularitygs/mixins/_push-pull.scss +41 -0
- data/templates/project/behaviors/box-sizing/boxsizing.htc +399 -0
- data/templates/project/behaviors/box-sizing/boxsizing.php +23 -0
- data/templates/project/manifest.rb +4 -0
- metadata +39 -22
- data/stylesheets/singularitygs.sass +0 -40
- data/stylesheets/singularitygs/_background-grid.sass +0 -19
- data/stylesheets/singularitygs/_column.sass +0 -25
- data/stylesheets/singularitygs/_grid-plugins.sass +0 -2
- data/stylesheets/singularitygs/_grid.sass +0 -2
- data/stylesheets/singularitygs/_gridsets.scss +0 -242
- data/stylesheets/singularitygs/_gutter.sass +0 -4
- data/stylesheets/singularitygs/_helpers.sass +0 -37
- data/stylesheets/singularitygs/_mixins.sass +0 -75
- data/stylesheets/singularitygs/grid-plugins/_compound.sass +0 -30
data/lib/singularitygs.rb
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
/*! SINGULARITY -- http://singularity.gs/ */
|
2
|
+
@import "compass";
|
3
|
+
@import "modular-scale";
|
4
|
+
@import "breakpoint";
|
5
|
+
|
6
|
+
// Singularity debug output
|
7
|
+
$singularity-debug: false !default;
|
8
|
+
|
9
|
+
// Can be a number or a list of non-uniform column widths
|
10
|
+
$columns: 12 !default;
|
11
|
+
|
12
|
+
// Must be of the same unit type of defined columns
|
13
|
+
$gutter: .25 !default;
|
14
|
+
|
15
|
+
// Grid padding can be any type of unit
|
16
|
+
$padding: 0 !default;
|
17
|
+
|
18
|
+
// Layout direction?
|
19
|
+
// options are ltr, rtl, both
|
20
|
+
$dir: ltr !default;
|
21
|
+
|
22
|
+
// Choose a selector for rtl layouts when using 'both'
|
23
|
+
$rtl-selector: '[dir="rtl"]' !default;
|
24
|
+
|
25
|
+
// Options for Multiple Grids
|
26
|
+
$grids: () !default;
|
27
|
+
$gutters: () !default;
|
28
|
+
$paddings: () !default;
|
29
|
+
|
30
|
+
$grids-mobile-first: true !default;
|
31
|
+
|
32
|
+
// Container Nonsense
|
33
|
+
$container: 100% !default;
|
34
|
+
$containers: () !default;
|
35
|
+
$container-to-ems: false !default;
|
36
|
+
|
37
|
+
// Base Font Size
|
38
|
+
$base-font-size: 1em !default;
|
39
|
+
|
40
|
+
// Structural templates for grid
|
41
|
+
$grouped-styles: false !default;
|
42
|
+
$output: 'isolation' !default;
|
43
|
+
@import "singularitygs/grid-structure/isolation";
|
44
|
+
@import "singularitygs/grid-structure/float";
|
45
|
+
|
46
|
+
// Helpers return think like list sums and column counts
|
47
|
+
@import "singularitygs/helpers";
|
48
|
+
|
49
|
+
// Compound grid calculation function
|
50
|
+
@import "singularitygs/grid-plugins";
|
51
|
+
|
52
|
+
// Column math is isolated
|
53
|
+
@import "singularitygs/column";
|
54
|
+
|
55
|
+
// Gutter math is isolated
|
56
|
+
@import "singularitygs/gutter";
|
57
|
+
|
58
|
+
// Grid math combines column and gutter math
|
59
|
+
@import "singularitygs/grid";
|
60
|
+
|
61
|
+
// Mixins to write
|
62
|
+
@import "singularitygs/mixins";
|
63
|
+
|
64
|
+
// Mixins to write
|
65
|
+
@import "singularitygs/grid-test";
|
66
|
+
|
67
|
+
// Mixins to write
|
68
|
+
@import "singularitygs/background-grid";
|
@@ -0,0 +1,49 @@
|
|
1
|
+
// Write stops for single columns
|
2
|
+
@function grid-gradient-stop($location, $columns, $gutter, $color) {
|
3
|
+
@if $location == 1 {
|
4
|
+
@return $color 0%, $color column-span(1, 1, $columns), transparentize($color, 1) column-span(1, 1, $columns);
|
5
|
+
}
|
6
|
+
@if $location == column-count($columns) {
|
7
|
+
@return transparentize($color, 1) column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), $color column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), $color 100%;
|
8
|
+
}
|
9
|
+
@if $location > 1 {
|
10
|
+
@return transparentize($color, 1) column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), $color column-span($location - 1, 1, $columns) + gutter-span($gutter, $columns), $color column-span($location, 1, $columns), transparentize($color, 1) column-span($location, 1, $columns);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
// Compiling grid stops
|
15
|
+
@function grid-gradient-stops($columns, $gutter, $color) {
|
16
|
+
$list: ();
|
17
|
+
@for $i from 1 through column-count($columns) {
|
18
|
+
$list: join($list, grid-gradient-stop($i, $columns, $gutter, $color), comma);
|
19
|
+
}
|
20
|
+
@return $list;
|
21
|
+
}
|
22
|
+
|
23
|
+
// Pull in grid stops to make a background gradient
|
24
|
+
@mixin background-grid($columns: false, $gutter: false, $color: rgba(#69aedb, 0.5)) {
|
25
|
+
$gl: length($grids);
|
26
|
+
|
27
|
+
@if $gl == 0 {
|
28
|
+
$columns: find-grid($columns);
|
29
|
+
$gutter: find-gutter($gutter);
|
30
|
+
@include background(linear-gradient(left, grid-gradient-stops($columns, $gutter, $color)));
|
31
|
+
}
|
32
|
+
@else {
|
33
|
+
@for $i from 1 through $gl {
|
34
|
+
@if $i == 1 {
|
35
|
+
$grid: nth($grids, 1);
|
36
|
+
$gutter: find-gutter($gutter);
|
37
|
+
@include background(linear-gradient(left, grid-gradient-stops($grid, $gutter, $color)));
|
38
|
+
}
|
39
|
+
@else {
|
40
|
+
$grid: nth(nth($grids, $i), 1);
|
41
|
+
$mq: nth(nth($grids, $i), 2);
|
42
|
+
@include breakpoint($mq) {
|
43
|
+
$gutter: find-gutter($gutter);
|
44
|
+
@include background(linear-gradient(left, grid-gradient-stops($grid, $gutter, $color)));
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// Calculate the width spanning multiple columns
|
2
|
+
@function column-span($span, $location: 1, $columns: $columns, $gutter: $gutter) {
|
3
|
+
// if the gutter is a percent, convert it to a ratio
|
4
|
+
|
5
|
+
@if unit($gutter) == '%' {
|
6
|
+
$gutter: percentage-gutter-conversion($gutter, $columns);
|
7
|
+
}
|
8
|
+
|
9
|
+
// gutters are a type of column
|
10
|
+
$columns-and-gutters: column-sum($columns, $gutter);
|
11
|
+
|
12
|
+
// Equal width columns
|
13
|
+
@if type-of($columns) == number {
|
14
|
+
$span-and-gutter: $span + (($span - 1) * $gutter);
|
15
|
+
@return $span-and-gutter / $columns-and-gutters * 100%;
|
16
|
+
}
|
17
|
+
// Variable width columns
|
18
|
+
@if type-of($columns) == list {
|
19
|
+
// zero out initial sum
|
20
|
+
$sum: 0;
|
21
|
+
$holder: ();
|
22
|
+
// from start point to end point
|
23
|
+
@for $i from $location to $location + $span {
|
24
|
+
$holder: append($holder, nth(nth($columns, $i), 1), comma);
|
25
|
+
}
|
26
|
+
|
27
|
+
@return column-sum($holder, $gutter) / $columns-and-gutters * 100%;
|
28
|
+
}
|
29
|
+
|
30
|
+
@return 10%;
|
31
|
+
}
|
32
|
+
|
33
|
+
@function column-sum($columns: $columns, $gutter: $gutter) {
|
34
|
+
|
35
|
+
// if the gutter is a percent, convert it to a ratio
|
36
|
+
@if unit($gutter) == percentage {
|
37
|
+
$gutter: percentage-gutter-conversion($gutter, $columns);
|
38
|
+
}
|
39
|
+
|
40
|
+
@if type-of($columns) == 'number' {
|
41
|
+
@return $columns + ((column-count($columns) - 1) * $gutter);
|
42
|
+
}
|
43
|
+
@else if type-of($columns) == 'list' {
|
44
|
+
$sum: 0;
|
45
|
+
@each $column in $columns {
|
46
|
+
$sum: $sum + nth($column, 1);
|
47
|
+
}
|
48
|
+
$sum: $sum + (column-count($columns) - 1) * $gutter;
|
49
|
+
@return $sum;
|
50
|
+
}
|
51
|
+
}
|
@@ -1,16 +1,25 @@
|
|
1
|
-
|
2
|
-
.test-grid
|
3
|
-
height: 200px
|
4
|
-
width: 100
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
@mixin test-grid($columns: $columns, $gutter: $gutter, $padding: $padding, $prefix: a, $color: #66bbbb) {
|
2
|
+
.test-grid {
|
3
|
+
height: 200px;
|
4
|
+
width: 100%;
|
5
|
+
}
|
6
|
+
$grid-counter: 1;
|
7
|
+
@for $i from 1 through column-count($columns) {
|
8
|
+
.test.#{$prefix}#{$i} {
|
9
|
+
height: 100%;
|
10
|
+
@include grid-span(1, $i, $columns, $gutter, $padding);
|
11
|
+
// ie fallback
|
12
|
+
background-color: $color;
|
13
|
+
background-color: transparentize($color, 0.5);
|
14
|
+
.inner {
|
15
|
+
height: 100%;
|
16
|
+
// ie fallback
|
17
|
+
background-color: lighten($color, 10%);
|
18
|
+
background-color: transparentize($color, 0.5);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
14
23
|
|
15
24
|
// Need this markup to test
|
16
25
|
//<div class="test-grid">
|
@@ -0,0 +1,45 @@
|
|
1
|
+
// percentage conversion
|
2
|
+
@function percentage-gutter-conversion($percent-gutter, $columns) {
|
3
|
+
|
4
|
+
// find the resolution of the grids
|
5
|
+
$resolution: 0;
|
6
|
+
@if length($columns) == 1 {
|
7
|
+
$resolution: $columns;
|
8
|
+
}
|
9
|
+
@else {
|
10
|
+
@each $column in $columns {
|
11
|
+
$resolution: $resolution + $column;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
// divide the percentage gutter by 100% to get the offset
|
16
|
+
// then multiply be resolution for the full conversion
|
17
|
+
$new-gutter: ($percent-gutter / 100%) * $resolution;
|
18
|
+
|
19
|
+
@return $new-gutter;
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
// Gutters to be removed from columns
|
24
|
+
@function gutter-offset($gutter, $columns) {
|
25
|
+
|
26
|
+
// if the gutter is a percent, convert it to a ratio
|
27
|
+
@if unit($gutter) == percentage {
|
28
|
+
$gutter: percentage-gutter-conversion($gutter, $columns);
|
29
|
+
}
|
30
|
+
|
31
|
+
$gutter-sum: $gutter * (column-count($columns) - 1);
|
32
|
+
@return $gutter-sum / column-count($columns);
|
33
|
+
}
|
34
|
+
|
35
|
+
@function gutter-span($gutter, $columns) {
|
36
|
+
|
37
|
+
// if the gutter is a percent, convert it to a ratio
|
38
|
+
@if unit($gutter) == percentage {
|
39
|
+
$gutter: percentage-gutter-conversion($gutter, $columns);
|
40
|
+
}
|
41
|
+
|
42
|
+
$columns-and-gutters: column-sum($columns, $gutter);
|
43
|
+
|
44
|
+
@return $gutter / $columns-and-gutters * 100%;
|
45
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
// 16 arguments can be passed into this function
|
2
|
+
// a max of 16 comma seperated grids
|
3
|
+
@function compound($cg1: 1, $cg2: 1, $cg3: 1, $cg4: 1, $cg5: 1, $cg6: 1, $cg7: 1, $cg8: 1, $cg9: 1, $cg10: 1, $cg11: 1, $cg12: 1, $cg13: 1, $cg14: 1, $cg15: 1, $cg16: 1) {
|
4
|
+
|
5
|
+
// merge arguments into a single list.
|
6
|
+
$compound-grids: $cg1, $cg2, $cg3, $cg4, $cg5, $cg6, $cg7, $cg8, $cg9, $cg10, $cg11, $cg12, $cg13, $cg14, $cg15, $cg16;
|
7
|
+
|
8
|
+
// Find the base resolution of grid
|
9
|
+
$resolution: 1;
|
10
|
+
@each $item in $compound-grids {
|
11
|
+
$resolution: $resolution * $item;
|
12
|
+
}
|
13
|
+
|
14
|
+
$compound-grid: ();
|
15
|
+
$compound-counter: 1;
|
16
|
+
// cycle through each step in grid resolution
|
17
|
+
@for $i from 1 through $resolution {
|
18
|
+
|
19
|
+
// dont add a column by default
|
20
|
+
$add-col: false;
|
21
|
+
|
22
|
+
// cycle through all grids to see if any grids match
|
23
|
+
@each $grid in $compound-grids {
|
24
|
+
|
25
|
+
// if the grid divides evenly into the resolution, add a column
|
26
|
+
// divide the resolution by number of columns to get the column resolution
|
27
|
+
@if $i / ($resolution / $grid) == round($i / ($resolution / $grid)) {
|
28
|
+
$add-col: true;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
// add the counter value to the compound grid list, reset counter
|
33
|
+
// this marks where one column ends and a new one begins
|
34
|
+
@if $add-col {
|
35
|
+
$compound-grid: join($compound-grid, $compound-counter, comma);
|
36
|
+
$compound-counter: 1;
|
37
|
+
}
|
38
|
+
// if no column is added, bump up counter
|
39
|
+
@else {
|
40
|
+
$compound-counter: $compound-counter + 1;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
@if $singularity-debug {
|
45
|
+
@debug "Grid compounded to #{length($compound-grid)} columns";
|
46
|
+
}
|
47
|
+
|
48
|
+
@return $compound-grid;
|
49
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// centralize spiral steps.
|
2
|
+
@function ratio-spiral-i($i) {
|
3
|
+
@return (($i * 2) + 1);
|
4
|
+
}
|
5
|
+
|
6
|
+
@function ratio-spiral($depth: 5, $ratio: golden(), $invert: false) {
|
7
|
+
|
8
|
+
// write the middle most column, a little out of step from the other columns.
|
9
|
+
$list: ms(ratio-spiral-i(-$depth) + 1, 100, $ratio);
|
10
|
+
|
11
|
+
// flip the direction the order columns are written in.
|
12
|
+
@if $invert == false {
|
13
|
+
@for $i from -($depth - 1) to 0 {
|
14
|
+
// if the number is even
|
15
|
+
@if $i/2 == round($i/2) {
|
16
|
+
// append after the list
|
17
|
+
$list: append($list, ms(ratio-spiral-i($i), 100, $ratio));
|
18
|
+
}
|
19
|
+
@else {
|
20
|
+
// append before the list
|
21
|
+
$list: append(ms(ratio-spiral-i($i), 100, $ratio), $list);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
@else {
|
27
|
+
@for $i from -($depth - 1) to 0 {
|
28
|
+
@if $i/2 == round($i/2) {
|
29
|
+
$list: append(ms(ratio-spiral-i($i), 100, $ratio), $list);
|
30
|
+
}
|
31
|
+
@else {
|
32
|
+
$list: append($list, ms(ratio-spiral-i($i), 100, $ratio));
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
@if $singularity-debug {
|
38
|
+
@debug "Grid compounded to #{length($list)} columns";
|
39
|
+
}
|
40
|
+
|
41
|
+
@return $list;
|
42
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
|
File without changes
|
@@ -0,0 +1,94 @@
|
|
1
|
+
@mixin float-clear($dir) {
|
2
|
+
@if $dir == 'left' {
|
3
|
+
clear: right;
|
4
|
+
}
|
5
|
+
@else if $dir == 'right' {
|
6
|
+
clear: left;
|
7
|
+
}
|
8
|
+
@else if $dir == 'both' {
|
9
|
+
clear: both;
|
10
|
+
}
|
11
|
+
|
12
|
+
@include clearfix;
|
13
|
+
}
|
14
|
+
|
15
|
+
@mixin float-common($columns: $columns, $gutter: $gutter, $padding: $padding, $grouped-styles: $grouped-styles) {
|
16
|
+
@include box-sizing(border-box);
|
17
|
+
*behavior: url("../behaviors/box-sizing/boxsizing.php");
|
18
|
+
overflow: hidden;
|
19
|
+
*zoom: 1;
|
20
|
+
|
21
|
+
@if $grouped-styles and $padding != 0 {
|
22
|
+
padding-left: $padding;
|
23
|
+
padding-right: $padding;
|
24
|
+
}
|
25
|
+
@if $grouped-styles == false and $padding != 0 {
|
26
|
+
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
@mixin float-section($span, $location: $grid-counter, $columns: $columns, $gutter: $gutter, $padding: $padding, $grouped-styles: $grouped-styles) {
|
33
|
+
width: grid-span($span, $location, $columns, $gutter);
|
34
|
+
// add special left padding
|
35
|
+
@include grid-location($span, $location, $columns);
|
36
|
+
|
37
|
+
@if $dir == ltr or $dir == both {
|
38
|
+
@if $grid-location == 'middle' or $grid-location == 'first'{
|
39
|
+
float: left;
|
40
|
+
margin-right: gutter-span($gutter, $columns);
|
41
|
+
}
|
42
|
+
@else if $grid-location == 'last' {
|
43
|
+
float: right;
|
44
|
+
}
|
45
|
+
@include float-clear('left');
|
46
|
+
}
|
47
|
+
@if $dir == rtl {
|
48
|
+
@if $grid-location == 'middle' or $grid-location == 'first' {
|
49
|
+
float: right;
|
50
|
+
margin-left: gutter-span($gutter, $columns);
|
51
|
+
}
|
52
|
+
@else if $grid-location == 'last' {
|
53
|
+
float: left;
|
54
|
+
}
|
55
|
+
@include float-clear('right');
|
56
|
+
}
|
57
|
+
@if $dir == both {
|
58
|
+
#{$rtl-selector} & {
|
59
|
+
@if $grid-location == 'middle' or $grid-location == 'first' {
|
60
|
+
float: right;
|
61
|
+
margin-left: gutter-span($gutter, $columns);
|
62
|
+
}
|
63
|
+
@else if $grid-location == 'last' {
|
64
|
+
float: left;
|
65
|
+
}
|
66
|
+
@include float-clear('right');
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
// Padding
|
71
|
+
@if type-of($columns) == list {
|
72
|
+
@if type-of(nth($columns, $location)) == list {
|
73
|
+
padding-left: nth(nth($columns, $location), 2);
|
74
|
+
}
|
75
|
+
@else if $padding != 0 {
|
76
|
+
padding-left: $padding;
|
77
|
+
}
|
78
|
+
// add special right padding
|
79
|
+
@if type-of(nth($columns, $location + $span - 1)) == list {
|
80
|
+
padding-right: nth(nth($columns, $location + $span - 1), 2);
|
81
|
+
}
|
82
|
+
@else if $padding != 0 {
|
83
|
+
padding-right: $padding;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
@mixin float-structure($span, $location, $columns, $gutter, $padding) {
|
89
|
+
// common components
|
90
|
+
@include float-common($columns, $gutter);
|
91
|
+
|
92
|
+
// specific styles
|
93
|
+
@include float-section($span, $location, $columns, $gutter);
|
94
|
+
}
|