stratum 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,6 +1,6 @@
1
1
  *gem
2
2
  *swp
3
3
  .sass-cache
4
- demo/css
4
+ demo/_site/
5
5
  vendor/
6
6
  stratum/
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ Stratum
2
+ =======
3
+
4
+ Stratum is a Sass toolkit for Web Developers. Its goal is to get you started on a project in seconds and do all the heavy lifting, while you concentrate on the fun stuff.
5
+
6
+ Stratum is installed from command line:
7
+
8
+ `gem install stratum`
9
+
10
+ Once you install gem you can install/update Stratum in directly in your project. Remember, Stratum is just a collection of Sass mixins and utilities. No external dependencies. Just drop it in your project and start using.
11
+
12
+ ---
13
+
14
+ Command line
15
+ ------------
16
+
17
+ The following commands are available:
18
+
19
+ ```
20
+ stratum help Show help on specific commands (e.g. stratum help install)
21
+
22
+ stratum install Install Stratum in `./stratum`
23
+ -p [--path=./] Installation path (current directory if omitted)
24
+ -f [--force] Force installation into existing directory
25
+
26
+ stratum update Update `./stratum` in the current directory
27
+
28
+ stratum remove Removed `./stratum` in the current directory
29
+
30
+ stratum version Show gem version
31
+ -v [--version]
32
+ ```
33
+
34
+ Sass components
35
+ ---------------
36
+
37
+ Stratum is written in SCSS version of Sass syntax. It consists of several main components and a number of utilities and helpers.
38
+
39
+ * **Layout** – grids, scaffolding responsiveness
40
+ * **Forms** - form elements
41
+ * **CSS3** - mixins for cross-browser support of CSS3 properties
42
+ * **Utils** - various utilities and helpers
43
+
44
+ ### Layout
45
+
46
+ Stratum features a powerful grid system which comes with semantic definitions and scaffolding. Grid is available in fluid and pixel variants and can be mixed on the same page.
47
+
48
+ #### The Grid
49
+
50
+ Stratum's grid system is quite unique in that it doesn't expect you to calculate and define all its parameters (grid size, number of columns, column width and gutter width). Instead, it asks for only two concrete values *grid size* and *column count*. The third value, *gutter width* is a desired number, meaning that the exact round value will be calculated to fit the columns and gutters right within the specified width.
51
+
52
+ For example, if you want to produce a standard **980px** grid with **12** columns:
53
+
54
+ | Parameters | Requirements | Pixel | Fluid
55
+ |-----------------|----------------|---------------|-------------
56
+ | gutter | 20px (desired) | 16px (actual) | 6.72691%
57
+ | column width | -- | 67px | 1.60642%
58
+
59
+ Formula: *(col-number * col-width) + ((col-number - 1) * gutter-width)*
60
+ Result: *(12 * 67) + (11 * 16) = 980*
61
+
62
+ Column and gutter widths are variable where grid width and column count are constant. Stratum adjusts the variables until they fit the requirement.
63
+
64
+ Let's try another one, **11** columns in **934px** container.
65
+
66
+ | Parameters | Requirements | Pixel | Fluid
67
+ |-----------------|----------------|---------------|-------------
68
+ | gutter | 13px (desired) | 12px (actual) | 7.82241%
69
+ | column width | -- | 74px | 1.2685%
@@ -1,22 +1,12 @@
1
- @charset "utf-8";
2
-
3
- // © 2012 Tyom Semonov <mail@tyom.net>
4
- // Inspired by Zurb's Foundation & Gridulator.
5
-
6
- // -----------------------------------------------------------------------------
7
- // Stratum settings
8
- // -----------------------------------------------------------------------------
9
- //
10
- // Grid
11
- //
12
- $grid-guides-color: #8aa8c0;
13
- // $grid-guides-opacity: .1;
14
- // $grid-guides-position: front;
15
- $grid-type: pixel;
16
- $grid-total-columns: 12;
17
- $grid-desired-gutter: 20px;
18
- // $grid-baseline: 30px;
19
- // -----------------------------------------------------------------------------
1
+ // Grid settings
2
+ $grid-guides-color: #8aa8c0 !default;
3
+ $grid-guides-opacity: .2 !default;
4
+ $grid-guides-position: front !default;
5
+ $grid-type: fluid !default;
6
+ $grid-size: 980px !default;
7
+ $grid-total-columns: 12 !default;
8
+ $grid-desired-gutter: 20px !default;
9
+ $grid-baseline: 18px !default;
20
10
 
21
11
  @import "utils/vendor-prefix";
22
12
  @import "utils/group";
@@ -38,14 +38,35 @@
38
38
 
39
39
  // # Calculate the total width of number of columns including gutters
40
40
  // `$column-width` & `$gutter` are optional (use grid defaults)
41
- @function grid-columns-width($column-span, $column-width: auto, $gutter: auto) {
41
+ @function grid-columns-width($column-span, $column-width: auto, $gutter: auto, $type: $grid-type, $has-row: true) {
42
42
  @if $column-width == auto {
43
43
  $column-width: grid-column-width();
44
44
  }
45
45
  @if $gutter == auto {
46
46
  $gutter: grid-column-gutter($grid-size, $grid-desired-gutter);
47
+ } @else if $gutter == 0 {
48
+ // Adjust gutter width to exclude two half gutters on each side of grid container
49
+ // TODO simplify this bit and make it more obvious what's going on here (why pixel and fluid affect gutterless column behaviour)
50
+ // 1 is required to remove 1 gutter width from total width due to "rowed" columns adding extra gutter width
51
+ // FIXME This modifiers logic should be reviewed soon. Need to extract the ratios somewhere globally and apply them
52
+ // where they are needed (e.g. grid guides)
53
+ // It only affects m-pixel/m-fluid container modifiers of "rowless" grids
54
+ // e.g. .m-gutterless.m-pixel (on global fluid grid)
55
+ $v-mod: if($grid-type == pixel, 0, 1);
56
+ @if $has-row {
57
+ $v-mod: if($grid-type == pixel, 1, 0);
58
+ }
59
+ $v-gutter-width-adjusted: ($grid-gutter * ($grid-total-columns - $v-mod)) / $grid-total-columns;
60
+ $column-width: $column-width + $v-gutter-width-adjusted;
47
61
  }
48
- @return ceil($column-span * $column-width + ($column-span - 1) * $gutter);
62
+
63
+ $column-width: ceil($column-span * $column-width + ($column-span - 1) * $gutter);
64
+
65
+ @if $type == fluid {
66
+ $column-width: grid-percentage($column-width);
67
+ }
68
+
69
+ @return $column-width;
49
70
  }
50
71
 
51
72
  // # Convert percentage of width relative to the total width
@@ -18,7 +18,8 @@
18
18
  // Calculate gutter to column ratio
19
19
  $v-gutter-ratio: $v-column-gutter / ($v-column-width + $v-column-gutter);
20
20
  // Calculate column to grid width ratio
21
- $v-column-ratio: ($v-column-width + $v-column-gutter) / $grid-size;
21
+ // not entirely sure where $v-column-gutter/3 magic number comes from, but it's necessary to make it work
22
+ $v-column-ratio: ($v-column-width + $v-column-gutter) / ($grid-size - $v-column-gutter / 3);
22
23
 
23
24
  // Reset column size with percentages
24
25
  $v-column-gutter: percentage($v-gutter-ratio);
@@ -63,22 +64,30 @@
63
64
  $v-column-gutter $grid-baseline + 1, // v-rhythm
64
65
  $v-column-relative-width 10px, // column
65
66
  $v-column-gutter ($v-block-height + 1); // block
67
+ }
68
+ }
69
+
70
+ // Show grid guides on all grid containers
71
+ @mixin GRID-GUIDES($position: back) {
72
+ %l-container {
73
+ @include show-grid-guides($position);
74
+ }
75
+ }
76
+
77
+ // Show grid guide on element
78
+ @mixin show-grid-guides($position: back) {
79
+ @include grid-render-guides($grid-size);
66
80
 
81
+ &::before {
67
82
  // Grid placement (back by default)
68
- @if $grid-guides-position == front {
83
+ @if $position == front {
69
84
  z-index: 999;
70
85
  } @else {
71
86
  z-index: -1;
72
87
  }
73
88
  }
74
- }
75
89
 
76
- // Currently only global for all grids
77
- @mixin GRID-GUIDES {
78
- %l-container > %l-row {
79
- @include grid-render-guides($grid-size);
80
- &::before {
81
- margin: 0 $grid-half-gutter;
82
- }
90
+ %l-container::before {
91
+ content: none;
83
92
  }
84
93
  }
@@ -39,12 +39,14 @@ $grid-column: grid-column-width();
39
39
  // $modifier: 1 - normal (column) margins
40
40
  // $modifier: -1 - negative (row) margins
41
41
  @mixin grid-column-margins($type: $grid-type, $modifier: 1) {
42
- $v-gutter: auto;
42
+ $v-gutter: 0;
43
43
 
44
- @if($type == fluid) {
44
+ @if $type == fluid {
45
45
  $v-gutter: grid-percentage($grid-half-gutter * $modifier);
46
- } @else if ($type == pixel) {
46
+ } @else if $type == pixel {
47
47
  $v-gutter: $grid-half-gutter * $modifier;
48
+ } @else if $type == center {
49
+ $v-gutter: auto;
48
50
  }
49
51
 
50
52
  margin-left: $v-gutter;
@@ -52,45 +54,26 @@ $grid-column: grid-column-width();
52
54
  }
53
55
 
54
56
  // Calculate single column width (in pixels) multipled by number of columns it spans (indluding gutters)
55
- @mixin grid-column-width($span: 1, $type: $grid-type, $gutter: $grid-gutter) {
56
- $v-col-width: auto;
57
-
58
- @if($type == pixel) {
59
- $v-col-width: grid-columns-width($span);
60
- } @else if($type == fluid) {
61
- $v-col-width: grid-percentage(grid-columns-width($span));
62
- } @else if($type == marginless) {
63
- $v-col-width: grid-percentage(grid-columns-width($span, $grid-column + $gutter, 0));
64
- }
65
-
66
- width: $v-col-width;
57
+ @mixin grid-column-width($span: 1, $type: $grid-type, $gutter: $grid-gutter, $has-row: true) {
58
+ width: grid-columns-width($span, $grid-column, $gutter, $type, $has-row);
67
59
  }
68
60
 
69
61
 
70
62
  // Calculate offset width based on number of columns it spans (including gutters)
71
63
  @mixin grid-offset-by-column($span: 1, $direction: left, $flow: positive, $grid-type: $grid-type) {
72
- $v-offset: 0px;
64
+ $v-offset: grid-columns-width($span, $type: $grid-type);
73
65
  $v-gutter: $grid-gutter;
74
66
 
75
- // Grid with rows (outer margins)
76
- @if $grid-type != marginless {
77
- $v-gutter: $v-gutter * 1.5; // half gutter from row offset
78
- }
79
-
80
- // Pixel grid
81
- @if $grid-type == pixel {
82
- $v-offset: grid-columns-width($span);
83
- }
84
67
  // Fluid grid
85
- @if $grid-type == fluid or $grid-type == marginless {
68
+ @if $grid-type == fluid {
86
69
  $v-gutter: grid-percentage($v-gutter);
87
- $v-offset: grid-percentage(grid-columns-width($span));
88
70
  }
89
71
 
90
72
  // Negative offset
91
73
  @if $flow == negative {
92
- $v-offset: -$v-offset + $v-gutter;
74
+ // @debug $v-offset, $v-gutter, $v-gutter / 2;
75
+ margin-#{$direction}: -$v-offset - ($v-gutter / 2);
76
+ } @else {
77
+ margin-#{$direction}: $v-offset + ($v-gutter * 1.5);
93
78
  }
94
-
95
- margin-#{$direction}: $v-offset + $v-gutter;
96
79
  }
@@ -12,14 +12,20 @@
12
12
  // They use global grid settings and can be overriden with:
13
13
  // %l-grid-pixel – Force pixel grid
14
14
  // %l-grid-fluid – Force fluid grid
15
- // %l-marginless – Collapse column margins (gutters)
15
+ // %l-gutterless – Collapse column margins (gutters)
16
16
  //
17
17
  // %l-row – Grid consists of a number of rows
18
18
  // They are required for correct column margins, but can be omitted,
19
- // in which case the grid with no `%l-row` becomes marginless
19
+ // in which case the grid with no `%l-row` becomes gutterless
20
20
  //
21
21
  // %l-col – Column, the unit of the grid
22
22
  // %l-col-<$i> – Column size (e.g. `%l-col-4` spans four single columns, including three gutters)
23
+ // %l-col-full – 100% width
24
+ // %l-col-half – 50% width
25
+ // %l-col-quarter – 25% width
26
+ // %l-col-eighth – 12.5% width
27
+ // %l-col-sixteenth – 6.25% width
28
+ // %l-col-center - Center column
23
29
  //
24
30
  // l-col-from-left-<$i> – Offset column by <column size> from left
25
31
  // l-col-to-left-<$i> – Offset column by <column size> to left (negative margin)
@@ -68,11 +74,13 @@
68
74
  @include grid-row(fluid);
69
75
  }
70
76
 
71
- // Defines row of marginless grid
72
- &%l-marginless > %l-row {
73
- margin: {
74
- left: 0;
75
- right: 0;
77
+ // Defines row of gutterless grid
78
+ %l-gutterless {
79
+ &, %l-row {
80
+ margin: {
81
+ left: 0;
82
+ right: 0;
83
+ }
76
84
  }
77
85
  }
78
86
  }
@@ -81,8 +89,12 @@
81
89
  // Defines columns
82
90
  %l-col {
83
91
  @include grid-column;
84
- }
85
92
 
93
+ %l-gutterless & {
94
+ margin-left: 0;
95
+ margin-right: 0;
96
+ }
97
+ }
86
98
 
87
99
  // Float last column to right if `%l-last-col-right` extended
88
100
  // Applied to `%l-container`
@@ -94,38 +106,73 @@
94
106
  }
95
107
 
96
108
 
97
- // Defines column sizes
109
+ // Column spans
98
110
  @for $i from 1 through $grid-total-columns {
99
-
100
- // ## Spans
101
-
102
111
  %l-col-#{$i} {
103
- %l-row & {
104
- @include grid-column-width($i, $grid-type);
105
-
106
- %l-marginless > & {
107
- @include grid-column-width($i, marginless);
108
- @include grid-column-margins(fluid, 0);
109
- }
110
- }
111
-
112
- // Marginless (container without row)
113
- %l-container > & {
114
- @include grid-column-width($i, marginless);
115
- }
112
+ @include grid-column-width($i, $grid-type);
116
113
 
117
114
  // Force pixel grid
118
- %l-grid-pixel > %l-row > & {
115
+ %l-grid-pixel & {
119
116
  @include grid-column-width($i, pixel);
120
117
  @include grid-column-margins(pixel);
121
118
  }
122
119
  // Force fluid grid
123
- %l-grid-fluid > %l-row > &,
124
- // Always set nested grid to fluid
125
- %l-container %l-container > %l-row > & {
120
+ %l-grid-fluid & {
126
121
  @include grid-column-width($i, fluid);
127
122
  @include grid-column-margins(fluid);
128
123
  }
124
+
125
+ // Force gutterless grid
126
+ %l-gutterless &,
127
+ // Apply gutterless grid on columns without rows
128
+ %l-container > & {
129
+ @include grid-column-width($i, $grid-type, 0);
130
+ @include grid-column-margins(0);
131
+ }
132
+
133
+ // Force gutterless when row is absent
134
+ %l-grid-pixel > & {
135
+ @include grid-column-width($i, pixel, 0, false);
136
+ @include grid-column-margins(0);
137
+ }
138
+ %l-grid-fluid > & {
139
+ @include grid-column-width($i, fluid, 0, false);
140
+ @include grid-column-margins(0);
141
+ }
142
+ }
143
+ }
144
+
145
+
146
+ // Fluid grid subdivisions
147
+ %l-col-full {
148
+ width: 100%;
149
+ }
150
+ %l-col-half {
151
+ width: 50%;
152
+ }
153
+ %l-col-third {
154
+ width: 33.33333%;
155
+ }
156
+ %l-col-quarter {
157
+ width: 25%;
158
+ }
159
+ %l-col-eighth {
160
+ width: 12.5%;
161
+ }
162
+ %l-col-sixteenth {
163
+ width: 6.25%;
164
+ }
165
+
166
+
167
+ // Centre column
168
+ %l-col-center {
169
+ %l-container &,
170
+ %l-grid-pixel &,
171
+ %l-grid-fluid &,
172
+ %l-gutterless & {
173
+ float: none;
174
+ margin-left: auto;
175
+ margin-right: auto;
129
176
  }
130
177
  }
131
178
 
@@ -138,7 +185,7 @@
138
185
 
139
186
 
140
187
  // TODO Improve
141
- // Defines column offsets
188
+ // Column offsets
142
189
  %l-container {
143
190
  @for $i from 1 through $grid-total-columns {
144
191
 
@@ -212,27 +259,26 @@
212
259
  }
213
260
  }
214
261
 
215
- // ## Marginless grid
216
- & > %l-col,
217
- &%l-marginless %l-col {
262
+ // ## gutterless grid
263
+ %l-gutterless %l-col {
218
264
  // From left
219
265
  &%l-col-from-left-#{$i} {
220
- @include grid-offset-by-column($i, left, positive, marginless);
266
+ @include grid-offset-by-column($i, left, positive, gutterless);
221
267
  }
222
268
 
223
269
  // To left
224
270
  &%l-col-to-left-#{$i} {
225
- @include grid-offset-by-column($i, left, negative, marginless);
271
+ @include grid-offset-by-column($i, left, negative, gutterless);
226
272
  }
227
273
 
228
274
  // From right
229
275
  &%l-col-from-right-#{$i} {
230
- @include grid-offset-by-column($i, right, positive, marginless);
276
+ @include grid-offset-by-column($i, right, positive, gutterless);
231
277
  }
232
278
 
233
279
  // To right
234
280
  &%l-col-to-right-#{$i} {
235
- @include grid-offset-by-column($i, right, negative, marginless);
281
+ @include grid-offset-by-column($i, right, negative, gutterless);
236
282
  }
237
283
  }
238
284
  }
@@ -1,7 +1,7 @@
1
1
  // Grid defaults settings
2
2
  // ----------------------
3
3
 
4
- // Set these settings in `stratum.scss`
4
+ // Set these settings in `stratum.scss` unless imported directly as `layout/grid`
5
5
 
6
6
  $grid-responsive: false !default;
7
7
 
@@ -1,33 +1,44 @@
1
- // # Scaffolding stylesheet
1
+ // Scaffolding stylesheet
2
+ // ============================================================================
2
3
  // Exports `l-` prefixed classes useful for prototyping layouts
3
4
 
5
+
4
6
  // Grid container & rows
5
7
  .l-container {
6
8
  @extend %l-container;
7
9
  @extend %l-last-col-right;
8
10
 
9
- > .l-row {
11
+ .l-row {
10
12
  @extend %l-row;
11
13
  }
14
+ .l-col {
15
+ @extend %l-col;
16
+ }
12
17
 
18
+ // # Modifiers
19
+
20
+ // Grid types
21
+ .l-row.m-gutterless {
22
+ @extend %l-gutterless;
23
+ }
13
24
  &.m-pixel {
14
25
  @extend %l-grid-pixel;
15
26
  }
16
-
17
27
  &.m-fluid {
18
28
  @extend %l-grid-fluid;
19
29
  }
20
30
 
21
- .l-col {
22
- @extend %l-col;
23
- }
31
+ // Grid guides
32
+ &.m-show-guides {
33
+ @include show-grid-guides;
24
34
 
25
- &.m-marginless {
26
- @extend %l-marginless;
35
+ &.m-front {
36
+ @include show-grid-guides(front);
37
+ }
27
38
  }
28
39
  }
29
40
 
30
- // Grid columns
41
+ // Span-based column modifiers
31
42
  @for $i from 1 through $grid-total-columns {
32
43
  .l-col {
33
44
  &.m-#{$i} {
@@ -49,3 +60,17 @@
49
60
  }
50
61
  }
51
62
  }
63
+
64
+ // Generic column modifiers
65
+ .l-col {
66
+ // Centre column
67
+ &.m-centered {
68
+ @extend %l-col-center;
69
+ }
70
+ // Grid column subdivisions
71
+ @each $word in full, half, quarter, eighth, sixteenth {
72
+ &.m-#{$word} {
73
+ @extend %l-col-#{$word};
74
+ }
75
+ }
76
+ }
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stratum
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/stratum.gemspec CHANGED
@@ -16,6 +16,5 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_dependency('sass', '>= 3.2.0')
20
19
  s.add_dependency('thor')
21
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stratum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-26 00:00:00.000000000 Z
12
+ date: 2013-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: sass
16
- requirement: &70244371334840 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 3.2.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70244371334840
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: thor
27
- requirement: &70244371334180 !ruby/object:Gem::Requirement
16
+ requirement: &70124016369060 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ! '>='
@@ -32,7 +21,7 @@ dependencies:
32
21
  version: '0'
33
22
  type: :runtime
34
23
  prerelease: false
35
- version_requirements: *70244371334180
24
+ version_requirements: *70124016369060
36
25
  description: Stratum is a collection of SASS mixins and utilities for your web development
37
26
  needs.
38
27
  email: tyom@semonov.com
@@ -44,6 +33,7 @@ files:
44
33
  - .gitignore
45
34
  - .gitmodules
46
35
  - LICENSE
36
+ - README.md
47
37
  - assets/stylesheets/_stratum.scss
48
38
  - assets/stylesheets/css3/_box-sizing.scss
49
39
  - assets/stylesheets/forms/_input-placeholder.scss