ionica 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +2 -0
- data/app/assets/stylesheets/ionica.sass +255 -0
- data/lib/ionica/version.rb +4 -0
- data/lib/ionica.rb +6 -0
- metadata +70 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Tomislav Pesut & Anna Andresian
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
$DEFAULT_RESOLUTION: 768
|
2
|
+
|
3
|
+
@mixin grid-column-styles($transition_duration)
|
4
|
+
transition: transform, $transition_duration
|
5
|
+
position: absolute
|
6
|
+
height: 100%
|
7
|
+
z-index: 1
|
8
|
+
|
9
|
+
@function map-length($map)
|
10
|
+
@return length(map-keys($map))
|
11
|
+
|
12
|
+
@function percentage-column($size, $number_of_columns)
|
13
|
+
@return to-percent($size * (100 / $number_of_columns))
|
14
|
+
|
15
|
+
@function to-percent($number)
|
16
|
+
@return $number * 1%
|
17
|
+
|
18
|
+
@mixin column($grid, $key)
|
19
|
+
@include grid-column-styles(map-get($grid, transition_duration))
|
20
|
+
$c: map-get($grid, $key)
|
21
|
+
$padding: map-get($grid, padding)
|
22
|
+
@include grid-column-with-offset(map-get($c, weight), map-get($grid, total_grid_weight), map-get($c, offset), $key, map-get($grid, core_columns), map-get($grid, resolution), map-get($grid, orientation), $grid, $padding)
|
23
|
+
|
24
|
+
@mixin generate-column-classes($grid, $class_name)
|
25
|
+
$num_columns: map-get($grid, num_columns)
|
26
|
+
$grid: map-merge($grid, (class_name: $class_name))
|
27
|
+
@for $i from 1 through $num_columns
|
28
|
+
.#{$class_name}-#{$i}
|
29
|
+
@include column($grid, $i)
|
30
|
+
|
31
|
+
@function grid($list, $breakpoints: 767, $padding: 0, $transition_duration: 500ms, $class_name: "amplify-ionica-grid-default-classname")
|
32
|
+
$breakpoints: parse-breakpoints($breakpoints)
|
33
|
+
$total_grid_weight: get-sum-of-column-weights($list)
|
34
|
+
$num_core_columns: get-num-core-columns($list)
|
35
|
+
$num_columns: length($list)
|
36
|
+
$core_columns: ()
|
37
|
+
$resolution: map-get($breakpoints, resolution)
|
38
|
+
$orientation: map-get($breakpoints, orientation)
|
39
|
+
|
40
|
+
$total_grid_weight: $total_grid_weight + (length($list) - 1) * $padding/100
|
41
|
+
$to_return: (total_grid_weight: $total_grid_weight, num_columns: $num_columns, resolution: $resolution, orientation: $orientation, padding: $padding)
|
42
|
+
$index: 1
|
43
|
+
$offset: 0
|
44
|
+
$to_return : map-merge($to_return, (class_name: $class_name, transition_duration: $transition_duration))
|
45
|
+
|
46
|
+
@each $column_param in $list
|
47
|
+
|
48
|
+
$column_weight: get-column-weight($column_param)
|
49
|
+
$column_padding: $padding/100
|
50
|
+
@if $index == 1
|
51
|
+
$column_padding: 0
|
52
|
+
$to_return: map-merge($to_return, ($index: (weight: $column_weight, offset: $offset + $column_padding)))
|
53
|
+
|
54
|
+
@if is-core-column-param($column_param) or $num_core_columns == 0
|
55
|
+
$core_columns: map-merge($core_columns, ($index: (weight: $column_weight)))
|
56
|
+
$index: $index + 1
|
57
|
+
$offset: $offset + $column_weight + $column_padding
|
58
|
+
|
59
|
+
$to_return: map-merge($to_return, (core_columns: $core_columns))
|
60
|
+
$total_core_column_weight: total-column-weights($core_columns) + (map-length($core_columns) - 1) * $padding/100
|
61
|
+
$to_return: map-merge($to_return, (total_core_column_weight: $total_core_column_weight))
|
62
|
+
@return $to_return
|
63
|
+
|
64
|
+
@function parse-breakpoints($breakpoints)
|
65
|
+
$to_return: ()
|
66
|
+
$breakpoints_resolution: null
|
67
|
+
$breakpoints_orientation: null
|
68
|
+
|
69
|
+
@if type-of($breakpoints) == map
|
70
|
+
$breakpoints_resolution: map-get($breakpoints, resolution)
|
71
|
+
$breakpoints_orientation: map-get($breakpoints, orientation)
|
72
|
+
|
73
|
+
@else
|
74
|
+
@if type-of($breakpoints) == number
|
75
|
+
$breakpoints_resolution: $breakpoints
|
76
|
+
$breakpoints_orientation: null
|
77
|
+
|
78
|
+
@else
|
79
|
+
$breakpoints: assert-type($breakpoints, string, "Expected a number or a string with value 'portrait' or 'landscape'. Got #{$breakpoints}.")
|
80
|
+
$breakpoints_orientation: $breakpoints
|
81
|
+
$breakpoints_resolution: null
|
82
|
+
|
83
|
+
@if is-not-null($breakpoints_resolution)
|
84
|
+
$breakpoints_resolution: assert-type($breakpoints_resolution, number, "Expected a number for resolution. Got #{type-of($breakpoints_resolution)}.")
|
85
|
+
@if $breakpoints_resolution < 0
|
86
|
+
@error "Expected resolution greater than 0. Got #{$breakpoints_resolution}."
|
87
|
+
|
88
|
+
@if is-not-null($breakpoints_orientation)
|
89
|
+
@if $breakpoints_orientation != "portrait" and $breakpoints_orientation != "landscape"
|
90
|
+
@error "Expected 'portrait' or 'landscape' as value of orientation. Got #{$breakpoints_orientation}."
|
91
|
+
|
92
|
+
@if $breakpoints_resolution == null and $breakpoints_orientation == null
|
93
|
+
$breakpoints_resolution: $DEFAULT_RESOLUTION
|
94
|
+
|
95
|
+
$to_return: map-merge($to_return, (resolution: $breakpoints_resolution))
|
96
|
+
$to_return: map-merge($to_return, (orientation: $breakpoints_orientation))
|
97
|
+
|
98
|
+
@return $to_return
|
99
|
+
|
100
|
+
@function assert-not-null($value, $error_message)
|
101
|
+
@if is-null($value)
|
102
|
+
@error $error_message
|
103
|
+
@return $error_message
|
104
|
+
|
105
|
+
@function is-null($value)
|
106
|
+
@return $value == null
|
107
|
+
|
108
|
+
@function is-not-null($value)
|
109
|
+
@return not is-null($value)
|
110
|
+
|
111
|
+
@function assert-type($value, $expected_type, $error_message)
|
112
|
+
@if type-of($value) != $expected_type
|
113
|
+
@error $error_message
|
114
|
+
@return $value
|
115
|
+
|
116
|
+
@function get-sum-of-column-weights($list)
|
117
|
+
$total_weight: 0
|
118
|
+
|
119
|
+
@each $column_param in $list
|
120
|
+
$total_weight: $total_weight + get-column-weight($column_param)
|
121
|
+
|
122
|
+
@return $total_weight
|
123
|
+
|
124
|
+
@function get-num-core-columns($list)
|
125
|
+
$num_core_columns: 0
|
126
|
+
|
127
|
+
@each $column_param in $list
|
128
|
+
@if is-core-column-param($column_param)
|
129
|
+
$num_core_columns: $num_core_columns + 1
|
130
|
+
|
131
|
+
@return $num_core_columns
|
132
|
+
|
133
|
+
@function get-column-weight($column_param)
|
134
|
+
@if type-of($column_param) == list
|
135
|
+
@return nth($column_param,1)
|
136
|
+
|
137
|
+
@if type-of($column_param) == number
|
138
|
+
@return $column_param
|
139
|
+
|
140
|
+
@function is-core-column-param($column_param)
|
141
|
+
@if type-of($column_param) == list
|
142
|
+
@return nth($column_param,2) == true
|
143
|
+
@return false
|
144
|
+
@if type-of($column_param) != number
|
145
|
+
@error "First parameter to grid has to be a list of numbers and/or lists"
|
146
|
+
@return false
|
147
|
+
|
148
|
+
@mixin grid-column-with-offset($column_weight, $total_column_weights, $offset, $index, $core_columns, $resolution, $orientation, $grid, $padding: 0)
|
149
|
+
@include grid-column($column_weight, $total_column_weights)
|
150
|
+
left: percentage-column($offset, $total_column_weights)
|
151
|
+
|
152
|
+
@if is-core-column($index, $core_columns)
|
153
|
+
@include extend-this-column($column_weight, $index, $core_columns, $resolution, $orientation, $padding)
|
154
|
+
@else
|
155
|
+
@include remove-this-column($column_weight, $total_column_weights, $offset, $resolution, $orientation, $grid)
|
156
|
+
|
157
|
+
@mixin grid-column($size, $number_of_columns)
|
158
|
+
width: percentage-column($size, $number_of_columns)
|
159
|
+
|
160
|
+
@function is-core-column($key, $core_columns)
|
161
|
+
@return map-get($core_columns, $key) != null
|
162
|
+
|
163
|
+
@mixin extend-this-column($column_weight, $column_index, $core_columns, $resolution, $orientation, $padding)
|
164
|
+
$total_weight: total-column-weights($core_columns) + (map-length($core_columns) - 1) * $padding/100
|
165
|
+
|
166
|
+
$columns_before_this_column: get-columns-with-index-less-than($column_index, $core_columns)
|
167
|
+
$num_columns_before_this_column: map-length($columns_before_this_column)
|
168
|
+
|
169
|
+
$width: percentage-column($column_weight, $total_weight)
|
170
|
+
$left: percentage-column(total-column-weights($columns_before_this_column) + $num_columns_before_this_column * $padding/100, $total_weight)
|
171
|
+
@include extend($resolution, $orientation, $width, $left)
|
172
|
+
|
173
|
+
@function total-column-weights($column_map)
|
174
|
+
$total_column_weights: 0
|
175
|
+
@each $index, $value in $column_map
|
176
|
+
$total_column_weights: $total_column_weights + map-get($value, weight)
|
177
|
+
@return $total_column_weights
|
178
|
+
|
179
|
+
@function get-columns-with-index-less-than($limit_index, $column_map)
|
180
|
+
$to_return : ()
|
181
|
+
@each $index, $value in $column_map
|
182
|
+
@if $index < $limit_index
|
183
|
+
$to_return: map-merge($to_return, ($index: $value))
|
184
|
+
|
185
|
+
@return $to_return
|
186
|
+
|
187
|
+
@mixin extend($r, $o, $width: 100%, $left: 0)
|
188
|
+
@include w-resolution-or-orientation($r, $o)
|
189
|
+
width: $width
|
190
|
+
left: $left
|
191
|
+
|
192
|
+
@mixin w-resolution-or-orientation($r, $o)
|
193
|
+
@if is-not-null($r)
|
194
|
+
@include w-lte($r)
|
195
|
+
@content
|
196
|
+
|
197
|
+
@if is-not-null($o)
|
198
|
+
@include w-orientation($o)
|
199
|
+
@content
|
200
|
+
|
201
|
+
@mixin w-lte($resolution)
|
202
|
+
@media only screen and (max-width: #{$resolution}px)
|
203
|
+
@content
|
204
|
+
|
205
|
+
@mixin w-orientation($orientation)
|
206
|
+
@media only screen and (orientation: #{$orientation})
|
207
|
+
@content
|
208
|
+
|
209
|
+
@mixin remove-this-column($column_weight, $total_grid_weight, $offset, $resolution, $orientation, $grid)
|
210
|
+
@if $offset < $total_grid_weight / 2
|
211
|
+
$distance: -100% - ($offset/$column_weight) * 101%
|
212
|
+
@include offscreen-left($distance, $resolution, $orientation, percentage-column($column_weight, $total_grid_weight), $grid)
|
213
|
+
@else
|
214
|
+
$distance: ($total_grid_weight - $offset)/$column_weight * 101%
|
215
|
+
@include offscreen-right($distance, $resolution, $orientation, percentage-column($column_weight, $total_grid_weight), $grid)
|
216
|
+
|
217
|
+
@mixin offscreen-left($distance, $resolution, $orientation, $column_width, $grid)
|
218
|
+
@include w-resolution-or-orientation($resolution, $orientation)
|
219
|
+
transform: translate3d($distance,0,0)
|
220
|
+
z-index: 0
|
221
|
+
.no-csstransforms3d &
|
222
|
+
left: -#{$column_width}
|
223
|
+
|
224
|
+
&.slide-in
|
225
|
+
transform: translate3d(100% + $distance, 0 ,0)
|
226
|
+
|
227
|
+
@include shift-core-columns($grid, $column_width, "right")
|
228
|
+
|
229
|
+
@mixin offscreen-right($distance, $resolution, $orientation, $column_width, $grid)
|
230
|
+
@include w-resolution-or-orientation($resolution, $orientation)
|
231
|
+
transform: translate3d($distance,0 ,0)
|
232
|
+
z-index: 0
|
233
|
+
.no-csstransforms3d &
|
234
|
+
left: 100%
|
235
|
+
|
236
|
+
&.slide-in
|
237
|
+
transform: translate3d(-100% + $distance, 0, 0)
|
238
|
+
|
239
|
+
@include shift-core-columns($grid, $column_width, "left")
|
240
|
+
|
241
|
+
@mixin shift-core-columns($grid, $shift_distance, $direction)
|
242
|
+
$core_columns: map-get($grid, core_columns)
|
243
|
+
$class_name: map-get($grid, class_name)
|
244
|
+
$total_core_weight: map-get($grid, total_core_column_weight)
|
245
|
+
$total_weight: map-get($grid, total_grid_weight)
|
246
|
+
$padding: map-get($grid, padding)
|
247
|
+
@each $index, $weight in $core_columns
|
248
|
+
$weight: map-get($weight, weight)
|
249
|
+
$this_column_in_percentages: ($weight / $total_core_weight) * 100%
|
250
|
+
$x_position: $this_column_in_percentages / ($this_column_in_percentages / $shift_distance)
|
251
|
+
& ~ .#{$class_name}-#{$index}
|
252
|
+
@if $direction == "right"
|
253
|
+
transform: translate3d($x_position + ($padding * ($total_core_weight / $total_weight) / $weight * 1%), 0, 0)
|
254
|
+
@if $direction == "left"
|
255
|
+
transform: translate3d(-$x_position - ($padding * ($total_core_weight / $total_weight) / $weight * 1%), 0, 0)
|
data/lib/ionica.rb
ADDED
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ionica
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tomislav Pesut
|
9
|
+
- Anna Andresian
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: railties
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
description: A gem that provides a lightweight responsive grid
|
32
|
+
email:
|
33
|
+
- tpesut@amplify.com
|
34
|
+
- aandresian@amplify.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/ionica/version.rb
|
40
|
+
- lib/ionica.rb
|
41
|
+
- app/assets/stylesheets/ionica.sass
|
42
|
+
- LICENSE
|
43
|
+
- README.md
|
44
|
+
homepage: http://rubygems.org/gems/ionica
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
- app
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.24
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: A gem that provides a lightweight responsive grid
|
70
|
+
test_files: []
|