okonomi_ui_kit 0.1.14 → 0.1.15
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/app/assets/builds/okonomi_ui_kit/application.tailwind.css +3 -0
- data/app/helpers/okonomi_ui_kit/component.rb +7 -0
- data/app/helpers/okonomi_ui_kit/components/segment.rb +19 -48
- data/app/views/okonomi/components/segment/_segment.html.erb +2 -2
- data/lib/okonomi_ui_kit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56ed44988417d6630c5a19c81f9b5ebe5a5f746bc50bceaf367bfae211ccf2c5
|
4
|
+
data.tar.gz: 13dccf96cf57029453d93fed7be5caf5c24e3433d0c0533e29121c0e6afbc6a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca51c73c4400d20071e4b68e4a65b6578e8cbf2f750f107e9d982d490aab21b1d717c84220784462c0225ec34c5935fcd75ec3991a1b2a06b05a1bc7d6f2b6d3
|
7
|
+
data.tar.gz: 5d1f047793d156fb8d71ebb9898bb567692550432e25eaac7bfa6affa8d28aec5269d3e8f2f73c5c3b2ca29dc62f80878756a539943dc1d93892d71e3c776426
|
@@ -4,16 +4,12 @@ module OkonomiUiKit
|
|
4
4
|
def render(options = {}, &block)
|
5
5
|
options = options.with_indifferent_access
|
6
6
|
title = options.delete(:title)
|
7
|
+
variant = options.delete(:variant) || :default
|
7
8
|
|
8
|
-
|
9
|
-
style(:root),
|
10
|
-
options.delete(:class)
|
11
|
-
)
|
12
|
-
|
13
|
-
builder = SectionBuilder.new(view, self)
|
9
|
+
builder = SectionBuilder.new(view, self, variant)
|
14
10
|
builder.title(title) if title
|
15
11
|
|
16
|
-
view.render(template_path, builder: builder,
|
12
|
+
view.render(template_path, builder: builder, component: self, variant: variant, &block)
|
17
13
|
end
|
18
14
|
|
19
15
|
register_styles :default do
|
@@ -24,10 +20,11 @@ module OkonomiUiKit
|
|
24
20
|
title: "text-base/7 font-semibold text-gray-900",
|
25
21
|
subtitle: "mt-1 max-w-2xl text-sm/6 text-gray-500",
|
26
22
|
actions: "mt-4 flex md:ml-4 md:mt-0",
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
variants: {
|
24
|
+
default: {
|
25
|
+
body: "px-4 py-5 sm:px-6"
|
26
|
+
}
|
27
|
+
}
|
31
28
|
}
|
32
29
|
end
|
33
30
|
end
|
@@ -36,7 +33,9 @@ module OkonomiUiKit
|
|
36
33
|
include ActionView::Helpers::TagHelper
|
37
34
|
include ActionView::Helpers::CaptureHelper
|
38
35
|
|
39
|
-
|
36
|
+
attr_reader :view, :component, :variant
|
37
|
+
|
38
|
+
def initialize(template, component, variant = :default)
|
40
39
|
@template = template
|
41
40
|
@component = component
|
42
41
|
@title_content = nil
|
@@ -44,18 +43,19 @@ module OkonomiUiKit
|
|
44
43
|
@actions_content = nil
|
45
44
|
@body_content = nil
|
46
45
|
@attributes = []
|
46
|
+
@variant = variant
|
47
47
|
end
|
48
48
|
|
49
49
|
def title(text, **options)
|
50
|
-
@title_content = tag.h3(text, class: @component.
|
50
|
+
@title_content = tag.h3(text, class: @component.variant_style(variant, :title))
|
51
51
|
end
|
52
52
|
|
53
53
|
def subtitle(text, **options)
|
54
|
-
@subtitle_content = tag.p(text, class: @component.
|
54
|
+
@subtitle_content = tag.p(text, class: @component.variant_style(variant, :subtitle))
|
55
55
|
end
|
56
56
|
|
57
57
|
def actions(&block)
|
58
|
-
@actions_content = tag.div(class: @component.
|
58
|
+
@actions_content = tag.div(class: @component.variant_style(variant, :actions)) do
|
59
59
|
capture(&block) if block_given?
|
60
60
|
end
|
61
61
|
end
|
@@ -65,47 +65,18 @@ module OkonomiUiKit
|
|
65
65
|
# Capture the content first to see if attributes were used
|
66
66
|
content = capture { yield(self) }
|
67
67
|
|
68
|
-
@body_content =
|
69
|
-
|
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
|
68
|
+
@body_content = tag.div class: @component.variant_style(variant, :body) do
|
69
|
+
content
|
80
70
|
end
|
81
71
|
end
|
82
72
|
end
|
83
73
|
|
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
74
|
def render_header
|
104
75
|
return nil unless @title_content || @subtitle_content || @actions_content
|
105
76
|
|
106
|
-
tag.div(class: @component.
|
77
|
+
tag.div(class: @component.variant_style(variant, :header)) do
|
107
78
|
if @actions_content
|
108
|
-
tag.div(class: @component.
|
79
|
+
tag.div(class: @component.variant_style(variant, :header_with_actions)) do
|
109
80
|
title_section = tag.div do
|
110
81
|
content_parts = []
|
111
82
|
content_parts << @title_content if @title_content
|