font-awesome-propshaft 1.0.1
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 +7 -0
- data/LICENSE +201 -0
- data/README.md +146 -0
- data/Rakefile +12 -0
- data/app/assets/fonts/fa-brands-400.ttf +0 -0
- data/app/assets/fonts/fa-brands-400.woff2 +0 -0
- data/app/assets/fonts/fa-regular-400.ttf +0 -0
- data/app/assets/fonts/fa-regular-400.woff2 +0 -0
- data/app/assets/fonts/fa-solid-900.ttf +0 -0
- data/app/assets/fonts/fa-solid-900.woff2 +0 -0
- data/app/assets/fonts/fa-v4compatibility.ttf +0 -0
- data/app/assets/fonts/fa-v4compatibility.woff2 +0 -0
- data/app/assets/stylesheets/font-awesome-propshaft.css +8004 -0
- data/app/helpers/font_awesome_propshaft/rails/icon_helper.rb +100 -0
- data/lib/font-awesome-propshaft/engine.rb +6 -0
- data/lib/font-awesome-propshaft/version.rb +6 -0
- data/lib/font-awesome-propshaft.rb +2 -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/controllers/pages_controller.rb +2 -0
- data/test/dummy/app/views/pages/icons.html.erb +3 -0
- data/test/dummy/config/application.rb +17 -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 +16 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/log/test.log +15419 -0
- data/test/dummy/tmp/local_secret.txt +1 -0
- data/test/font_awesome_propshaft_rails_test.rb +93 -0
- data/test/icon_helper_test.rb +138 -0
- data/test/test_helper.rb +7 -0
- metadata +135 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
module FontAwesomePropshaft
|
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
|
+
# fa_icon "camera-retro"
|
10
|
+
# # => <i class="fa fa-camera-retro"></i>
|
11
|
+
#
|
12
|
+
# fa_icon "camera-retro", text: "Take a photo"
|
13
|
+
# # => <i class="fa fa-camera-retro"></i> Take a photo
|
14
|
+
# fa_icon "chevron-right", text: "Get started", right: true
|
15
|
+
# # => Get started <i class="fa fa-chevron-right"></i>
|
16
|
+
#
|
17
|
+
# fa_icon "camera-retro 2x"
|
18
|
+
# # => <i class="fa fa-camera-retro fa-2x"></i>
|
19
|
+
# fa_icon ["camera-retro", "4x"]
|
20
|
+
# # => <i class="fa fa-camera-retro fa-4x"></i>
|
21
|
+
# fa_icon "spinner spin lg"
|
22
|
+
# # => <i class="fa fa-spinner fa-spin fa-lg">
|
23
|
+
#
|
24
|
+
# fa_icon "quote-left 4x", class: "pull-left"
|
25
|
+
# # => <i class="fa fa-quote-left fa-4x pull-left"></i>
|
26
|
+
#
|
27
|
+
# fa_icon "user", data: { id: 123 }
|
28
|
+
# # => <i class="fa fa-user" data-id="123"></i>
|
29
|
+
#
|
30
|
+
# content_tag(:li, fa_icon("check li", text: "Bulleted list item"))
|
31
|
+
# # => <li><i class="fa fa-check fa-li"></i> Bulleted list item</li>
|
32
|
+
def fa_icon(names = "flag", original_options = {})
|
33
|
+
options = original_options.deep_dup
|
34
|
+
classes = ["fa"]
|
35
|
+
classes.concat Private.icon_names(names)
|
36
|
+
classes.concat Array(options.delete(:class))
|
37
|
+
text = options.delete(:text)
|
38
|
+
right_icon = options.delete(:right)
|
39
|
+
icon = content_tag(:i, nil, options.merge(:class => classes))
|
40
|
+
Private.icon_join(icon, text, right_icon)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creates an stack set of icon tags given a base icon name, a main icon
|
44
|
+
# name, and possible icon modifiers.
|
45
|
+
#
|
46
|
+
# Examples
|
47
|
+
#
|
48
|
+
# fa_stacked_icon "twitter", base: "square-o"
|
49
|
+
# # => <span class="fa-stack">
|
50
|
+
# # => <i class="fa fa-square-o fa-stack-2x"></i>
|
51
|
+
# # => <i class="fa fa-twitter fa-stack-1x"></i>
|
52
|
+
# # => </span>
|
53
|
+
#
|
54
|
+
# fa_stacked_icon "terminal inverse", base: "square", class: "pull-right", text: "Hi!"
|
55
|
+
# # => <span class="fa-stack pull-right">
|
56
|
+
# # => <i class="fa fa-square fa-stack-2x"></i>
|
57
|
+
# # => <i class="fa fa-terminal fa-inverse fa-stack-1x"></i>
|
58
|
+
# # => </span> Hi!
|
59
|
+
#
|
60
|
+
# fa_stacked_icon "camera", base: "ban-circle", reverse: true
|
61
|
+
# # => <span class="fa-stack">
|
62
|
+
# # => <i class="fa fa-camera fa-stack-1x"></i>
|
63
|
+
# # => <i class="fa fa-ban-circle fa-stack-2x"></i>
|
64
|
+
# # => </span>
|
65
|
+
def fa_stacked_icon(names = "flag", original_options = {})
|
66
|
+
options = original_options.deep_dup
|
67
|
+
classes = Private.icon_names("stack").concat(Array(options.delete(:class)))
|
68
|
+
base_names = Private.array_value(options.delete(:base) || "square-o").push("stack-2x")
|
69
|
+
names = Private.array_value(names).push("stack-1x")
|
70
|
+
base = fa_icon(base_names, options.delete(:base_options) || {})
|
71
|
+
icon = fa_icon(names, options.delete(:icon_options) || {})
|
72
|
+
icons = [base, icon]
|
73
|
+
icons.reverse! if options.delete(:reverse)
|
74
|
+
text = options.delete(:text)
|
75
|
+
right_icon = options.delete(:right)
|
76
|
+
stacked_icon = content_tag(:span, safe_join(icons), options.merge(:class => classes))
|
77
|
+
Private.icon_join(stacked_icon, text, right_icon)
|
78
|
+
end
|
79
|
+
|
80
|
+
module Private
|
81
|
+
extend ActionView::Helpers::OutputSafetyHelper
|
82
|
+
|
83
|
+
def self.icon_join(icon, text, reverse_order = false)
|
84
|
+
return icon if text.blank?
|
85
|
+
elements = [icon, ERB::Util.html_escape(text)]
|
86
|
+
elements.reverse! if reverse_order
|
87
|
+
safe_join(elements, " ")
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.icon_names(names = [])
|
91
|
+
array_value(names).map { |n| "fa-#{n}" }
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.array_value(value = [])
|
95
|
+
value.is_a?(Array) ? value : value.to_s.split(/\s+/)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
@import font-awesome-propshaft
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "font-awesome-propshaft";
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "rails/all"
|
4
|
+
require "propshaft"
|
5
|
+
|
6
|
+
Bundler.require(:default, :development)
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
config.encoding = "utf-8"
|
11
|
+
|
12
|
+
# replacement for environments/*.rb
|
13
|
+
config.active_support.deprecation = :stderr
|
14
|
+
config.eager_load = false
|
15
|
+
config.active_support.test_order = :random rescue nil
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
#
|
8
|
+
# avoid deprecation warnings if building against older versions of Rails
|
9
|
+
|
10
|
+
# secret_token migrated to secret_key_base in Rails 4
|
11
|
+
SKB_VERSION = Gem::Version.new('4.0.0')
|
12
|
+
|
13
|
+
# Get the current Rails version.
|
14
|
+
RAILS_VERSION = Rails.respond_to?(:version) ? Gem::Version.new(Rails.version) : Gem::Version.new('3.22')
|
15
|
+
|
16
|
+
|