okonomi_ui_kit 0.1.8 → 0.1.10
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 +50 -6
- data/app/assets/builds/okonomi_ui_kit/application.tailwind.css +508 -225
- data/app/helpers/okonomi_ui_kit/CLAUDE.md +619 -0
- data/app/helpers/okonomi_ui_kit/application_helper.rb +8 -0
- data/app/helpers/okonomi_ui_kit/attribute_section_helper.rb +5 -5
- data/app/helpers/okonomi_ui_kit/component.rb +14 -6
- data/app/helpers/okonomi_ui_kit/components/alert.rb +1 -1
- data/app/helpers/okonomi_ui_kit/components/badge.rb +4 -4
- data/app/helpers/okonomi_ui_kit/components/breadcrumbs.rb +4 -4
- data/app/helpers/okonomi_ui_kit/components/button_base.rb +94 -22
- data/app/helpers/okonomi_ui_kit/components/button_tag.rb +14 -8
- data/app/helpers/okonomi_ui_kit/components/button_to.rb +8 -7
- data/app/helpers/okonomi_ui_kit/components/code.rb +41 -37
- data/app/helpers/okonomi_ui_kit/components/confirmation_modal.rb +130 -0
- data/app/helpers/okonomi_ui_kit/components/dropdown_button.rb +147 -0
- data/app/helpers/okonomi_ui_kit/components/forms/check_box_with_label.rb +38 -0
- data/app/helpers/okonomi_ui_kit/components/forms/collection_select.rb +57 -0
- data/app/helpers/okonomi_ui_kit/components/forms/date_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/datetime_local_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/email_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/field.rb +24 -0
- data/app/helpers/okonomi_ui_kit/components/forms/field_set.rb +17 -0
- data/app/helpers/okonomi_ui_kit/components/forms/input_base.rb +57 -0
- data/app/helpers/okonomi_ui_kit/components/forms/label.rb +27 -0
- data/app/helpers/okonomi_ui_kit/components/forms/multi_select.rb +18 -0
- data/app/helpers/okonomi_ui_kit/components/forms/number_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/password_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/search_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/select.rb +57 -0
- data/app/helpers/okonomi_ui_kit/components/forms/show_if.rb +28 -0
- data/app/helpers/okonomi_ui_kit/components/forms/telephone_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/text_area.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/text_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/time_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms/upload_field.rb +25 -0
- data/app/helpers/okonomi_ui_kit/components/forms/url_field.rb +9 -0
- data/app/helpers/okonomi_ui_kit/components/forms.rb +6 -0
- data/app/helpers/okonomi_ui_kit/components/icon.rb +6 -6
- data/app/helpers/okonomi_ui_kit/components/link_to.rb +11 -10
- data/app/helpers/okonomi_ui_kit/components/navigation.rb +98 -0
- data/app/helpers/okonomi_ui_kit/components/page.rb +18 -203
- data/app/helpers/okonomi_ui_kit/components/page_header.rb +111 -0
- data/app/helpers/okonomi_ui_kit/components/page_section.rb +145 -0
- data/app/helpers/okonomi_ui_kit/components/table.rb +7 -8
- data/app/helpers/okonomi_ui_kit/components/typography.rb +16 -16
- data/app/helpers/okonomi_ui_kit/components.rb +4 -0
- data/app/helpers/okonomi_ui_kit/configs.rb +4 -0
- data/app/helpers/okonomi_ui_kit/form_builder.rb +39 -130
- data/app/helpers/okonomi_ui_kit/form_component.rb +7 -0
- data/app/helpers/okonomi_ui_kit/svg_icons.rb +5 -5
- data/app/helpers/okonomi_ui_kit/t_w_merge.rb +33 -27
- data/app/helpers/okonomi_ui_kit/ui_helper.rb +17 -58
- data/app/javascript/okonomi_ui_kit/controllers/dropdown_controller.js +6 -0
- data/app/views/okonomi/components/confirmation_modal/_confirmation_modal.html.erb +76 -0
- data/app/views/okonomi/components/dropdown_button/_dropdown_button.html.erb +282 -0
- data/app/views/okonomi/components/forms/check_box_with_label/_check_box_with_label.html.erb +6 -0
- data/app/views/okonomi/{forms/tailwind → components/forms/field}/_field.html.erb +7 -7
- data/app/views/okonomi/components/forms/field_set/_field_set.html.erb +3 -0
- data/app/views/okonomi/components/forms/upload_field/_upload_field.html.erb +1 -0
- data/app/views/okonomi/components/navigation/_link.html.erb +18 -0
- data/app/views/okonomi/components/navigation/_navigation.html.erb +4 -0
- data/app/views/okonomi/components/page/_page.html.erb +1 -1
- data/app/views/okonomi/components/page_header/_page_header.html.erb +4 -0
- data/app/views/okonomi/components/page_section/_page_section.html.erb +4 -0
- data/app/views/okonomi/forms/tailwind/_checkbox_label.html.erb +2 -2
- data/app/views/okonomi/forms/tailwind/_multi_select.html.erb +2 -4
- data/app/views/okonomi/forms/tailwind/_upload_field.html.erb +10 -10
- data/config/importmap.rb +1 -1
- data/lib/okonomi_ui_kit/engine.rb +0 -1
- data/lib/okonomi_ui_kit/version.rb +1 -1
- metadata +47 -16
- data/app/helpers/okonomi_ui_kit/navigation_helper.rb +0 -72
- data/app/helpers/okonomi_ui_kit/theme.rb +0 -136
- data/app/helpers/okonomi_ui_kit/theme_helper.rb +0 -17
- data/app/views/okonomi/forms/tailwind/_field_set.html.erb +0 -3
- data/app/views/okonomi/modals/_confirmation_modal.html.erb +0 -77
- data/app/views/okonomi/navigation/_link.html.erb +0 -15
- data/app/views/okonomi/navigation/_menu.html.erb +0 -3
- data/app/views/okonomi/navigation/_navbar.html.erb +0 -105
- data/app/views/okonomi/page_builder/_page.html.erb +0 -3
@@ -2,9 +2,22 @@ module OkonomiUiKit
|
|
2
2
|
module Components
|
3
3
|
class Page < OkonomiUiKit::Component
|
4
4
|
def render(options = {}, &block)
|
5
|
+
options = options.with_indifferent_access
|
6
|
+
|
7
|
+
classes = tw_merge(
|
8
|
+
style(:root),
|
9
|
+
options.delete(:class)
|
10
|
+
)
|
11
|
+
|
5
12
|
builder = PageBuilder.new(view)
|
6
13
|
|
7
|
-
view.render(template_path, builder: builder, options: options, &block)
|
14
|
+
view.render(template_path, builder: builder, options: options.merge(class: classes), &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
register_styles :default do
|
18
|
+
{
|
19
|
+
root: "flex flex-col gap-8 p-8"
|
20
|
+
}
|
8
21
|
end
|
9
22
|
end
|
10
23
|
|
@@ -18,24 +31,19 @@ module OkonomiUiKit
|
|
18
31
|
end
|
19
32
|
|
20
33
|
def page_header(**options, &block)
|
21
|
-
|
22
|
-
yield(header_builder) if block_given?
|
23
|
-
@content_parts << header_builder.render
|
34
|
+
@content_parts << @template.ui.page_header(options, &block)
|
24
35
|
nil
|
25
36
|
end
|
26
37
|
|
27
38
|
def section(**options, &block)
|
28
|
-
|
29
|
-
section_builder.title(options[:title]) if options[:title]
|
30
|
-
yield(section_builder) if block_given?
|
31
|
-
@content_parts << section_builder.render
|
39
|
+
@content_parts << @template.ui.page_section(options, &block)
|
32
40
|
nil
|
33
41
|
end
|
34
42
|
|
35
43
|
def render_content
|
36
44
|
@template.safe_join(@content_parts)
|
37
45
|
end
|
38
|
-
|
46
|
+
|
39
47
|
def to_s
|
40
48
|
render_content
|
41
49
|
end
|
@@ -50,198 +58,5 @@ module OkonomiUiKit
|
|
50
58
|
@template.capture(*args, &block)
|
51
59
|
end
|
52
60
|
end
|
53
|
-
|
54
|
-
class PageHeaderBuilder
|
55
|
-
include ActionView::Helpers::TagHelper
|
56
|
-
include ActionView::Helpers::CaptureHelper
|
57
|
-
|
58
|
-
def initialize(template)
|
59
|
-
@template = template
|
60
|
-
@breadcrumbs_content = nil
|
61
|
-
@row_content = nil
|
62
|
-
end
|
63
|
-
|
64
|
-
def breadcrumbs(&block)
|
65
|
-
@breadcrumbs_content = @template.ui.breadcrumbs(&block)
|
66
|
-
end
|
67
|
-
|
68
|
-
def row(&block)
|
69
|
-
row_builder = PageHeaderRowBuilder.new(@template)
|
70
|
-
yield(row_builder) if block_given?
|
71
|
-
@row_content = row_builder.render
|
72
|
-
end
|
73
|
-
|
74
|
-
def render
|
75
|
-
content = []
|
76
|
-
content << @breadcrumbs_content if @breadcrumbs_content
|
77
|
-
content << @row_content if @row_content
|
78
|
-
|
79
|
-
tag.div(class: "flex flex-col gap-2") do
|
80
|
-
@template.safe_join(content.compact)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
85
|
-
|
86
|
-
def tag
|
87
|
-
@template.tag
|
88
|
-
end
|
89
|
-
|
90
|
-
def capture(*args, &block)
|
91
|
-
@template.capture(*args, &block)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
class PageHeaderRowBuilder
|
96
|
-
include ActionView::Helpers::TagHelper
|
97
|
-
include ActionView::Helpers::CaptureHelper
|
98
|
-
|
99
|
-
def initialize(template)
|
100
|
-
@template = template
|
101
|
-
@title_content = nil
|
102
|
-
@actions_content = nil
|
103
|
-
end
|
104
|
-
|
105
|
-
def title(text, **options)
|
106
|
-
@title_content = tag.h1(text, class: "text-2xl font-bold leading-7 text-gray-900 truncate sm:text-3xl sm:tracking-tight")
|
107
|
-
end
|
108
|
-
|
109
|
-
def actions(&block)
|
110
|
-
@actions_content = tag.div(class: "mt-4 flex md:ml-4 md:mt-0 gap-2") do
|
111
|
-
capture(&block) if block_given?
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def render
|
116
|
-
tag.div(class: "flex w-full justify-between items-center") do
|
117
|
-
content = []
|
118
|
-
content << @title_content if @title_content
|
119
|
-
content << @actions_content if @actions_content
|
120
|
-
@template.safe_join(content.compact)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
private
|
125
|
-
|
126
|
-
def tag
|
127
|
-
@template.tag
|
128
|
-
end
|
129
|
-
|
130
|
-
def capture(*args, &block)
|
131
|
-
@template.capture(*args, &block)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
class SectionBuilder
|
136
|
-
include ActionView::Helpers::TagHelper
|
137
|
-
include ActionView::Helpers::CaptureHelper
|
138
|
-
|
139
|
-
def initialize(template)
|
140
|
-
@template = template
|
141
|
-
@title_content = nil
|
142
|
-
@subtitle_content = nil
|
143
|
-
@actions_content = nil
|
144
|
-
@body_content = nil
|
145
|
-
@attributes = []
|
146
|
-
end
|
147
|
-
|
148
|
-
def title(text, **options)
|
149
|
-
@title_content = tag.h3(text, class: "text-base/7 font-semibold text-gray-900")
|
150
|
-
end
|
151
|
-
|
152
|
-
def subtitle(text, **options)
|
153
|
-
@subtitle_content = tag.p(text, class: "mt-1 max-w-2xl text-sm/6 text-gray-500")
|
154
|
-
end
|
155
|
-
|
156
|
-
def actions(&block)
|
157
|
-
@actions_content = tag.div(class: "mt-4 flex md:ml-4 md:mt-0") do
|
158
|
-
capture(&block) if block_given?
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def body(&block)
|
163
|
-
if block_given?
|
164
|
-
# Capture the content first to see if attributes were used
|
165
|
-
content = capture { yield(self) }
|
166
|
-
|
167
|
-
@body_content = if @attributes.any?
|
168
|
-
# If attributes were added, wrap them in dl
|
169
|
-
tag.div do
|
170
|
-
tag.dl(class: "divide-y divide-gray-100") do
|
171
|
-
@template.safe_join(@attributes)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
else
|
175
|
-
# Otherwise, just return the captured content
|
176
|
-
tag.div do
|
177
|
-
content
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def attribute(label, value = nil, **options, &block)
|
184
|
-
content = if block_given?
|
185
|
-
capture(&block)
|
186
|
-
elsif value.respond_to?(:call)
|
187
|
-
value.call
|
188
|
-
else
|
189
|
-
value
|
190
|
-
end
|
191
|
-
|
192
|
-
attribute_html = tag.div(class: "py-6 sm:grid sm:grid-cols-3 sm:gap-4") do
|
193
|
-
dt_content = tag.dt(label, class: "text-sm font-medium text-gray-900")
|
194
|
-
dd_content = tag.dd(content, class: "mt-1 text-sm/6 text-gray-700 sm:col-span-2 sm:mt-0")
|
195
|
-
|
196
|
-
dt_content + dd_content
|
197
|
-
end
|
198
|
-
|
199
|
-
@attributes << attribute_html
|
200
|
-
end
|
201
|
-
|
202
|
-
def render
|
203
|
-
tag.div(class: "overflow-hidden bg-white") do
|
204
|
-
header_content = build_header
|
205
|
-
content_parts = []
|
206
|
-
content_parts << header_content if header_content.present?
|
207
|
-
content_parts << @body_content if @body_content
|
208
|
-
@template.safe_join(content_parts.compact)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
private
|
213
|
-
|
214
|
-
def build_header
|
215
|
-
return nil unless @title_content || @subtitle_content || @actions_content
|
216
|
-
|
217
|
-
tag.div(class: "py-6") do
|
218
|
-
if @actions_content
|
219
|
-
tag.div(class: "flex w-full justify-between items-start") do
|
220
|
-
title_section = tag.div do
|
221
|
-
content_parts = []
|
222
|
-
content_parts << @title_content if @title_content
|
223
|
-
content_parts << @subtitle_content if @subtitle_content
|
224
|
-
@template.safe_join(content_parts.compact)
|
225
|
-
end
|
226
|
-
|
227
|
-
title_section + @actions_content
|
228
|
-
end
|
229
|
-
else
|
230
|
-
content_parts = []
|
231
|
-
content_parts << @title_content if @title_content
|
232
|
-
content_parts << @subtitle_content if @subtitle_content
|
233
|
-
@template.safe_join(content_parts.compact)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
def tag
|
239
|
-
@template.tag
|
240
|
-
end
|
241
|
-
|
242
|
-
def capture(*args, &block)
|
243
|
-
@template.capture(*args, &block)
|
244
|
-
end
|
245
|
-
end
|
246
61
|
end
|
247
|
-
end
|
62
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module OkonomiUiKit
|
2
|
+
module Components
|
3
|
+
class PageHeader < OkonomiUiKit::Component
|
4
|
+
def render(options = {}, &block)
|
5
|
+
options = options.with_indifferent_access
|
6
|
+
|
7
|
+
classes = tw_merge(
|
8
|
+
style(:root),
|
9
|
+
options.delete(:class)
|
10
|
+
)
|
11
|
+
|
12
|
+
builder = PageHeaderBuilder.new(view, self)
|
13
|
+
|
14
|
+
view.render(template_path, builder: builder, options: options.merge(class: classes), &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
register_styles :default do
|
18
|
+
{
|
19
|
+
root: "flex flex-col gap-2",
|
20
|
+
row: "flex w-full justify-between items-center",
|
21
|
+
actions: "mt-4 flex md:ml-4 md:mt-0 gap-2"
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class PageHeaderBuilder
|
27
|
+
include ActionView::Helpers::TagHelper
|
28
|
+
include ActionView::Helpers::CaptureHelper
|
29
|
+
|
30
|
+
def initialize(template, component)
|
31
|
+
@template = template
|
32
|
+
@component = component
|
33
|
+
@breadcrumbs_content = nil
|
34
|
+
@row_content = nil
|
35
|
+
end
|
36
|
+
|
37
|
+
def breadcrumbs(&block)
|
38
|
+
@breadcrumbs_content = @template.ui.breadcrumbs(&block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def row(&block)
|
42
|
+
row_builder = PageHeaderRowBuilder.new(@template, @component)
|
43
|
+
yield(row_builder) if block_given?
|
44
|
+
@row_content = row_builder.render
|
45
|
+
end
|
46
|
+
|
47
|
+
def render
|
48
|
+
content = []
|
49
|
+
content << @breadcrumbs_content if @breadcrumbs_content
|
50
|
+
content << @row_content if @row_content
|
51
|
+
|
52
|
+
@template.safe_join(content.compact)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def tag
|
58
|
+
@template.tag
|
59
|
+
end
|
60
|
+
|
61
|
+
def capture(*args, &block)
|
62
|
+
@template.capture(*args, &block)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class PageHeaderRowBuilder
|
67
|
+
include ActionView::Helpers::TagHelper
|
68
|
+
include ActionView::Helpers::CaptureHelper
|
69
|
+
|
70
|
+
attr_reader :template
|
71
|
+
|
72
|
+
delegate :ui, to: :template
|
73
|
+
|
74
|
+
def initialize(template, component)
|
75
|
+
@template = template
|
76
|
+
@component = component
|
77
|
+
@title_content = nil
|
78
|
+
@actions_content = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
def title(text, **options)
|
82
|
+
@title_content = ui.typography(text, variant: "h1", **options)
|
83
|
+
end
|
84
|
+
|
85
|
+
def actions(&block)
|
86
|
+
@actions_content = tag.div(class: @component.style(:actions)) do
|
87
|
+
capture(&block) if block_given?
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def render
|
92
|
+
tag.div(class: @component.style(:row)) do
|
93
|
+
content = []
|
94
|
+
content << @title_content if @title_content
|
95
|
+
content << @actions_content if @actions_content
|
96
|
+
@template.safe_join(content.compact)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def tag
|
103
|
+
@template.tag
|
104
|
+
end
|
105
|
+
|
106
|
+
def capture(*args, &block)
|
107
|
+
@template.capture(*args, &block)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
module OkonomiUiKit
|
2
|
+
module Components
|
3
|
+
class PageSection < OkonomiUiKit::Component
|
4
|
+
def render(options = {}, &block)
|
5
|
+
options = options.with_indifferent_access
|
6
|
+
title = options.delete(:title)
|
7
|
+
|
8
|
+
classes = tw_merge(
|
9
|
+
style(:root),
|
10
|
+
options.delete(:class)
|
11
|
+
)
|
12
|
+
|
13
|
+
builder = SectionBuilder.new(view, self)
|
14
|
+
builder.title(title) if title
|
15
|
+
|
16
|
+
view.render(template_path, builder: builder, options: options.merge(class: classes), &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
register_styles :default do
|
20
|
+
{
|
21
|
+
root: "overflow-hidden bg-white",
|
22
|
+
header: "py-6",
|
23
|
+
header_with_actions: "flex w-full justify-between items-start",
|
24
|
+
title: "text-base/7 font-semibold text-gray-900",
|
25
|
+
subtitle: "mt-1 max-w-2xl text-sm/6 text-gray-500",
|
26
|
+
actions: "mt-4 flex md:ml-4 md:mt-0",
|
27
|
+
attribute_list: "divide-y divide-gray-100",
|
28
|
+
attribute_row: "py-6 sm:grid sm:grid-cols-3 sm:gap-4",
|
29
|
+
attribute_label: "text-sm font-medium text-gray-900",
|
30
|
+
attribute_value: "mt-1 text-sm/6 text-gray-700 sm:col-span-2 sm:mt-0"
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class SectionBuilder
|
36
|
+
include ActionView::Helpers::TagHelper
|
37
|
+
include ActionView::Helpers::CaptureHelper
|
38
|
+
|
39
|
+
def initialize(template, component)
|
40
|
+
@template = template
|
41
|
+
@component = component
|
42
|
+
@title_content = nil
|
43
|
+
@subtitle_content = nil
|
44
|
+
@actions_content = nil
|
45
|
+
@body_content = nil
|
46
|
+
@attributes = []
|
47
|
+
end
|
48
|
+
|
49
|
+
def title(text, **options)
|
50
|
+
@title_content = tag.h3(text, class: @component.style(:title))
|
51
|
+
end
|
52
|
+
|
53
|
+
def subtitle(text, **options)
|
54
|
+
@subtitle_content = tag.p(text, class: @component.style(:subtitle))
|
55
|
+
end
|
56
|
+
|
57
|
+
def actions(&block)
|
58
|
+
@actions_content = tag.div(class: @component.style(:actions)) do
|
59
|
+
capture(&block) if block_given?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def body(&block)
|
64
|
+
if block_given?
|
65
|
+
# Capture the content first to see if attributes were used
|
66
|
+
content = capture { yield(self) }
|
67
|
+
|
68
|
+
@body_content = if @attributes.any?
|
69
|
+
# If attributes were added, wrap them in dl
|
70
|
+
tag.div do
|
71
|
+
tag.dl(class: @component.style(:attribute_list)) do
|
72
|
+
@template.safe_join(@attributes)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
else
|
76
|
+
# Otherwise, just return the captured content
|
77
|
+
tag.div do
|
78
|
+
content
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def attribute(label, value = nil, **options, &block)
|
85
|
+
content = if block_given?
|
86
|
+
capture(&block)
|
87
|
+
elsif value.respond_to?(:call)
|
88
|
+
value.call
|
89
|
+
else
|
90
|
+
value
|
91
|
+
end
|
92
|
+
|
93
|
+
attribute_html = tag.div(class: @component.style(:attribute_row)) do
|
94
|
+
dt_content = tag.dt(label, class: @component.style(:attribute_label))
|
95
|
+
dd_content = tag.dd(content, class: @component.style(:attribute_value))
|
96
|
+
|
97
|
+
dt_content + dd_content
|
98
|
+
end
|
99
|
+
|
100
|
+
@attributes << attribute_html
|
101
|
+
end
|
102
|
+
|
103
|
+
def render_header
|
104
|
+
return nil unless @title_content || @subtitle_content || @actions_content
|
105
|
+
|
106
|
+
tag.div(class: @component.style(:header)) do
|
107
|
+
if @actions_content
|
108
|
+
tag.div(class: @component.style(:header_with_actions)) do
|
109
|
+
title_section = tag.div do
|
110
|
+
content_parts = []
|
111
|
+
content_parts << @title_content if @title_content
|
112
|
+
content_parts << @subtitle_content if @subtitle_content
|
113
|
+
@template.safe_join(content_parts.compact)
|
114
|
+
end
|
115
|
+
|
116
|
+
title_section + @actions_content
|
117
|
+
end
|
118
|
+
else
|
119
|
+
content_parts = []
|
120
|
+
content_parts << @title_content if @title_content
|
121
|
+
content_parts << @subtitle_content if @subtitle_content
|
122
|
+
@template.safe_join(content_parts.compact)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def render_content
|
128
|
+
content_parts = []
|
129
|
+
content_parts << render_header
|
130
|
+
content_parts << @body_content if @body_content
|
131
|
+
@template.safe_join(content_parts.compact)
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def tag
|
137
|
+
@template.tag
|
138
|
+
end
|
139
|
+
|
140
|
+
def capture(*args, &block)
|
141
|
+
@template.capture(*args, &block)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -4,8 +4,8 @@ module OkonomiUiKit
|
|
4
4
|
def render(options = {}, &block)
|
5
5
|
options = options.with_indifferent_access
|
6
6
|
variant = (options.delete(:variant) || :default).to_sym
|
7
|
-
|
8
|
-
builder = TableBuilder.new(view,
|
7
|
+
|
8
|
+
builder = TableBuilder.new(view, self, variant)
|
9
9
|
view.render(template_path, builder: builder, options: options, &block)
|
10
10
|
end
|
11
11
|
|
@@ -48,9 +48,8 @@ module OkonomiUiKit
|
|
48
48
|
include ActionView::Helpers::TagHelper
|
49
49
|
include ActionView::Helpers::CaptureHelper
|
50
50
|
|
51
|
-
def initialize(template,
|
51
|
+
def initialize(template, style_provider, variant = :default)
|
52
52
|
@template = template
|
53
|
-
@theme = theme
|
54
53
|
@style_provider = style_provider
|
55
54
|
@variant = variant
|
56
55
|
@current_row_cells = []
|
@@ -157,7 +156,7 @@ module OkonomiUiKit
|
|
157
156
|
|
158
157
|
def render_th(cell, is_first, is_last)
|
159
158
|
align_class = style(:alignment, cell[:align]) || style(:alignment, :left)
|
160
|
-
|
159
|
+
|
161
160
|
position_class = if is_first
|
162
161
|
style(:th, :first)
|
163
162
|
elsif is_last
|
@@ -171,7 +170,7 @@ module OkonomiUiKit
|
|
171
170
|
position_class,
|
172
171
|
align_class,
|
173
172
|
cell[:options][:class]
|
174
|
-
].compact.join(
|
173
|
+
].compact.join(" ")
|
175
174
|
|
176
175
|
options = cell[:options].except(:class)
|
177
176
|
tag.th(cell[:content], scope: cell[:scope], class: classes, **options)
|
@@ -179,7 +178,7 @@ module OkonomiUiKit
|
|
179
178
|
|
180
179
|
def render_td(cell, is_first, is_last)
|
181
180
|
align_class = style(:alignment, cell[:align]) || style(:alignment, :left)
|
182
|
-
|
181
|
+
|
183
182
|
position_class = if is_first
|
184
183
|
style(:td, :first)
|
185
184
|
elsif is_last
|
@@ -193,7 +192,7 @@ module OkonomiUiKit
|
|
193
192
|
position_class,
|
194
193
|
align_class,
|
195
194
|
cell[:options][:class]
|
196
|
-
].compact.join(
|
195
|
+
].compact.join(" ")
|
197
196
|
|
198
197
|
options = cell[:options].except(:class)
|
199
198
|
tag.td(cell[:content], class: classes, **options)
|
@@ -2,14 +2,14 @@ module OkonomiUiKit
|
|
2
2
|
module Components
|
3
3
|
class Typography < OkonomiUiKit::Component
|
4
4
|
TYPOGRAPHY_COMPONENTS = {
|
5
|
-
body1:
|
6
|
-
body2:
|
7
|
-
h1:
|
8
|
-
h2:
|
9
|
-
h3:
|
10
|
-
h4:
|
11
|
-
h5:
|
12
|
-
h6:
|
5
|
+
body1: "p",
|
6
|
+
body2: "p",
|
7
|
+
h1: "h1",
|
8
|
+
h2: "h2",
|
9
|
+
h3: "h3",
|
10
|
+
h4: "h4",
|
11
|
+
h5: "h5",
|
12
|
+
h6: "h6"
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
def render(text = nil, options = {}, &block)
|
@@ -17,15 +17,15 @@ module OkonomiUiKit
|
|
17
17
|
options ||= {}
|
18
18
|
options = options.with_indifferent_access
|
19
19
|
|
20
|
-
variant = (options.delete(:variant) ||
|
21
|
-
component = (TYPOGRAPHY_COMPONENTS[variant] ||
|
22
|
-
color = (options.delete(:color) ||
|
20
|
+
variant = (options.delete(:variant) || "body1").to_sym
|
21
|
+
component = (TYPOGRAPHY_COMPONENTS[variant] || "span").to_s
|
22
|
+
color = (options.delete(:color) || "default").to_sym
|
23
23
|
|
24
24
|
classes = [
|
25
|
-
style(:variants, variant) ||
|
26
|
-
style(:colors, color) ||
|
27
|
-
options.delete(:class) ||
|
28
|
-
].reject(&:blank?).join(
|
25
|
+
style(:variants, variant) || "",
|
26
|
+
style(:colors, color) || "",
|
27
|
+
options.delete(:class) || ""
|
28
|
+
].reject(&:blank?).join(" ")
|
29
29
|
|
30
30
|
view.render(
|
31
31
|
template_path,
|
@@ -65,4 +65,4 @@ module OkonomiUiKit
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
|
-
end
|
68
|
+
end
|