Module: CoPlan::ApplicationHelper

Defined in:
app/helpers/coplan/application_helper.rb

Constant Summary collapse

FAVICON_COLORS =
{
  "production"  => { start: "#3B82F6", stop: "#1E40AF" },
  "staging"     => { start: "#F59E0B", stop: "#D97706" },
  "development" => { start: "#10B981", stop: "#047857" },
}.freeze

Instance Method Summary collapse

Instance Method Details

#coplan_environment_badgeObject



40
41
42
43
44
45
46
# File 'app/helpers/coplan/application_helper.rb', line 40

def coplan_environment_badge
  return if Rails.env.production?

  label = Rails.env.capitalize
  colors = FAVICON_COLORS.fetch(Rails.env, FAVICON_COLORS["development"])
  tag.span(label, class: "env-badge", style: "background: #{colors[:start]};")
end

#coplan_favicon_tagObject



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
# File 'app/helpers/coplan/application_helper.rb', line 9

def coplan_favicon_tag
  colors = FAVICON_COLORS.fetch(Rails.env, FAVICON_COLORS["development"])
  svg = "    <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 100 100\">\n      <defs>\n        <linearGradient id=\"g\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\">\n          <stop offset=\"0%\" stop-color=\"\#{colors[:start]}\"/>\n          <stop offset=\"100%\" stop-color=\"\#{colors[:stop]}\"/>\n        </linearGradient>\n      </defs>\n      <rect width=\"100\" height=\"100\" rx=\"22\" fill=\"url(#g)\"/>\n      <g opacity=\".25\" fill=\"none\" stroke=\"#fff\" stroke-width=\"2\" stroke-linecap=\"round\">\n        <line x1=\"16\" y1=\"18\" x2=\"84\" y2=\"18\"/>\n        <line x1=\"16\" y1=\"28\" x2=\"84\" y2=\"28\"/>\n        <line x1=\"16\" y1=\"38\" x2=\"84\" y2=\"38\"/>\n        <line x1=\"16\" y1=\"48\" x2=\"84\" y2=\"48\"/>\n        <line x1=\"16\" y1=\"58\" x2=\"84\" y2=\"58\"/>\n        <line x1=\"16\" y1=\"68\" x2=\"84\" y2=\"68\"/>\n        <line x1=\"16\" y1=\"78\" x2=\"84\" y2=\"78\"/>\n      </g>\n      <circle cx=\"40\" cy=\"46\" r=\"22\" fill=\"#fff\" opacity=\".55\"/>\n      <path d=\"M26,62 L18,78 L36,66 Z\" fill=\"#fff\" opacity=\".55\"/>\n      <circle cx=\"62\" cy=\"54\" r=\"22\" fill=\"#fff\" opacity=\".55\"/>\n      <path d=\"M76,70 L84,84 L68,72 Z\" fill=\"#fff\" opacity=\".55\"/>\n    </svg>\n  SVG\n\n  data_uri = \"data:image/svg+xml,\#{ERB::Util.url_encode(svg.strip)}\"\n  tag.link(rel: \"icon\", type: \"image/svg+xml\", href: data_uri)\nend\n"