Module: Decidim::Design::TabPanelsHelper

Defined in:
decidim-design/app/helpers/decidim/design/tab_panels_helper.rb

Instance Method Summary collapse

Instance Method Details

#tab_panels_itemsObject



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'decidim-design/app/helpers/decidim/design/tab_panels_helper.rb', line 106

def tab_panels_items
  [
    {
      enabled: true,
      id: "button",
      text: "Button",
      icon: resource_type_icon_key("images"),
      method: :cell,
      args: ["decidim/button", { text: t("decidim.design.helpers.send") }]
    },
    {
      enabled: true,
      id: "announce",
      text: "Announcement",
      icon: resource_type_icon_key("documents"),
      method: :cell,
      args: ["decidim/announcement", t("decidim.design.components.announcement.iam_an_announcement")]
    }
  ]
end

#tab_panels_items_altObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'decidim-design/app/helpers/decidim/design/tab_panels_helper.rb', line 127

def tab_panels_items_alt
  [
    {
      enabled: true,
      id: "icon",
      text: "Icon",
      method: :icon,
      args: ["question-line", { class: "w-4 h-4" }]
    },
    {
      enabled: true,
      id: "text",
      text: "Plain",
      method: :content_tag,
      args: ["p", "plain text", { class: "text-left" }]
    }
  ]
end

#tab_panels_sectionsObject



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
# File 'decidim-design/app/helpers/decidim/design/tab_panels_helper.rb', line 6

def tab_panels_sections
  [
    {
      id: "context",
      title: t("decidim.design.helpers.context"),
      contents: [
        {
          type: :text,
          values: [
            t("decidim.design.helpers.tab_panels_context_description"),
            t("decidim.design.helpers.tab_panels_context_description_html")
          ]
        }
      ]
    },
    {
      id: "usage",
      title: t("decidim.design.helpers.usage"),
      contents: [
        {
          type: :text,
          values: [
            t("decidim.design.helpers.tab_panels_usage_description"),
            t("decidim.design.helpers.tab_panels_usage_description_html"),
            t("decidim.design.helpers.tab_panels_usage_description_id_html"),
            t("decidim.design.helpers.tab_panels_usage_description_tab_html"),
            t("decidim.design.helpers.tab_panels_usage_description_remixicon_html"),
            t("decidim.design.helpers.tab_panels_usage_description_rails_html"),
            t("decidim.design.helpers.tab_panels_usage_description_arguments_html")
          ]
        },
        {
          type: :table,
          options: { headings: %w(Display Values), style: "--cell-width: 50%;" },
          items: tab_panels_table(
            { values: tab_panels_items },
            { values: tab_panels_items_alt }
          ),
          cell_snippet: {
            cell: "decidim/tab_panels",
            args: [tab_panels_items],
            call_string: [<<-TEXT1, <<-TEXT2]
  cell(
"decidim/tab_panels",
[
  {
    enabled: true,
    id: "icon",
    text: "Icon",
    method: :icon,
    args: ["question-line", { class: "w-4 h-4" }]
  },
  {
    enabled: true,
    id: "text",
    text: "Plain",
    method: :content_tag,
    args: ["p", "plain text", { class: "text-left" }]
  }
]
    )
            TEXT2
          }
        }
      ]
    }
  ]
end

#tab_panels_table(*table_rows, **_opts) ⇒ Object



97
98
99
100
101
102
103
104
# File 'decidim-design/app/helpers/decidim/design/tab_panels_helper.rb', line 97

def tab_panels_table(*table_rows, **_opts)
  table_rows.each_with_index.map do |table_cell, _ix|
    row = []
    row << { method: :cell, args: ["decidim/tab_panels", table_cell[:values]] }
    row << (:pre, (:code, JSON.pretty_generate(table_cell[:values])), class: "text-left")
    row
  end
end