drg_material_icons 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +113 -0
- data/Rakefile +12 -0
- data/app/assets/fonts/material-icons-outline.woff2 +0 -0
- data/app/assets/fonts/material-icons-regular.woff2 +0 -0
- data/app/assets/stylesheets/drg_material_icons.css +2430 -0
- data/app/helpers/drg_material_icons/rails/icon_helper.rb +112 -0
- data/lib/drg_material_icons/engine.rb +6 -0
- data/lib/drg_material_icons/version.rb +6 -0
- data/lib/drg_material_icons.rb +2 -0
- data/lib/generators/drg_material_icons_update/USAGE +8 -0
- data/lib/generators/drg_material_icons_update/common.css +284 -0
- data/lib/generators/drg_material_icons_update/drg_material_icons_update_generator.rb +41 -0
- data/lib/generators/drg_material_icons_update/material-icons-outline.codepoints +2117 -0
- data/lib/generators/drg_material_icons_update/material-icons-regular.codepoints +2142 -0
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/assets/stylesheets/sass-import.css.sass +1 -0
- data/test/dummy/app/assets/stylesheets/scss-import.css.scss +1 -0
- data/test/dummy/app/assets/stylesheets/sprockets-require.css +3 -0
- data/test/dummy/app/controllers/pages_controller.rb +2 -0
- data/test/dummy/app/views/pages/icons.html.erb +3 -0
- data/test/dummy/config/application.rb +19 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +22 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config.ru +4 -0
- data/test/font_awesome_rails_test.rb +70 -0
- data/test/icon_helper_test.rb +138 -0
- data/test/test_helper.rb +7 -0
- metadata +123 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
module DrgMaterialIcons
|
2
|
+
module Rails
|
3
|
+
module IconHelper
|
4
|
+
# Creates an icon tag given an icon name and possible icon
|
5
|
+
# modifiers.
|
6
|
+
#
|
7
|
+
# Examples
|
8
|
+
#
|
9
|
+
# mi_icon "camera-retro"
|
10
|
+
# # => <i class="mi mi-camera-retro"></i>
|
11
|
+
#
|
12
|
+
# mi_icon "camera-retro", text: "Take a photo"
|
13
|
+
# # => <i class="mi mi-camera-retro"></i> Take a photo
|
14
|
+
# mi_icon "chevron-right", text: "Get started", right: true
|
15
|
+
# # => Get started <i class="mi mi-chevron-right"></i>
|
16
|
+
#
|
17
|
+
# mi_icon "camera-retro 2x"
|
18
|
+
# # => <i class="mi mi-camera-retro mi-2x"></i>
|
19
|
+
# mi_icon ["camera-retro", "4x"]
|
20
|
+
# # => <i class="mi mi-camera-retro mi-4x"></i>
|
21
|
+
# mi_icon "spinner spin lg"
|
22
|
+
# # => <i class="mi mi-spinner mi-spin mi-lg">
|
23
|
+
#
|
24
|
+
# mi_icon "quote-left 4x", class: "pull-left"
|
25
|
+
# # => <i class="mi mi-quote-left mi-4x pull-left"></i>
|
26
|
+
#
|
27
|
+
# mi_icon "user", data: { id: 123 }
|
28
|
+
# # => <i class="mi mi-user" data-id="123"></i>
|
29
|
+
#
|
30
|
+
# content_tag(:li, mi_icon("check li", text: "Bulleted list item"))
|
31
|
+
# # => <li><i class="mi mi-check mi-li"></i> Bulleted list item</li>
|
32
|
+
#
|
33
|
+
# If you want to use outline font style simply add -o to font name.
|
34
|
+
def mi_icon(names = 'flag', original_options = {})
|
35
|
+
options = original_options.deep_dup
|
36
|
+
classes = ['mi']
|
37
|
+
classes.concat Private.icon_names(names)
|
38
|
+
classes.concat Array(options.delete(:class))
|
39
|
+
text = options.delete(:text)
|
40
|
+
right_icon = options.delete(:right)
|
41
|
+
# outline icons end with -o suffix
|
42
|
+
if classes[1].match(/\-o/)
|
43
|
+
classes[0] = 'mi-o'
|
44
|
+
classes[1].sub!('-o', '')
|
45
|
+
end
|
46
|
+
# replace - with _ in icon name for compatibility with font awesome
|
47
|
+
classes[1].gsub!('-', '_').sub!('mi_', 'mi-')
|
48
|
+
|
49
|
+
icon = content_tag(:i, nil, options.merge(class: classes))
|
50
|
+
Private.icon_join(icon, text, right_icon)
|
51
|
+
end
|
52
|
+
alias fa_icon mi_icon
|
53
|
+
|
54
|
+
# Creates an stack set of icon tags given a base icon name, a main icon
|
55
|
+
# name, and possible icon modifiers.
|
56
|
+
#
|
57
|
+
# Examples
|
58
|
+
#
|
59
|
+
# mi_stacked_icon "twitter", base: "square-o"
|
60
|
+
# # => <span class="mi-stack">
|
61
|
+
# # => <i class="mi mi-square-o mi-stack-2x"></i>
|
62
|
+
# # => <i class="mi mi-twitter mi-stack-1x"></i>
|
63
|
+
# # => </span>
|
64
|
+
#
|
65
|
+
# mi_stacked_icon "terminal inverse", base: "square", class: "pull-right", text: "Hi!"
|
66
|
+
# # => <span class="mi-stack pull-right">
|
67
|
+
# # => <i class="mi mi-square mi-stack-2x"></i>
|
68
|
+
# # => <i class="mi mi-terminal mi-inverse mi-stack-1x"></i>
|
69
|
+
# # => </span> Hi!
|
70
|
+
#
|
71
|
+
# mi_stacked_icon "camera", base: "ban-circle", reverse: true
|
72
|
+
# # => <span class="mi-stack">
|
73
|
+
# # => <i class="mi mi-camera mi-stack-1x"></i>
|
74
|
+
# # => <i class="mi mi-ban-circle mi-stack-2x"></i>
|
75
|
+
# # => </span>
|
76
|
+
def mi_stacked_icon(names = 'flag', original_options = {})
|
77
|
+
options = original_options.deep_dup
|
78
|
+
classes = Private.icon_names('stack').concat(Array(options.delete(:class)))
|
79
|
+
base_names = Private.array_value(options.delete(:base) || 'square-o').push('stack-2x')
|
80
|
+
names = Private.array_value(names).push('stack-1x')
|
81
|
+
base = mi_icon(base_names, options.delete(:base_options) || {})
|
82
|
+
icon = mi_icon(names, options.delete(:icon_options) || {})
|
83
|
+
icons = [base, icon]
|
84
|
+
icons.reverse! if options.delete(:reverse)
|
85
|
+
text = options.delete(:text)
|
86
|
+
right_icon = options.delete(:right)
|
87
|
+
stacked_icon = content_tag(:span, safe_join(icons), options.merge(class: classes))
|
88
|
+
Private.icon_join(stacked_icon, text, right_icon)
|
89
|
+
end
|
90
|
+
alias fa_stacked_icon mi_stacked_icon
|
91
|
+
|
92
|
+
module Private
|
93
|
+
extend ActionView::Helpers::OutputSafetyHelper
|
94
|
+
|
95
|
+
def self.icon_join(icon, text, reverse_order = false)
|
96
|
+
return icon if text.blank?
|
97
|
+
elements = [icon, ERB::Util.html_escape(text)]
|
98
|
+
elements.reverse! if reverse_order
|
99
|
+
safe_join(elements, ' ')
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.icon_names(names = [])
|
103
|
+
array_value(names).map { |n| "mi-#{n}" }
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.array_value(value = [])
|
107
|
+
value.is_a?(Array) ? value : value.to_s.split(/\s+/)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,284 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2022- Damjan Rems
|
3
|
+
*/
|
4
|
+
@font-face {
|
5
|
+
font-family: MI;
|
6
|
+
font-style: normal;
|
7
|
+
font-weight: 400;
|
8
|
+
src: url('material-icons-regular.woff2') format('woff2')
|
9
|
+
}
|
10
|
+
|
11
|
+
@font-face {
|
12
|
+
font-family: MI-O;
|
13
|
+
font-style: normal;
|
14
|
+
font-weight: 400;
|
15
|
+
src: url('material-icons-outline.woff2') format('woff2')
|
16
|
+
}
|
17
|
+
|
18
|
+
.mi, .fa {
|
19
|
+
font-family: MI;
|
20
|
+
}
|
21
|
+
.mi-o {
|
22
|
+
font-family: MI-O;
|
23
|
+
}
|
24
|
+
|
25
|
+
.mi, .mi-o, .fa {
|
26
|
+
font-size: 24px;
|
27
|
+
font-weight: normal;
|
28
|
+
font-style: normal;
|
29
|
+
vertical-align: middle;
|
30
|
+
display: inline-block;
|
31
|
+
width: initial;
|
32
|
+
height: 1em;
|
33
|
+
text-transform: none;
|
34
|
+
|
35
|
+
/* Support for all WebKit browsers. */
|
36
|
+
-webkit-font-smoothing: antialiased;
|
37
|
+
/* Support for Safari and Chrome. */
|
38
|
+
text-rendering: optimizeLegibility;
|
39
|
+
/* Support for Firefox. */
|
40
|
+
-moz-osx-font-smoothing: grayscale;
|
41
|
+
}
|
42
|
+
|
43
|
+
/* Rules for sizing the icon. */
|
44
|
+
.mi-md-18 { font-size: 18px; }
|
45
|
+
.mi-md-24 { font-size: 24px; }
|
46
|
+
.mi-md-36 { font-size: 36px; }
|
47
|
+
.mi-md-48 { font-size: 48px; }
|
48
|
+
|
49
|
+
/* Rules for using icons as black on a light background. */
|
50
|
+
.mi-md-dark { color: rgba(0, 0, 0, 0.54); }
|
51
|
+
.mi-md-dark.md-inactive { color: rgba(0, 0, 0, 0.26); }
|
52
|
+
|
53
|
+
/* Rules for using icons as white on a dark background. */
|
54
|
+
.mi-md-light { color: rgba(255, 255, 255, 1); }
|
55
|
+
.mi-md-inactive { color: rgba(255, 255, 255, 0.3); }
|
56
|
+
|
57
|
+
/* Rules to rotate items */
|
58
|
+
.mi-r90 {
|
59
|
+
transform: rotate(90deg);
|
60
|
+
}
|
61
|
+
.mi-r180 {
|
62
|
+
transform: rotate(180deg);
|
63
|
+
}
|
64
|
+
.mi-r270 {
|
65
|
+
transform: rotate(270deg);
|
66
|
+
}
|
67
|
+
.mi-flip-horizontal {
|
68
|
+
transform: scale(-1, 1);
|
69
|
+
}
|
70
|
+
.mi-flip-vertical {
|
71
|
+
transform: scale(1, -1);
|
72
|
+
}
|
73
|
+
|
74
|
+
/* old fa- settings and mi- replacements */
|
75
|
+
.mi-lg, .fa-lg {
|
76
|
+
font-size: 32px;
|
77
|
+
}
|
78
|
+
.mi-2x, .fa-2x {
|
79
|
+
font-size: 48px;
|
80
|
+
}
|
81
|
+
.mi-3x, .fa-3x {
|
82
|
+
font-size: 72px;
|
83
|
+
}
|
84
|
+
.mi-4x, .fa-4x {
|
85
|
+
font-size: 96px;
|
86
|
+
}
|
87
|
+
.mi-5x, .fa-5x {
|
88
|
+
font-size: 120px;
|
89
|
+
}
|
90
|
+
.mi-ul, .fa-ul {
|
91
|
+
padding-left: 0;
|
92
|
+
margin-left: 2.14285714em;
|
93
|
+
list-style-type: none;
|
94
|
+
}
|
95
|
+
.mi-ul > li, .fa-ul > li {
|
96
|
+
position: relative;
|
97
|
+
}
|
98
|
+
.mi-li, .fa-li {
|
99
|
+
position: absolute;
|
100
|
+
left: -2.14285714em;
|
101
|
+
width: 2.14285714em;
|
102
|
+
top: 0.14285714em;
|
103
|
+
text-align: center;
|
104
|
+
}
|
105
|
+
.mi-li.mi-lg, .fa-li.fa-lg {
|
106
|
+
left: -1.85714286em;
|
107
|
+
}
|
108
|
+
.mi-border, .fa-border {
|
109
|
+
padding: .2em .25em .15em;
|
110
|
+
border: solid 0.08em #eeeeee;
|
111
|
+
border-radius: .1em;
|
112
|
+
}
|
113
|
+
.mi-pull-left, .fa-pull-left {
|
114
|
+
float: left;
|
115
|
+
}
|
116
|
+
.mi-pull-right, .fa-pull-right {
|
117
|
+
float: right;
|
118
|
+
}
|
119
|
+
.mi.mi-pull-left, .fa.fa-pull-left {
|
120
|
+
margin-right: .3em;
|
121
|
+
}
|
122
|
+
.mi.mi-pull-right, .fa.fa-pull-right {
|
123
|
+
margin-left: .3em;
|
124
|
+
}
|
125
|
+
|
126
|
+
.mi.pull-left, .fa.pull-left {
|
127
|
+
margin-right: .3em;
|
128
|
+
}
|
129
|
+
.mi.pull-right .fa.pull-right {
|
130
|
+
margin-left: .3em;
|
131
|
+
}
|
132
|
+
.mi-spin, .fa-spin {
|
133
|
+
-webkit-animation: fa-spin 1.5s infinite linear;
|
134
|
+
animation: fa-spin 1.5s infinite linear;
|
135
|
+
}
|
136
|
+
.mi-pulse, .fa-pulse {
|
137
|
+
-webkit-animation: fa-spin 1s infinite steps(8);
|
138
|
+
animation: fa-spin 1s infinite steps(8);
|
139
|
+
}
|
140
|
+
|
141
|
+
@-webkit-keyframes fa-spin {
|
142
|
+
0% {
|
143
|
+
-webkit-transform: rotate(0deg);
|
144
|
+
transform: rotate(0deg);
|
145
|
+
}
|
146
|
+
100% {
|
147
|
+
-webkit-transform: rotate(359deg);
|
148
|
+
transform: rotate(359deg);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
@-webkit-keyframes mi-spin {
|
152
|
+
0% {
|
153
|
+
-webkit-transform: rotate(0deg);
|
154
|
+
transform: rotate(0deg);
|
155
|
+
}
|
156
|
+
100% {
|
157
|
+
-webkit-transform: rotate(359deg);
|
158
|
+
transform: rotate(359deg);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
@keyframes fa-spin {
|
163
|
+
0% {
|
164
|
+
-webkit-transform: rotate(0deg);
|
165
|
+
transform: rotate(0deg);
|
166
|
+
}
|
167
|
+
100% {
|
168
|
+
-webkit-transform: rotate(359deg);
|
169
|
+
transform: rotate(359deg);
|
170
|
+
}
|
171
|
+
}
|
172
|
+
@keyframes mi-spin {
|
173
|
+
0% {
|
174
|
+
-webkit-transform: rotate(0deg);
|
175
|
+
transform: rotate(0deg);
|
176
|
+
}
|
177
|
+
100% {
|
178
|
+
-webkit-transform: rotate(359deg);
|
179
|
+
transform: rotate(359deg);
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
.mi-rotate-90, .fa-rotate-90 {
|
184
|
+
transform: rotate(90deg);
|
185
|
+
}
|
186
|
+
.mi-rotate-180, .fa-rotate-180 {
|
187
|
+
transform: rotate(180deg);
|
188
|
+
}
|
189
|
+
.mi-rotate-270, .fa-rotate-270 {
|
190
|
+
transform: rotate(270deg);
|
191
|
+
}
|
192
|
+
.mi-flip-horizontal, .fa-flip-horizontal {
|
193
|
+
transform: scale(-1, 1);
|
194
|
+
}
|
195
|
+
.mi-flip-vertical, .fa-flip-vertical {
|
196
|
+
transform: scale(1, -1);
|
197
|
+
}
|
198
|
+
:root .fa-rotate-90,
|
199
|
+
:root .fa-rotate-180,
|
200
|
+
:root .fa-rotate-270,
|
201
|
+
:root .fa-flip-horizontal,
|
202
|
+
:root .fa-flip-vertical,
|
203
|
+
:root .mi-rotate-90,
|
204
|
+
:root .mi-rotate-180,
|
205
|
+
:root .mi-rotate-270,
|
206
|
+
:root .mi-flip-horizontal,
|
207
|
+
:root .mi-flip-vertical {
|
208
|
+
filter: none;
|
209
|
+
}
|
210
|
+
.mi-stack, .fa-stack {
|
211
|
+
position: relative;
|
212
|
+
display: inline-block;
|
213
|
+
width: 2em;
|
214
|
+
height: 2em;
|
215
|
+
line-height: 2em;
|
216
|
+
vertical-align: middle;
|
217
|
+
}
|
218
|
+
.fa-stack-1x,
|
219
|
+
.fa-stack-2x,
|
220
|
+
.mi-stack-1x,
|
221
|
+
.mi-stack-2x {
|
222
|
+
position: absolute;
|
223
|
+
left: 0;
|
224
|
+
width: 100%;
|
225
|
+
text-align: center;
|
226
|
+
}
|
227
|
+
.mi-stack-1x, .fa-stack-1x {
|
228
|
+
line-height: inherit;
|
229
|
+
}
|
230
|
+
.mi-stack-2x, .fa-stack-2x {
|
231
|
+
font-size: 2em;
|
232
|
+
}
|
233
|
+
.mi-inverse, .fa-inverse {
|
234
|
+
color: #ffffff;
|
235
|
+
}
|
236
|
+
|
237
|
+
/* fa icons replacements */
|
238
|
+
.mi-user:before {content: '\e7fd';}
|
239
|
+
.mi-users:before {content: '\e7fc';}
|
240
|
+
.mi-bars:before {content: '\e5d2';}
|
241
|
+
.mi-file_excel:before {content: '\e2c4'}
|
242
|
+
.mi-cog:before {content: '\e8b8';}
|
243
|
+
.mi-envelope:before {content: '\e0e1';}
|
244
|
+
.mi-square:before {content: '\e834';}
|
245
|
+
.mi-check_square:before {content: '\e835';}
|
246
|
+
.mi-plus:before {content: '\e145';}
|
247
|
+
.mi-frown:before {content: '\e811';}
|
248
|
+
.mi-thumbs_up:before {content: '\e8dc';}
|
249
|
+
.mi-thumbs_down:before {content: '\e8db';}
|
250
|
+
.mi-mobile:before {content: '\e32c';}
|
251
|
+
.mi-eye:before {content: '\e8f4';}
|
252
|
+
.mi-question:before {content: '\eb8b';}
|
253
|
+
.mi-question_circle:before {content: '\e887';}
|
254
|
+
.mi-calendar:before {content: '\ebcc';}
|
255
|
+
.mi-table:before {content: '\f101';}
|
256
|
+
.mi-sliders:before {content: '\e429';}
|
257
|
+
.mi-file_text:before {content: '\e873';}
|
258
|
+
.mi-trash:before {content: '\e92e';}
|
259
|
+
.mi-caret_down:before {content: '\e5c5';}
|
260
|
+
.mi-sort_unset:before {content: '\ef4f';}
|
261
|
+
.mi-sort_up:before {content: '\e5db';}
|
262
|
+
.mi-sort_down:before {content: '\e5d8';}
|
263
|
+
.mi-arrow_right:before {content: '\e5c8';}
|
264
|
+
.mi-arrow_left:before {content: '\e5c4';}
|
265
|
+
.mi-clock:before {content: '\e8b5';}
|
266
|
+
.mi-calculator:before {content: '\ea5f';}
|
267
|
+
.mi-car:before {content: '\e531';}
|
268
|
+
.mi-plus_square:before {content: '\e146';}
|
269
|
+
.mi-paperclip:before {content: '\e226';}
|
270
|
+
.mi-sign_in:before {content: '\ea77';}
|
271
|
+
.mi-sign_out:before {content: '\e9ba';}
|
272
|
+
.mi-check_circle:before {content: '\e86c';}
|
273
|
+
.mi-plus_circle:before {content: '\e147';}
|
274
|
+
.mi-cogs:before {content: '\ea3d';}
|
275
|
+
.mi-table:before {font-family: MI-O; content: '\f101';}
|
276
|
+
.mi-arrow_up:before {content: '\e5d8';}
|
277
|
+
.mi-arrow_down:before {content: '\e5db';}
|
278
|
+
.mi-window_close:before {content: '\e0e9';}
|
279
|
+
.mi-chevron_down:before {content: '\e5cf';}
|
280
|
+
.mi-chevron_up:before {content: '\e5ce';}
|
281
|
+
.mi-angle_down:before {content: '\e5cf'; font-size: 18px}
|
282
|
+
.mi-angle_up:before {content: '\e5ce'; font-size: 18px}
|
283
|
+
.mi-times:before {content: '\e5cd'}
|
284
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class DrgMaterialIconsUpdateGenerator < Rails::Generators::Base
|
2
|
+
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
desc "This generator creates app/assets/stylesheets/drg_material_icons.css"
|
5
|
+
|
6
|
+
###########################################################################
|
7
|
+
# Will create output and save it to form filename.
|
8
|
+
###########################################################################
|
9
|
+
def create_css_file
|
10
|
+
@cp_dir = File.dirname(__FILE__)
|
11
|
+
@css_dir = File.expand_path('../../../../app/assets/stylesheets', __FILE__)
|
12
|
+
css = common_css + build_css
|
13
|
+
create_file "#{@css_dir}/drg_material_icons.css", css
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
###########################################################################
|
18
|
+
#
|
19
|
+
###########################################################################
|
20
|
+
def common_css
|
21
|
+
File.read("#{@cp_dir}/common.css")
|
22
|
+
end
|
23
|
+
|
24
|
+
###########################################################################
|
25
|
+
#
|
26
|
+
###########################################################################
|
27
|
+
def build_css
|
28
|
+
icons = {}
|
29
|
+
File.readlines("#{@cp_dir}/material-icons-outline.codepoints").each do |line|
|
30
|
+
name, code = line.chomp.split(' ')
|
31
|
+
icons[name] = code
|
32
|
+
end
|
33
|
+
|
34
|
+
File.readlines("#{@cp_dir}/material-icons-regular.codepoints").each do |line|
|
35
|
+
name, code = line.chomp.split(' ')
|
36
|
+
icons[name] = code if icons[name].nil?
|
37
|
+
end
|
38
|
+
icons.inject('') { |r, icon| r << %(.mi-#{icon.first}:before {content: '\\#{icon.last}';}\n) }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|