codelation_assets 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +122 -2
- data/app/assets/stylesheets/codelation/mixins/has_columns.scss +0 -1
- data/lib/codelation_assets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99d0048b807a011e81c8237d7ad960557745f504
|
4
|
+
data.tar.gz: c0ba29d216ecd9a2ce69a24305ae368cd2162089
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89f802369ab7a1cced4c97fb2a1da09325ee60d022c0c10245bdc5245e2bf864038a79eb4d232443a9eb603a29a622f24926efe7348b7269bcdd2316717c0768
|
7
|
+
data.tar.gz: 4391b62d4d6b92a07e78e12407e669e321db9018cf101b4aa1246a25f0cb09f78cc84bcd7634df3151c9dd18274ee5a5d9513894496c58fa724e5a0e0f0952a6
|
data/README.md
CHANGED
@@ -27,6 +27,75 @@ Add to `application.js`:
|
|
27
27
|
//= require codelation
|
28
28
|
```
|
29
29
|
|
30
|
+
#### App Functions
|
31
|
+
|
32
|
+
The `App` object is used in Codelation's Rails projects to register components that
|
33
|
+
need to be initialized on every page and to sprinkle in JavaScript on specific pages.
|
34
|
+
|
35
|
+
##### Registering JavaScript Components
|
36
|
+
|
37
|
+
By using `App.register('component')`, you can fire some JavaScript on every page load.
|
38
|
+
|
39
|
+
The function passed to `enter` will fire for `$(document).on('ready page:load')`, so
|
40
|
+
it will work with or without Turbolinks.
|
41
|
+
|
42
|
+
The function passed to `exit` will fire for `$(document).on('page:before-unload')`,
|
43
|
+
so it will only work with Turbolinks, but will not be needed when not using Turbolinks.
|
44
|
+
|
45
|
+
Example:
|
46
|
+
|
47
|
+
```javascript
|
48
|
+
(function() {
|
49
|
+
"use strict"
|
50
|
+
|
51
|
+
var body, links;
|
52
|
+
|
53
|
+
App.register('component').enter(function() {
|
54
|
+
body = $('body');
|
55
|
+
links = $('a[href]:not([href^="#"]):not([target="_blank"])');
|
56
|
+
|
57
|
+
// Add 'loading' class to the body when a link is clicked,
|
58
|
+
// add add 'active' class to the clicked link.
|
59
|
+
links.click(function() {
|
60
|
+
links.removeClass('active');
|
61
|
+
body.addClass('loading');
|
62
|
+
$(this).addClass('active');
|
63
|
+
});
|
64
|
+
}).exit(function() {
|
65
|
+
// Remove the classes when the body is unloaded
|
66
|
+
body.removeClass('loading');
|
67
|
+
links.removeClass('active');
|
68
|
+
});
|
69
|
+
})();
|
70
|
+
```
|
71
|
+
|
72
|
+
##### Registering Per Page JavaScript Snippets
|
73
|
+
|
74
|
+
You can use `App.register('[controller-name].[action-name]')` to fire some JavaScript any time
|
75
|
+
that page is loaded and unloaded. The `enter` and `exit` functions work the same as components.
|
76
|
+
|
77
|
+
Example:
|
78
|
+
|
79
|
+
```javascript
|
80
|
+
(function() {
|
81
|
+
"use strict"
|
82
|
+
|
83
|
+
var refreshInterval;
|
84
|
+
|
85
|
+
// This will only fire when entering and exiting the `AwesomeStatsController#index` page.
|
86
|
+
App.register('awesome-stats.index').enter(function() {
|
87
|
+
// Poll a URL for new data at a set interval
|
88
|
+
refreshInterval = setInterval(pollStats, 5000);
|
89
|
+
}).exit(function() {
|
90
|
+
// Clear the interval when the page is unloaded
|
91
|
+
clearInterval(refreshInterval);
|
92
|
+
});
|
93
|
+
})();
|
94
|
+
```
|
95
|
+
|
96
|
+
You can also use `App.register('[controller-name]')` to fire JavaScript on all pages
|
97
|
+
for the given controller name.
|
98
|
+
|
30
99
|
### Sass
|
31
100
|
|
32
101
|
Add to `application.scss`:
|
@@ -91,11 +160,62 @@ A good use case is centering an image of unknown height inside a container with
|
|
91
160
|
|
92
161
|
###### has-cards($columns, $margin: 0)
|
93
162
|
|
94
|
-
|
163
|
+
This mixin uses flexbox to create a cards layout like that used by Google Material Design. The
|
164
|
+
mixin is used on the container element. This will create a fixed margin between each card element
|
165
|
+
and adds padding around the outside of the cards. Useful for creating a dashboard widgets look.
|
166
|
+
|
167
|
+
Example:
|
168
|
+
|
169
|
+
```html
|
170
|
+
<div class="dashboard">
|
171
|
+
<div class="card"><div>
|
172
|
+
<div class="card"><div>
|
173
|
+
<div class="card"><div>
|
174
|
+
<div class="card"><div>
|
175
|
+
</div>
|
176
|
+
```
|
177
|
+
|
178
|
+
```scss
|
179
|
+
// This will create a cards layout with two cards per row.
|
180
|
+
// There will be a fixed margin of 1em between and around the cards.
|
181
|
+
// The cards in each row will stretch to be the same height.
|
182
|
+
.dashboard {
|
183
|
+
@include has-cards(2, 1em);
|
184
|
+
background-color: #ccc;
|
185
|
+
|
186
|
+
.card {
|
187
|
+
background-color: #fff;
|
188
|
+
border-radius: 2px;
|
189
|
+
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
```
|
95
193
|
|
96
194
|
###### has-columns($columns, $gutter: 0)
|
97
195
|
|
98
|
-
|
196
|
+
This mixin uses flexbox to create a layout with the specified number of columns
|
197
|
+
that stretch to fill the container's height. The given gutter size will the margin
|
198
|
+
between the columns. There is no need to set a margin-right of 0 to the nth-child
|
199
|
+
or anything like that. Flexbox rules!
|
200
|
+
|
201
|
+
Example:
|
202
|
+
|
203
|
+
```html
|
204
|
+
<div class="row">
|
205
|
+
<div class="column"><div>
|
206
|
+
<div class="column"><div>
|
207
|
+
<div class="column"><div>
|
208
|
+
</div>
|
209
|
+
```
|
210
|
+
|
211
|
+
```scss
|
212
|
+
// This will create a layout with three columns.
|
213
|
+
// The columns will all fill the container height.
|
214
|
+
// There will be a fixed gutter of 12px between the columns.
|
215
|
+
.row {
|
216
|
+
@include has-columns(3, 12px);
|
217
|
+
}
|
218
|
+
```
|
99
219
|
|
100
220
|
## Contributing
|
101
221
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codelation_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Pattison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bourbon
|