Module: Fluxbit::ViewHelper

Defined in:
app/helpers/fluxbit/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#fx_body_classObject



5
6
7
# File 'app/helpers/fluxbit/view_helper.rb', line 5

def fx_body_class
  "h-full bg-slate-100 dark:bg-slate-900 dark:text-white"
end

#fx_sort_downObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/helpers/fluxbit/view_helper.rb', line 57

def fx_sort_down
   :svg, class: "size-4", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor" do
    concat(
      (
        :path,
        "",
        fill_rule: "evenodd",
        d: "M11.47 19.28a.75.75 0 0 1 1.06 0l3.75-3.75a.75.75 0 0 1-1.06-1.06L12 17.69l-3.22-3.22a.75.75 0 1 1-1.06 1.06l3.75 3.75Z",
        clip_rule: "evenodd"
      )
    )
  end
end

#fx_sort_field(field, url, label = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/fluxbit/view_helper.rb', line 9

def fx_sort_field(field, url, label = nil)
  order = (request.query_parameters[:order] || "").rpartition("_")

  order_direction = "asc"
  if order.first == field.to_s
    order_direction = order.last == "asc" ? "desc" : "asc"
  end

  link_to public_send(url, request.query_parameters.merge(order: "#{field}_#{order_direction}")), class: "order-#{order_direction} flex" do
    label_text = label || field.to_s.titlecase
    icon = if order.first == field.to_s
      order_direction == "asc" ? fx_sort_up : fx_sort_down
    else
      fx_sort_up_down
    end

    safe_join([ h(label_text), icon ], " ")
  end
end

#fx_sort_upObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/helpers/fluxbit/view_helper.rb', line 43

def fx_sort_up
   :svg, class: "size-4", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor" do
    concat(
      (
        :path,
        "",
        fill_rule: "evenodd",
        d: "M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Z",
        clip_rule: "evenodd"
      )
    )
  end
end

#fx_sort_up_downObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/helpers/fluxbit/view_helper.rb', line 29

def fx_sort_up_down
   :svg, class: "size-4", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor" do
    concat(
      (
        :path,
        "",
        fill_rule: "evenodd",
        d: "M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",
        clip_rule: "evenodd"
      )
    )
  end
end