ionica 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed6e5a6ffcc115f5a476c5ce35052014a29194db
4
- data.tar.gz: d663883ce3e8c350f24a46b82896319d72ce5636
3
+ metadata.gz: 37e75dbd3b8968d4886331a58f70893d4073cc3e
4
+ data.tar.gz: 5b9bbdb6c47bdf7f9aaf46be5437ab3b366d9d1f
5
5
  SHA512:
6
- metadata.gz: 0e10f7b6f447a002e6a00361b77db3ed77ebded793d9bfff29ef66a5d035e98a3e7a0ca27eca552ce1720a37b4b818f1d6d49e3341302855d4cc29eaf1f8e56a
7
- data.tar.gz: ab0975798695e02a4b3207c1bdea3a94f8451c36d66359a681508741f1638c93dfed3823f0091a24a4363d32b72866a8726dfa16eac350fa6fe5326b794e8fab
6
+ metadata.gz: 23dd3edcb6d9a363e909a9f7e2a224018345b7adf41d4329a15f8760e810a89065c6ddc505867c81b07798115e8313e40dc4985762c11a1769b8604bcdc10c95
7
+ data.tar.gz: e6c2185c249c960b9b7194754120a2d04a7f36299a82bd2578b4023407bd7b6a46d2ece93ee9a150ee9347c530077d74b690b92d51f8b7c5bc0234ad90b240f7
@@ -1,12 +1,59 @@
1
- $DEFAULT_RESOLUTION: 768
2
- $DEFAULT_IDENTIFIER: "amplify-ionica-grid-default-identifier"
3
- $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
1
+ @function _length($number, $unit)
2
+ $strings: 'px' 'cm' 'mm' '%' 'ch' 'pica' 'in' 'em' 'rem' 'pt' 'pc' 'ex' 'vw' 'vh' 'vmin' 'vmax'
3
+ $units: 1px 1cm 1mm 1% 1ch 1pica 1in 1em 1rem 1pt 1pc 1ex 1vw 1vh 1vmin 1vmax
4
+ $index: index($strings, $unit)
5
+
6
+ @if not $index
7
+ @warn "Unknown unit `#{$unit}`."
8
+ @return false
9
+
10
+ @return $number * nth($units, $index)
11
+
12
+ @function number($string)
13
+ // Matrices
14
+ $strings: '0' '1' '2' '3' '4' '5' '6' '7' '8' '9'
15
+ $numbers: 0 1 2 3 4 5 6 7 8 9
16
+
17
+ // Result
18
+ $result: 0
19
+ $divider: 0
20
+ $minus: false
21
+
22
+ // Looping through all characters
23
+ @for $i from 1 through str-length($string)
24
+ $character: str-slice($string, $i, $i)
25
+ $index: index($strings, $character)
26
+
27
+
28
+ @if $character == '-'
29
+ $minus: true
4
30
 
5
- @mixin grid-column-styles($transition_duration)
6
- transition: transform, $transition_duration
7
- position: absolute
8
- height: 100%
9
- z-index: 1
31
+
32
+ @else if $character == '.'
33
+ $divider: 1
34
+
35
+
36
+ @else
37
+ @if not $index
38
+ $result: if($minus, $result * -1, $result)
39
+ @return _length($result, str-slice($string, $i))
40
+
41
+
42
+ $number: nth($numbers, $index)
43
+
44
+ @if $divider == 0
45
+ $result: $result * 10
46
+
47
+
48
+ @else
49
+ // Move the decimal dot to the left
50
+ $divider: $divider * 10
51
+ $number: $number / $divider
52
+
53
+
54
+ $result: $result + $number
55
+
56
+ @return if($minus, $result * -1, $result)
10
57
 
11
58
  @function map-length($map)
12
59
  @return length(map-keys($map))
@@ -14,14 +61,40 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
14
61
  @function percentage-column($size, $number_of_columns)
15
62
  @return to-percent($size * (100 / $number_of_columns))
16
63
 
64
+ @function decimal-column($size, $number_of_columns)
65
+ @return $size / $number_of_columns
66
+
17
67
  @function to-percent($number)
18
68
  @return $number * 1%
19
69
 
70
+ @function column-has-weight($column)
71
+ @return type-of($column) == number or (type-of($column) == list and type-of(nth($column, 1)) == number)
72
+
73
+ @function column-has-width($column)
74
+ @return type-of($column) == string
75
+
76
+ @function throw-invalid-weight-argument-error()
77
+ @error "First argument of a column has to be a list, number or a string"
78
+ @return 0
79
+
80
+ @function is-last-column($column_index, $grid)
81
+ @return $column_index == map-get($grid, num_columns)
82
+
83
+ $DEFAULT_RESOLUTION: 768
84
+ $DEFAULT_IDENTIFIER: "amplify-ionica-grid-default-identifier"
85
+ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
86
+
87
+ @mixin grid-column-styles($transition_duration)
88
+ transition: transform, $transition_duration
89
+ position: absolute
90
+ height: 100%
91
+ z-index: 1
92
+
20
93
  @mixin column($grid, $key)
21
94
  @include grid-column-styles(map-get($grid, transition_duration))
22
95
  $c: map-get($grid, $key)
23
96
  $padding: map-get($grid, padding)
24
- @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)
97
+ @include grid-column-with-offset(map-get($c, weight), map-get($c, width), map-get($grid, total_grid_weight), map-get($grid, total_fixed_width), map-get($c, offset), map-get($c, width_offset), $key, map-get($grid, core_columns), map-get($grid, resolution), map-get($grid, orientation), $grid, $padding)
25
98
 
26
99
  @mixin generate-column-classes($grid, $class_name)
27
100
  $num_columns: map-get($grid, num_columns)
@@ -44,24 +117,34 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
44
117
  $index: 1
45
118
  $offset: 0
46
119
  $to_return : map-merge($to_return, (class_name: $class_name, transition_duration: $transition_duration))
120
+ $total_fixed_width: 0
121
+ $width_offset: 0
47
122
 
48
123
  @each $column_param in $list
49
124
 
50
125
  $column_weight: get-column-weight($column_param)
126
+ $column_width: get-column-width($column_param)
127
+ @if column-has-width($column_param)
128
+ $total_fixed_width: $total_fixed_width + number($column_width)
129
+
51
130
  $column_padding: $padding/100
52
131
  $column_identifier: get-column-identifier($column_param)
53
132
  @if $index == 1
54
133
  $column_padding: 0
55
- $to_return: map-merge($to_return, ($index: (weight: $column_weight, offset: $offset + $column_padding, identifier: $column_identifier)))
56
134
 
57
135
  @if is-core-column-param($column_param) or $num_core_columns == 0
58
136
  $core_columns: map-merge($core_columns, ($index: (weight: $column_weight, identifier: $column_identifier)))
137
+ @else
138
+ $to_return: map-merge($to_return, ($index: (weight: $column_weight, width: $column_width, offset: $offset + $column_padding, width_offset: $width_offset, identifier: $column_identifier)))
139
+
59
140
  $index: $index + 1
60
141
  $offset: $offset + $column_weight + $column_padding
142
+ @if column-has-width($column_param)
143
+ $width_offset: $width_offset + number($column_width)
61
144
 
62
145
  $to_return: map-merge($to_return, (core_columns: $core_columns))
63
146
  $total_core_column_weight: total-column-weights($core_columns) + (map-length($core_columns) - 1) * $padding/100
64
- $to_return: map-merge($to_return, (total_core_column_weight: $total_core_column_weight))
147
+ $to_return: map-merge($to_return, (total_core_column_weight: $total_core_column_weight, total_fixed_width: $total_fixed_width))
65
148
  @return $to_return
66
149
 
67
150
  @function parse-breakpoints($breakpoints)
@@ -134,12 +217,25 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
134
217
  @return $num_core_columns
135
218
 
136
219
  @function get-column-weight($column_param)
220
+ @if column-has-width($column_param)
221
+ @return 0
222
+
137
223
  @if type-of($column_param) == list
138
224
  @return nth($column_param,1)
139
225
 
140
226
  @if type-of($column_param) == number
141
227
  @return $column_param
142
228
 
229
+ @error "Something Error Happened"
230
+
231
+ @function get-column-width($column_param)
232
+ @if column-has-weight($column_param)
233
+ @return 0
234
+ @else if type-of($column_param) == string
235
+ @return $column_param
236
+
237
+ @error "Column width must be a string."
238
+
143
239
  @function get-column-identifier($column_param)
144
240
  @if type-of($column_param) == list
145
241
  @if length($column_param) > 2 and type-of(nth($column_param, 3)) == string
@@ -150,21 +246,32 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
150
246
  @if type-of($column_param) == list
151
247
  @return nth($column_param,2) == true
152
248
  @return false
153
- @if type-of($column_param) != number
154
- @error "First parameter to grid has to be a list of numbers and/or lists"
155
- @return false
156
249
 
157
- @mixin grid-column-with-offset($column_weight, $total_column_weights, $offset, $index, $core_columns, $resolution, $orientation, $grid, $padding: 0)
158
- @include grid-column($column_weight, $total_column_weights)
159
- left: percentage-column($offset, $total_column_weights)
250
+ @mixin grid-column-with-offset($column_weight, $column_width, $total_column_weights, $total_fixed_width, $offset, $width_offset, $index, $core_columns, $resolution, $orientation, $grid, $padding: 0)
251
+ @include grid-column($column_weight, $column_width, $total_column_weights, $total_fixed_width)
252
+ @if $offset == 0 and $width_offset == 0
253
+ left: 0
254
+ @else if $total_fixed_width == 0
255
+ left: percentage-column($offset, $total_column_weights)
256
+ @else
257
+ left: calc(#{$width_offset} + (100% - #{$total_fixed_width}) * #{decimal-column($offset, $total_column_weights)})
160
258
 
161
259
  @if is-core-column($index, $core_columns)
162
260
  @include extend-this-column($column_weight, $index, $core_columns, $resolution, $orientation, $padding)
163
261
  @else
164
- @include remove-this-column($column_weight, $total_column_weights, $offset, $resolution, $orientation, $grid)
262
+ @if $column_width == 0
263
+ @include remove-this-dynamic-column($column_weight, $total_column_weights, $offset, $resolution, $orientation, $grid)
264
+ @else
265
+ @include remove-this-static-column($column_width, $resolution, $orientation, $index, $grid)
165
266
 
166
- @mixin grid-column($size, $number_of_columns)
167
- width: percentage-column($size, $number_of_columns)
267
+ @mixin grid-column($weight, $width, $number_of_columns, $total_fixed_width)
268
+ @if $width == 0
269
+ @if $total_fixed_width == 0
270
+ width: percentage-column($weight, $number_of_columns)
271
+ @else
272
+ width: calc((100% - #{$total_fixed_width}) * #{decimal-column($weight, $number_of_columns)})
273
+ @else
274
+ width: #{$width}
168
275
 
169
276
  @function is-core-column($key, $core_columns)
170
277
  @return map-get($core_columns, $key) != null
@@ -215,7 +322,7 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
215
322
  @media only screen and (orientation: #{$orientation})
216
323
  @content
217
324
 
218
- @mixin remove-this-column($column_weight, $total_grid_weight, $offset, $resolution, $orientation, $grid)
325
+ @mixin remove-this-dynamic-column($column_weight, $total_grid_weight, $offset, $resolution, $orientation, $grid)
219
326
  @if $offset < $total_grid_weight / 2
220
327
  $distance: -100% - ($offset/$column_weight) * 101%
221
328
  @include offscreen-left($distance, $resolution, $orientation, percentage-column($column_weight, $total_grid_weight), $grid)
@@ -223,7 +330,13 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
223
330
  $distance: ($total_grid_weight - $offset)/$column_weight * 101%
224
331
  @include offscreen-right($distance, $resolution, $orientation, percentage-column($column_weight, $total_grid_weight), $grid)
225
332
 
226
- @mixin offscreen-left($distance, $resolution, $orientation, $column_width, $grid)
333
+ @mixin remove-this-static-column($column_width, $resolution, $orientation, $index, $grid)
334
+ @if $index == 1
335
+ @include offscreen-left(-100%, $resolution, $orientation, $column_width, $grid, true)
336
+ @else if is-last-column($index, $grid)
337
+ @include offscreen-right(100%, $resolution, $orientation, $column_width, $grid, true)
338
+
339
+ @mixin offscreen-left($distance, $resolution, $orientation, $column_width, $grid, $is_static_column: false)
227
340
  @include w-resolution-or-orientation($resolution, $orientation)
228
341
  transform: translate3d($distance,0,0)
229
342
  z-index: 0
@@ -233,9 +346,9 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
233
346
  &.slide-in
234
347
  transform: translate3d(100% + $distance, 0 ,0)
235
348
 
236
- @include shift-core-columns($grid, $column_width, "right")
349
+ @include shift-core-columns($grid, $column_width, "right", $is_static_column)
237
350
 
238
- @mixin offscreen-right($distance, $resolution, $orientation, $column_width, $grid)
351
+ @mixin offscreen-right($distance, $resolution, $orientation, $column_width, $grid, $is_static_column: false)
239
352
  @include w-resolution-or-orientation($resolution, $orientation)
240
353
  transform: translate3d($distance,0 ,0)
241
354
  z-index: 0
@@ -245,23 +358,36 @@ $DEFAULT_CLASSNAME: "amplify-ionica-grid-default-classname"
245
358
  &.slide-in
246
359
  transform: translate3d(-100% + $distance, 0, 0)
247
360
 
248
- @include shift-core-columns($grid, $column_width, "left")
361
+ @include shift-core-columns($grid, $column_width, "left", $is_static_column)
249
362
 
250
- @mixin shift-core-columns($grid, $shift_distance, $direction)
363
+ @mixin shift-core-columns($grid, $shift_distance, $direction, $is_static_column: false)
251
364
  $core_columns: map-get($grid, core_columns)
252
365
  $class_name: map-get($grid, class_name)
253
366
  $total_core_weight: map-get($grid, total_core_column_weight)
254
367
  $total_weight: map-get($grid, total_grid_weight)
255
368
  $padding: map-get($grid, padding)
369
+ $x_position: 0
256
370
  @each $index, $params in $core_columns
257
371
  $weight: map-get($params, weight)
258
372
  $identifier: map-get($params, identifier)
259
373
  @if $identifier == $DEFAULT_IDENTIFIER
260
374
  $identifier: ".#{$class_name}-#{$index}"
261
- $this_column_in_percentages: ($weight / $total_core_weight) * 100%
262
- $x_position: $this_column_in_percentages / ($this_column_in_percentages / $shift_distance)
375
+ @if $is_static_column
376
+ $x_position: $shift_distance
377
+ @else
378
+ $this_column_in_percentages: ($weight / $total_core_weight) * 100%
379
+ $x_position: $this_column_in_percentages / ($this_column_in_percentages / $shift_distance)
263
380
  & ~ #{$identifier}
264
- @if $direction == "right"
265
- transform: translate3d($x_position + ($padding * ($total_core_weight / $total_weight) / $weight * 1%), 0, 0)
266
- @if $direction == "left"
267
- transform: translate3d(-$x_position - ($padding * ($total_core_weight / $total_weight) / $weight * 1%), 0, 0)
381
+ @if $is_static_column
382
+ $p: ($padding * ($total_core_weight / $total_weight) / $weight * 1%)
383
+ @if $direction == "right"
384
+ transform: translate3d(calc(#{$x_position} + #{$p}), 0, 0)
385
+ @if $direction == "left"
386
+ transform: translate3d(#{-$x_position}, 0, 0)
387
+
388
+ @else
389
+ @if $direction == "right"
390
+ transform: translate3d($x_position + ($padding * ($total_core_weight / $total_weight) / $weight * 1%), 0, 0)
391
+ @if $direction == "left"
392
+ transform: translate3d(-$x_position - ($padding * ($total_core_weight / $total_weight) / $weight * 1%), 0, 0)
393
+
@@ -1,4 +1,4 @@
1
1
  module Ionica
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ionica
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomislav Pesut
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-04 00:00:00.000000000 Z
12
+ date: 2014-12-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties