fatcow 0.1.2 → 0.1.4
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 +3 -0
- data/lib/fatcow/helpers.rb +23 -2
- data/lib/fatcow/icon.rb +31 -7
- data/lib/fatcow/model.rb +17 -12
- data/lib/fatcow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ce51b7283b6d2b8fdbcc0186ecbf52ded0d45e5dc0eb52728bed6be9ca616c5
|
|
4
|
+
data.tar.gz: a417404eb455ab6c5af6d9f651b4e83325193c878dda9462764feae569d1511d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7521fdb3002cfb91f5ed976d47876cd3f1c5cfe537d6bb0f95eaa32157792521c089b1697e0b8eedc1dbd1c1c66fa86e90d3f48207cd96decd73fd84ed62eed7
|
|
7
|
+
data.tar.gz: '0896205527bf40cc57a76b9211f37e18ba81df2f7800a6c63d0a232f9d0fce03b22ae5cf6c96a5c5863184f9e0873c7a7bd0f3899a1b42081927da0df84d0e9f'
|
data/README.md
CHANGED
|
@@ -70,6 +70,9 @@ You cannot do this on collections, though that may be coming later.
|
|
|
70
70
|
<%= @alert.show_icon %>
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
## All Icons
|
|
74
|
+

|
|
75
|
+
|
|
73
76
|
## Licensing
|
|
74
77
|
|
|
75
78
|
FatCow web icons are licensed under
|
data/lib/fatcow/helpers.rb
CHANGED
|
@@ -11,8 +11,10 @@ module Fatcow
|
|
|
11
11
|
def fatcow_style_tag
|
|
12
12
|
content_tag :style do <<~CSS
|
|
13
13
|
.fatcow-icon {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
display: inline-block;
|
|
15
|
+
position: relative;
|
|
16
|
+
image-rendering: crisp-edges;
|
|
17
|
+
user-select: none;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
.fatcow-icon__bullet {
|
|
@@ -21,10 +23,29 @@ module Fatcow
|
|
|
21
23
|
left: 0;
|
|
22
24
|
transform: translate(25%, 25%);
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
.fatcow-icon > img:not(.fatcow-icon__bullet--hack) {
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
24
30
|
|
|
25
31
|
.fatcow-icon__bullet--pre-aligned {
|
|
26
32
|
transform: none;
|
|
27
33
|
}
|
|
34
|
+
|
|
35
|
+
.fatcow-icon--small .fatcow-icon__bullet--hack {
|
|
36
|
+
display: inline-block;
|
|
37
|
+
position: static;
|
|
38
|
+
transform: none;
|
|
39
|
+
margin-left: 4px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.fatcow-icon:not(.fatcow-icon--small) .fatcow-icon__bullet--hack {
|
|
43
|
+
transform: none;
|
|
44
|
+
bottom: 0;
|
|
45
|
+
right: 0;
|
|
46
|
+
top: initial;
|
|
47
|
+
left: initial;
|
|
48
|
+
}
|
|
28
49
|
CSS
|
|
29
50
|
end
|
|
30
51
|
end
|
data/lib/fatcow/icon.rb
CHANGED
|
@@ -4,12 +4,14 @@ require 'nokogiri'
|
|
|
4
4
|
|
|
5
5
|
module Fatcow
|
|
6
6
|
class Icon
|
|
7
|
-
attr_reader :name, :status, :app
|
|
7
|
+
attr_reader :name, :status, :app, :size
|
|
8
8
|
|
|
9
|
-
def initialize(app, name, status = nil)
|
|
9
|
+
def initialize(app, name, status = nil, **options)
|
|
10
10
|
@app = app
|
|
11
11
|
@name = name
|
|
12
12
|
@status = status
|
|
13
|
+
|
|
14
|
+
@size = options[:size] || :regular
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
def status=(new_status)
|
|
@@ -27,6 +29,11 @@ module Fatcow
|
|
|
27
29
|
clear_document
|
|
28
30
|
end
|
|
29
31
|
|
|
32
|
+
def size=(new_size)
|
|
33
|
+
@size = new_size
|
|
34
|
+
clear_document
|
|
35
|
+
end
|
|
36
|
+
|
|
30
37
|
def to_html
|
|
31
38
|
document.to_html.html_safe
|
|
32
39
|
end
|
|
@@ -45,22 +52,28 @@ module Fatcow
|
|
|
45
52
|
|
|
46
53
|
def asset_path
|
|
47
54
|
return base_icon_path unless status
|
|
48
|
-
"/assets/normal
|
|
55
|
+
"/assets/normal/#{subdirectory}/#{name}_#{status}.png" if status
|
|
49
56
|
end
|
|
50
57
|
|
|
51
58
|
def base_icon_path
|
|
52
|
-
"/assets/normal
|
|
59
|
+
"/assets/normal/#{subdirectory}/#{name}.png"
|
|
53
60
|
end
|
|
54
61
|
|
|
55
62
|
def bullet_icon_path
|
|
56
|
-
"/assets/normal/
|
|
63
|
+
return "/assets/normal/#{subdirectory}/bullet_#{status}.png" if bullet_exists?
|
|
64
|
+
"/assets/normal/FatCow_Icons16x16/#{status}.png"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def bullet_exists?
|
|
68
|
+
bullets = %i[archive attach back bell brush bug bulb_off bulb_on burn camera cd chart code_red code connect database document down dvd edit excel find flash gear lightning link magnify medal office palette php powerpoint table textfield up valid vector word world user blue purple pink red orange yellow green white black add delete go error key wrench toggle_minus toggle_plus feed picture disk star arrow_bottom arrow_down arrow_left_2 arrow_left arrow_right_2 arrow_right arrow_top arrow_up]
|
|
69
|
+
bullets.include? status
|
|
57
70
|
end
|
|
58
71
|
|
|
59
72
|
def document
|
|
60
73
|
return @document if @document
|
|
61
74
|
|
|
62
75
|
@document ||= Nokogiri::HTML::Builder.new do |doc|
|
|
63
|
-
doc.div(class:
|
|
76
|
+
doc.div(class: container_class) {
|
|
64
77
|
if status && composite?
|
|
65
78
|
doc.parent << Nokogiri::HTML.fragment(@app.image_tag(base_icon_path))
|
|
66
79
|
doc.parent << Nokogiri::HTML.fragment(@app.image_tag(bullet_icon_path, class: bullet_class))
|
|
@@ -77,10 +90,21 @@ module Fatcow
|
|
|
77
90
|
@document = nil
|
|
78
91
|
end
|
|
79
92
|
|
|
93
|
+
def container_class
|
|
94
|
+
return "fatcow-icon fatcow-icon--#{name}" if size == :regular
|
|
95
|
+
"fatcow-icon fatcow-icon--small fatcow-icon--#{name}"
|
|
96
|
+
end
|
|
97
|
+
|
|
80
98
|
def bullet_class
|
|
81
99
|
prealigned_bullets = %i[archive attach back bell brush bug bulb_off bulb_on burn camera cd chart code_red code connect database document down dvd edit excel find flash gear lightning link magnify medal office palette php powerpoint table textfield up valid vector word world user]
|
|
82
100
|
return 'fatcow-icon__bullet fatcow-icon__bullet--pre-aligned' if prealigned_bullets.include? status
|
|
83
|
-
return 'fatcow-icon__bullet'
|
|
101
|
+
return 'fatcow-icon__bullet' if bullet_exists?
|
|
102
|
+
'fatcow-icon__bullet fatcow-icon__bullet--hack'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def subdirectory
|
|
106
|
+
return 'FatCow_Icons32x32' if size == :regular
|
|
107
|
+
'FatCow_Icons16x16'
|
|
84
108
|
end
|
|
85
109
|
end
|
|
86
110
|
end
|
data/lib/fatcow/model.rb
CHANGED
|
@@ -16,33 +16,38 @@ module Fatcow
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
included do
|
|
19
|
-
def show_icon
|
|
20
|
-
current_state = find_icon_status(:FATCOW_ICON_SHOW_STATUSES)
|
|
19
|
+
def show_icon(**options)
|
|
20
|
+
current_state = find_icon_status(:FATCOW_ICON_SHOW_STATUSES, :DEFAULT_SHOW_STATUSES)
|
|
21
21
|
|
|
22
|
-
return custom_icon(current_state) if current_state
|
|
23
|
-
custom_icon(nil) if current_state.nil?
|
|
22
|
+
return custom_icon(current_state, **options) if current_state
|
|
23
|
+
custom_icon(nil, **options) if current_state.nil?
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def form_icon
|
|
27
|
-
current_state = find_icon_status(:FATCOW_ICON_FORM_STATUSES)
|
|
26
|
+
def form_icon(**options)
|
|
27
|
+
current_state = find_icon_status(:FATCOW_ICON_FORM_STATUSES, :DEFAULT_FORM_STATUSES)
|
|
28
28
|
|
|
29
|
-
return custom_icon(current_state) if current_state
|
|
30
|
-
custom_icon(nil) if current_state.nil?
|
|
29
|
+
return custom_icon(current_state, **options) if current_state
|
|
30
|
+
custom_icon(nil, **options) if current_state.nil?
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def find_icon_status(statuses_const_key)
|
|
33
|
+
def find_icon_status(statuses_const_key, fallback_const_key)
|
|
34
34
|
statuses = self.class.const_get statuses_const_key
|
|
35
|
+
fallback = self.class.const_get fallback_const_key
|
|
36
|
+
|
|
35
37
|
current_status = statuses.find { |status, proc| instance_exec(&proc) }
|
|
38
|
+
current_status = fallback.find { |status, proc| instance_exec(&proc) } if current_status.nil?
|
|
36
39
|
|
|
37
40
|
return nil if current_status.nil?
|
|
38
41
|
current_status[0]
|
|
39
42
|
end
|
|
40
43
|
|
|
41
|
-
def custom_icon(status)
|
|
44
|
+
def custom_icon(status, **options)
|
|
42
45
|
icon = self.class.const_get :FATCOW_ICON
|
|
43
46
|
|
|
44
47
|
icon.app = self if icon.app.nil?
|
|
45
48
|
icon.status = status if icon.status != status
|
|
49
|
+
icon.size = options[:size] if options[:size] && icon.size != options[:size]
|
|
50
|
+
icon.size = :regular unless options[:size] && icon.size != :regular
|
|
46
51
|
|
|
47
52
|
icon
|
|
48
53
|
end
|
|
@@ -51,8 +56,8 @@ module Fatcow
|
|
|
51
56
|
class_methods do
|
|
52
57
|
def has_icon (icon_name, **statuses)
|
|
53
58
|
const_set :FATCOW_ICON, Fatcow::Icon.new(nil, icon_name)
|
|
54
|
-
const_set :FATCOW_ICON_SHOW_STATUSES,
|
|
55
|
-
const_set :FATCOW_ICON_FORM_STATUSES,
|
|
59
|
+
const_set :FATCOW_ICON_SHOW_STATUSES, statuses[:show] || {}
|
|
60
|
+
const_set :FATCOW_ICON_FORM_STATUSES, statuses[:form] || {}
|
|
56
61
|
end
|
|
57
62
|
end
|
|
58
63
|
end
|
data/lib/fatcow/version.rb
CHANGED