dlegr250_material_design 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +4 -0
  6. data/README.md +66 -0
  7. data/Rakefile +6 -0
  8. data/app/controllers/styleguide_controller.rb +5 -0
  9. data/app/views/styleguide/_buttons.html.erb +79 -0
  10. data/app/views/styleguide/_menus.html.erb +189 -0
  11. data/app/views/styleguide/_navigation.html.erb +28 -0
  12. data/app/views/styleguide/index.html.erb +9 -0
  13. data/bin/console +14 -0
  14. data/bin/setup +7 -0
  15. data/dlegr250_material_design.gemspec +34 -0
  16. data/lib/dlegr250_material_design.rb +6 -0
  17. data/lib/dlegr250_material_design/version.rb +3 -0
  18. data/vendor/assets/javascripts/base/init.js.coffee +14 -0
  19. data/vendor/assets/javascripts/components/dialog.coffee +54 -0
  20. data/vendor/assets/javascripts/components/forms.coffee +17 -0
  21. data/vendor/assets/javascripts/components/layout.coffee +76 -0
  22. data/vendor/assets/javascripts/components/menus.coffee +87 -0
  23. data/vendor/assets/javascripts/components/snackbar_handler.coffee +8 -0
  24. data/vendor/assets/javascripts/components/tabs.coffee +18 -0
  25. data/vendor/assets/javascripts/components/utility.coffee +8 -0
  26. data/vendor/assets/javascripts/dlegr250_material_design.js +20 -0
  27. data/vendor/assets/javascripts/extensions/coffeescript.js.coffee +9 -0
  28. data/vendor/assets/javascripts/extensions/jquery.js.coffee +30 -0
  29. data/vendor/assets/javascripts/third_party/hammer.min.js +7 -0
  30. data/vendor/assets/javascripts/third_party/handlebars.latest.js +4454 -0
  31. data/vendor/assets/javascripts/third_party/jquery.hammer.js +33 -0
  32. data/vendor/assets/javascripts/third_party/snackbarlight.js +218 -0
  33. data/vendor/assets/stylesheets/base/base.scss +73 -0
  34. data/vendor/assets/stylesheets/base/global_classes.scss +261 -0
  35. data/vendor/assets/stylesheets/base/mixins.scss +202 -0
  36. data/vendor/assets/stylesheets/base/normalize.scss +229 -0
  37. data/vendor/assets/stylesheets/base/variables.scss +177 -0
  38. data/vendor/assets/stylesheets/components/badges.scss +28 -0
  39. data/vendor/assets/stylesheets/components/blank_slates.scss +58 -0
  40. data/vendor/assets/stylesheets/components/boxes.scss +34 -0
  41. data/vendor/assets/stylesheets/components/buttons.scss +225 -0
  42. data/vendor/assets/stylesheets/components/cards.scss +110 -0
  43. data/vendor/assets/stylesheets/components/code.scss +13 -0
  44. data/vendor/assets/stylesheets/components/dialogs.scss +57 -0
  45. data/vendor/assets/stylesheets/components/dividers.scss +35 -0
  46. data/vendor/assets/stylesheets/components/forms/error_messages.scss +27 -0
  47. data/vendor/assets/stylesheets/components/forms/fields.scss +56 -0
  48. data/vendor/assets/stylesheets/components/forms/labels.scss +17 -0
  49. data/vendor/assets/stylesheets/components/forms/radios.scss +90 -0
  50. data/vendor/assets/stylesheets/components/forms/selects.scss +15 -0
  51. data/vendor/assets/stylesheets/components/forms/text_fields.scss +38 -0
  52. data/vendor/assets/stylesheets/components/forms/toggles.scss +70 -0
  53. data/vendor/assets/stylesheets/components/lists.scss +242 -0
  54. data/vendor/assets/stylesheets/components/menus.scss +164 -0
  55. data/vendor/assets/stylesheets/components/overlay.scss +27 -0
  56. data/vendor/assets/stylesheets/components/snackbarlight.scss +77 -0
  57. data/vendor/assets/stylesheets/components/spinners.scss +67 -0
  58. data/vendor/assets/stylesheets/components/tabs.scss +62 -0
  59. data/vendor/assets/stylesheets/components/tooltips.scss +75 -0
  60. data/vendor/assets/stylesheets/dlegr250_material_design.scss +47 -0
  61. data/vendor/assets/stylesheets/fonts/material_design_iconic_font.scss +5168 -0
  62. data/vendor/assets/stylesheets/fonts/material_design_iconic_font/Material-Design-Iconic-Font.eot +0 -0
  63. data/vendor/assets/stylesheets/fonts/material_design_iconic_font/Material-Design-Iconic-Font.svg +787 -0
  64. data/vendor/assets/stylesheets/fonts/material_design_iconic_font/Material-Design-Iconic-Font.ttf +0 -0
  65. data/vendor/assets/stylesheets/fonts/material_design_iconic_font/Material-Design-Iconic-Font.woff +0 -0
  66. data/vendor/assets/stylesheets/fonts/material_design_iconic_font/Material-Design-Iconic-Font.woff2 +0 -0
  67. data/vendor/assets/stylesheets/layouts/application/appbar.scss +93 -0
  68. data/vendor/assets/stylesheets/layouts/application/base.scss +27 -0
  69. data/vendor/assets/stylesheets/layouts/application/main.scss +26 -0
  70. data/vendor/assets/stylesheets/layouts/application/sidebars.scss +85 -0
  71. data/vendor/assets/stylesheets/layouts/authentication/base.scss +53 -0
  72. metadata +155 -0
@@ -0,0 +1,33 @@
1
+ (function(factory) {
2
+ if (typeof define === 'function' && define.amd) {
3
+ define(['jquery', 'hammerjs'], factory);
4
+ } else if (typeof exports === 'object') {
5
+ factory(require('jquery'), require('hammerjs'));
6
+ } else {
7
+ factory(jQuery, Hammer);
8
+ }
9
+ }(function($, Hammer) {
10
+ function hammerify(el, options) {
11
+ var $el = $(el);
12
+ if(!$el.data("hammer")) {
13
+ $el.data("hammer", new Hammer($el[0], options));
14
+ }
15
+ }
16
+
17
+ $.fn.hammer = function(options) {
18
+ return this.each(function() {
19
+ hammerify(this, options);
20
+ });
21
+ };
22
+
23
+ // extend the emit method to also trigger jQuery events
24
+ Hammer.Manager.prototype.emit = (function(originalEmit) {
25
+ return function(type, data) {
26
+ originalEmit.call(this, type, data);
27
+ $(this.element).trigger({
28
+ type: type,
29
+ gesture: data
30
+ });
31
+ };
32
+ })(Hammer.Manager.prototype.emit);
33
+ }));
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Constructor
3
+ *
4
+ * @param {[type]} data [description]
5
+ * @param {[type]} options [description]
6
+ * @param {Function} callback [description]
7
+ */
8
+ function Snackbar(data, options, callback){
9
+ if (data !== "") {
10
+ this.options = this.activateOptions(options);
11
+ this.data = data;
12
+ this.callback = callback;
13
+ this.start();
14
+ this.snackbar();
15
+ } else {
16
+ console.warn("SnackbarLight: You can not create a empty snackbar please give it a string.");
17
+ }
18
+ }
19
+
20
+ Snackbar.prototype = {
21
+
22
+ /**
23
+ * Default options
24
+ *
25
+ * @type {Object}
26
+ */
27
+ options: {
28
+ // How long it takes for the snackbar to disappear
29
+ timeout: 5000,
30
+ // Wich class is used to tell that the snackbar is active
31
+ activeClass: "active",
32
+ // Name of the link or action if specified
33
+ link: false,
34
+ // If not used clicking will activate the callback or do nothing
35
+ url: "#"
36
+ },
37
+
38
+ /**
39
+ * Create container for the snackbar
40
+ *
41
+ * @return {void}
42
+ */
43
+ start: function() {
44
+ if (!document.getElementById("snackbar-container")) {
45
+ var snackbarContainer = document.createElement("div");
46
+
47
+ snackbarContainer.setAttribute("id", "snackbar-container");
48
+
49
+ document.body.appendChild(snackbarContainer);
50
+ }
51
+ },
52
+
53
+ /**
54
+ * Timer
55
+ *
56
+ * @param {Function} callback
57
+ * @param {int} delay
58
+ * @return {void}
59
+ */
60
+ timer: function(callback, delay) {
61
+ var remaining = delay;
62
+
63
+ this.timer = {
64
+ // Create random timer id
65
+ timerId: Math.round(Math.random()*1000),
66
+
67
+ pause: function() {
68
+ // Clear the timeout
69
+ window.clearTimeout(this.timerId);
70
+ // Set the remaining to what time remains
71
+ remaining -= new Date() - start;
72
+ },
73
+
74
+ resume: function() {
75
+ start = new Date();
76
+ // Clear the timeout
77
+ window.clearTimeout(this.timerId);
78
+ // Set the timeout again
79
+ this.timerId = window.setTimeout(callback, remaining);
80
+ },
81
+ };
82
+ // Start the timer
83
+ this.timer.resume();
84
+ },
85
+
86
+ /**
87
+ * snackbar
88
+ *
89
+ * @return {void}
90
+ */
91
+ snackbar: function() {
92
+ var __self = this,
93
+ snackbar = document.createElement("div");
94
+
95
+ // Put the snackbar inside the snackbar container
96
+ var container = document.getElementById("snackbar-container");
97
+
98
+ // 2016-02-04 / dan.legrand@gmail.com
99
+ // According to Google Material Design spec, do not stack snackbars.
100
+ // This clears out any previous snackbars before adding the new one.
101
+ container.innerHTML = null;
102
+
103
+ container.appendChild(snackbar);
104
+
105
+ // Set the html inside the snackbar
106
+ snackbar.innerHTML = this.getData();
107
+
108
+ // Set the class of the snackbar
109
+ snackbar.setAttribute("class", "snackbar");
110
+
111
+ // 2016-02-06 / dan.legrand@gmail.com
112
+ // According to Google Material Design spec, do not cover FAB buttons.
113
+ // This moves any FAB buttons from bottom-right corner up.
114
+ // Assumes only 1 FAB on screen in bottom-right corner.
115
+ if ($(window).width() <= 750) {
116
+ $(".fab").css("bottom", "64px");
117
+ }
118
+
119
+ // Wait to set the active class so animations will be activated
120
+ setTimeout(function() {
121
+ snackbar.setAttribute("class", snackbar.getAttribute("class") + " " + __self.options.activeClass);
122
+ }, 50);
123
+
124
+ // If the timeout is false the snackbar will not be destroyed after some time
125
+ // only when the user clicks on it
126
+ if (this.options.timeout !== false) {
127
+ // Start the timer
128
+ this.timer(function() {
129
+ snackbar.setAttribute("class", "snackbar");
130
+ __self.destroy(snackbar);
131
+ }, this.options.timeout);
132
+ }
133
+
134
+ // Add the event listeners
135
+ this.listeners(snackbar);
136
+ },
137
+
138
+ /**
139
+ * Get the data/ message to display in the snackbar
140
+ *
141
+ * @return {string}
142
+ */
143
+ getData: function() {
144
+ if (this.options.link !== false) {
145
+ return "<span>" + this.data + "</span><a href='" + this.options.url + "'>" + this.options.link + "</a>";
146
+ }
147
+ return "<span>" + this.data + "</span>";
148
+ },
149
+
150
+ /**
151
+ * Activate the listeners
152
+ *
153
+ * @param {Object} element
154
+ * @return {void}
155
+ */
156
+ listeners: function(element) {
157
+ var __self = this;
158
+ // Adding event listener for when user clicks on the snackbar to remove it
159
+ element.addEventListener("click", function(){
160
+ if (typeof __self.callback == "function") {
161
+ __self.callback();
162
+ }
163
+ element.setAttribute("class", "snackbar");
164
+ __self.destroy(element);
165
+ });
166
+
167
+ // Stopping the timer when user hovers on the snackbar
168
+ element.addEventListener("mouseenter",function(){
169
+ __self.timer.pause();
170
+ });
171
+ element.addEventListener("mouseout",function(){
172
+ __self.timer.resume();
173
+ });
174
+ },
175
+
176
+ /**
177
+ * Remove the snackbar
178
+ *
179
+ * @param {object} element
180
+ * @return {void}
181
+ */
182
+ destroy: function(element) {
183
+ // 2016-02-06 / dan.legrand@gmail.com
184
+ // Put FAB back to original position if there are no more active snackbars.
185
+ if (($(".snackbar.active").length > 0) && ($(window).width() <= 750)) {
186
+ $(".fab").css("bottom", "64px");
187
+ } else {
188
+ $(".fab").css("bottom", "24px");
189
+ }
190
+
191
+ // Delay for removing the element (for when there are animations)
192
+ this.timer.pause();
193
+
194
+ element.remove();
195
+
196
+ setTimeout(function() {
197
+ element.remove();
198
+ }, 10000);
199
+ },
200
+
201
+ /**
202
+ * Compare the options to the default ones.
203
+ *
204
+ * @param {Object} newOptions
205
+ * @return {Object}
206
+ */
207
+ activateOptions: function(newOptions) {
208
+ var __self = this,
209
+ options = newOptions || {};
210
+
211
+ for (var opt in this.options) {
212
+ if (__self.options.hasOwnProperty(opt) && !options.hasOwnProperty(opt)) {
213
+ options[opt] = __self.options[opt];
214
+ }
215
+ }
216
+ return options;
217
+ },
218
+ };
@@ -0,0 +1,73 @@
1
+ //======================================================================
2
+ // Base HTML elements.
3
+ // Class styles are defined in global_classes.scss
4
+ //======================================================================
5
+
6
+ // Typography
7
+ //----------------------------------------------------------------------
8
+
9
+ // Note: Material Design Iconic Font is hosted locally
10
+
11
+ // @import url("https://fonts.googleapis.com/css?family=Open+Sans:400,600,700");
12
+ @import url("https://fonts.googleapis.com/css?family=Roboto:400,600,700");
13
+
14
+ // HTML/body
15
+ //----------------------------------------------------------------------
16
+
17
+ html,
18
+ body {
19
+ background-color: $body-background-color;
20
+ height: 100%;
21
+ width: 100%;
22
+ }
23
+
24
+ body {
25
+ color: color("text");
26
+ font-family: "Roboto", sans-serif;
27
+ font-size: $font-size-normal;
28
+ font-weight: normal;
29
+ line-height: 1.2;
30
+ }
31
+
32
+ // Bold
33
+ //----------------------------------------------------------------------
34
+
35
+ b,
36
+ strong {
37
+ font-weight: 700;
38
+ }
39
+
40
+ // Paragraphs
41
+ //----------------------------------------------------------------------
42
+
43
+ p {
44
+ margin: $spacing-normal 0;
45
+ }
46
+
47
+ // HRs used as spacers with lines
48
+ //----------------------------------------------------------------------
49
+
50
+ hr {
51
+ border: none;
52
+ border-bottom: 1px solid color("divider");
53
+ height: 1px;
54
+ margin: $spacing-xsmall 0;
55
+ padding: 0;
56
+ }
57
+
58
+ // Links
59
+ //----------------------------------------------------------------------
60
+
61
+ a {
62
+ color: color("blue");
63
+ letter-spacing: 0.25px;
64
+ text-decoration: none;
65
+ }
66
+
67
+ // Images
68
+ //----------------------------------------------------------------------
69
+
70
+ img {
71
+ width: 100%;
72
+ height: auto;
73
+ }
@@ -0,0 +1,261 @@
1
+ //======================================================================
2
+ // Global CSS classes for use on any element.
3
+ // Default element styles are defined in the base.scss file.
4
+ //======================================================================
5
+
6
+ // Alignments
7
+ //----------------------------------------------------------------------
8
+
9
+ .align-left {
10
+ text-align: left;
11
+ }
12
+
13
+ .align-center {
14
+ text-align: center;
15
+ }
16
+
17
+ .align-right {
18
+ text-align: right;
19
+ }
20
+
21
+ .float-left {
22
+ float: left;
23
+ }
24
+
25
+ .float-right {
26
+ float: right;
27
+ }
28
+
29
+ // Expand entire width and take element padding into consideration.
30
+ .full-width {
31
+ @include full-width;
32
+ }
33
+
34
+ // Constrained to max size to center content
35
+ //----------------------------------------------------------------------
36
+
37
+ .constrained {
38
+ margin: auto;
39
+ @include full-width;
40
+ }
41
+
42
+ .constrained-small {
43
+ max-width: $small-width;
44
+ }
45
+
46
+ .constrained-medium {
47
+ max-width: $medium-width;
48
+ }
49
+
50
+ .constrained-large {
51
+ max-width: $large-width;
52
+ }
53
+
54
+ // Padding
55
+ //----------------------------------------------------------------------
56
+
57
+ .padding-xsmall {
58
+ padding: $spacing-xsmall;
59
+ }
60
+
61
+ .padding-small {
62
+ padding: $spacing-small;
63
+ }
64
+
65
+ .padding-normal {
66
+ padding: $spacing-normal;
67
+ }
68
+
69
+ .padding-large {
70
+ padding: $spacing-large;
71
+ }
72
+
73
+ .padding-xlarge {
74
+ padding: $spacing-xlarge;
75
+ }
76
+
77
+ // Margins
78
+ //----------------------------------------------------------------------
79
+
80
+ // TODO need classes for this???
81
+
82
+ // Helper text is subtle text to give extra minor details
83
+ //----------------------------------------------------------------------
84
+
85
+ .hint {
86
+ color: color("hint");
87
+ }
88
+
89
+ .helper-text {
90
+ color: color("helper");
91
+ font-size: $font-size-small;
92
+ }
93
+
94
+ // Highlight
95
+ //----------------------------------------------------------------------
96
+
97
+ .highlight {
98
+ background-color: color("highlight");
99
+ }
100
+
101
+ // Bold text
102
+ //----------------------------------------------------------------------
103
+
104
+ .bold,
105
+ .strong {
106
+ font-weight: 700;
107
+ }
108
+
109
+ // Rounded corners
110
+ //----------------------------------------------------------------------
111
+
112
+ .rounded-corners {
113
+ @include rounded-corners;
114
+ }
115
+
116
+ .rounded-top-corners {
117
+ @include rounded-top-corners;
118
+ }
119
+
120
+ .rounded-right-corners {
121
+ @include rounded-right-corners;
122
+ }
123
+
124
+ .rounded-bottom-corners {
125
+ @include rounded-bottom-corners;
126
+ }
127
+
128
+ .rounded-left-corners {
129
+ @include rounded-left-corners;
130
+ }
131
+
132
+ // Visibility
133
+ //----------------------------------------------------------------------
134
+
135
+ // Remove from DOM rendering completely
136
+ .hidden {
137
+ display: none;
138
+ }
139
+
140
+ // Remain in DOM flow but make invisible
141
+ .invisible {
142
+ visibility: hidden;
143
+ }
144
+
145
+ // Disabled elements
146
+ //----------------------------------------------------------------------
147
+
148
+ :disabled,
149
+ .disabled {
150
+ cursor: not-allowed !important;
151
+ pointer-events: none !important;
152
+ @include transparency(0.6);
153
+ @include box-shadow(none);
154
+ }
155
+
156
+ // Colored background or text
157
+ //----------------------------------------------------------------------
158
+
159
+ @each $color-name, $color in $colors {
160
+ .color-#{$color-name} {
161
+ color: $color !important; // Assume if you're specifying this you want it to override
162
+ }
163
+
164
+ .background-color-#{$color-name} {
165
+ background-color: $color !important;
166
+ }
167
+ }
168
+
169
+ // Media query classes for various device sizes
170
+ //----------------------------------------------------------------------
171
+
172
+ .small-only {
173
+ display: block;
174
+ }
175
+
176
+ .small-only-inline {
177
+ display: inline-block;
178
+ }
179
+
180
+ .small-and-medium-only {
181
+ display: block;
182
+ }
183
+
184
+ .small-and-medium-only-inline {
185
+ display: inline-block;
186
+ }
187
+
188
+ .medium-only,
189
+ .medium-only-inline {
190
+ display: none;
191
+ }
192
+
193
+ .medium-and-large-only,
194
+ .medium-and-large-only-inline {
195
+ display: none;
196
+ }
197
+
198
+ .large-only,
199
+ .large-only-inline {
200
+ display: none;
201
+ }
202
+
203
+ @media (min-width: $medium-width) {
204
+ .small-only,
205
+ .small-only-inline {
206
+ display: none !important;
207
+ }
208
+
209
+ .medium-only {
210
+ display: block !important;
211
+ }
212
+
213
+ .medium-only-inline {
214
+ display: inline-block !important;
215
+ }
216
+
217
+ .medium-and-large-only {
218
+ display: block !important;
219
+ }
220
+
221
+ .medium-and-large-only-inline {
222
+ display: inline-block !important;
223
+ }
224
+ }
225
+
226
+ @media (min-width: $large-width) {
227
+ .small-only,
228
+ .small-only-inline,
229
+ .small-and-medium-only,
230
+ .small-and-medium-only-inline,
231
+ .medium-only,
232
+ .medium-only-inline {
233
+ display: none !important;
234
+ }
235
+
236
+ .medium-and-large-only,
237
+ .large-only {
238
+ display: block !important;
239
+ }
240
+
241
+ .medium-and-large-only-inline,
242
+ .large-only-inline {
243
+ display: inline-block !important;
244
+ }
245
+ }
246
+
247
+ // Media queries
248
+ // Note: The best way to structure the use of media queries is to create the queries
249
+ // near the relevant code. For example, if you wanted to change the styles for buttons
250
+ // on small devices, paste the mobile query code up in the buttons section and style it
251
+ // there.
252
+ //----------------------------------------------------------------------
253
+
254
+ // Larger than mobile
255
+ @media (min-width: $small-width) {}
256
+
257
+ // Larger than medium
258
+ @media (min-width: $medium-width) {}
259
+
260
+ // Larger than large
261
+ @media (min-width: $large-width) {}