/
icons_helper.rb
132 lines (105 loc) · 2.41 KB
/
icons_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# frozen_string_literal: true
module IconsHelper
include FontAwesome::Sass::Rails::ViewHelpers
def icon_for_model(event_model)
send("#{event_model}_icon")
end
def cute_icon
icons = %w(slug sprinkler bee ant hose grass rabbit slug-eating snail earth-worm insect watering-can
wheelbarrow cat spiderweb bug butterfly ladybird stones)
rand_num = rand(1..icons.size)
icon = icons[rand_num - 1]
image_tag("icons/#{icon}.svg", 'aria-hidden' => "true", class: 'img img-cute', alt: icon)
end
def timeline_icon
image_icon 'timeline'
end
def garden_icon
image_icon 'gardens'
end
def planting_icon
image_icon 'planting'
end
def member_icon
icon('far', 'user')
end
def harvest_icon
image_icon 'harvest'
end
def growing_icon
image_icon 'growing'
end
def seed_icon
image_icon 'seeds'
end
def comment_icon
icon('far', 'comment')
end
def finished_icon
image_icon 'finish'
end
def edit_icon
image_icon 'edit'
end
def delete_icon
image_icon 'delete'
end
def add_photo_icon
image_icon 'add-photo'
end
def photo_icon
image_icon 'photo'
end
def seedling_icon
icon('fas', 'seedling')
end
def activity_icon
icon('fas', 'fa-truck-pickup')
end
def post_icon
image_icon 'post'
end
def perennial_icon
icon('fas', 'tree')
end
def planted_from_icon(planted_from)
planted_from
end
def delete_association_icon
icon('fas', 'backspace')
end
def like_icon
icon('fas', 'heart')
end
def plant_part_icon(name)
if File.exist? Rails.root.join('app', 'assets', 'images', 'icons', 'plant_parts', "#{name}.svg")
image_tag "icons/plant_parts/#{name}.svg", class: 'img img-icon', 'aria-hidden' => "true", alt: name
else
planting_icon
end
end
def crop_icon(crop)
if crop.svg_icon.present?
image_tag(crop_path(crop, format: 'svg'), class: 'crop-icon', alt: crop)
elsif crop.parent.present?
crop_icon(crop.parent)
else
planting_icon
end
end
def sunniness_icon(sunniness)
case sunniness
when 'sun'
icon 'far', 'sun'
when 'shade'
icon 'fas', 'umbrella-beach'
when 'semi-shade'
icon 'fas', 'cloud-sun'
else
icon 'fas', 'question'
end
end
def image_icon(icon)
image_tag "icons/#{icon}.svg", class: 'img img-icon', 'aria-hidden' => "true", alt: icon
end
end