okonomi_ui_kit 0.1.2 → 0.1.4
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 +336 -53
- data/app/assets/stylesheets/okonomi_ui_kit/application.tailwind.css +75 -3
- data/app/helpers/okonomi_ui_kit/attribute_section_helper.rb +1 -1
- data/app/helpers/okonomi_ui_kit/form_builder.rb +167 -158
- data/app/helpers/okonomi_ui_kit/navigation_helper.rb +2 -2
- data/app/helpers/okonomi_ui_kit/page_builder_helper.rb +1 -1
- data/app/helpers/okonomi_ui_kit/table_helper.rb +1 -1
- data/app/helpers/okonomi_ui_kit/theme.rb +107 -0
- data/app/helpers/okonomi_ui_kit/theme_helper.rb +17 -0
- data/app/helpers/okonomi_ui_kit/ui_helper.rb +110 -0
- data/app/javascript/okonomi_ui_kit/controllers/file_input_controller.js +13 -0
- data/app/javascript/okonomi_ui_kit/controllers/flash_controller.js +31 -0
- data/app/javascript/okonomi_ui_kit/controllers/form_field_visibility_controller.js +27 -0
- data/app/javascript/okonomi_ui_kit/controllers/upload_controller.js +55 -0
- data/app/views/okonomi/components/_typography.html.erb +7 -0
- data/app/views/{okonomi_ui_kit → okonomi}/forms/tailwind/_checkbox_label.html.erb +2 -2
- data/app/views/{okonomi_ui_kit → okonomi}/forms/tailwind/_field.html.erb +2 -2
- data/config/importmap.rb +5 -0
- data/lib/okonomi_ui_kit/engine.rb +3 -2
- data/lib/okonomi_ui_kit/version.rb +1 -1
- metadata +49 -14
- data/app/helpers/okonomi_ui_kit/button_helper.rb +0 -39
- /data/app/views/{okonomi_ui_kit → okonomi}/attribute_sections/_section.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/forms/tailwind/_field_set.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/forms/tailwind/_multi_select.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/forms/tailwind/_radio_button.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/forms/tailwind/_upload_field.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/navigation/_link.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/navigation/_menu.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/navigation/_navbar.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/page_builder/_page.html.erb +0 -0
- /data/app/views/{okonomi_ui_kit → okonomi}/tables/_table.html.erb +0 -0
@@ -1,3 +1,75 @@
|
|
1
|
-
@
|
2
|
-
@tailwind
|
3
|
-
|
1
|
+
@import "tailwindcss";
|
2
|
+
@config "../../../../config/tailwind.config.js";
|
3
|
+
|
4
|
+
@theme {
|
5
|
+
--color-default-50: var(--color-gray-50);
|
6
|
+
--color-default-100: var(--color-gray-100);
|
7
|
+
--color-default-200: var(--color-gray-200);
|
8
|
+
--color-default-300: var(--color-gray-300);
|
9
|
+
--color-default-400: var(--color-gray-400);
|
10
|
+
--color-default-500: var(--color-gray-500);
|
11
|
+
--color-default-600: var(--color-gray-600);
|
12
|
+
--color-default-700: var(--color-gray-700);
|
13
|
+
--color-default-800: var(--color-gray-800);
|
14
|
+
--color-default-900: var(--color-gray-900);
|
15
|
+
--color-primary-50: var(--color-indigo-50);
|
16
|
+
--color-primary-100: var(--color-indigo-100);
|
17
|
+
--color-primary-200: var(--color-indigo-200);
|
18
|
+
--color-primary-300: var(--color-indigo-300);
|
19
|
+
--color-primary-400: var(--color-indigo-400);
|
20
|
+
--color-primary-500: var(--color-indigo-500);
|
21
|
+
--color-primary-600: var(--color-indigo-600);
|
22
|
+
--color-primary-700: var(--color-indigo-700);
|
23
|
+
--color-primary-800: var(--color-indigo-800);
|
24
|
+
--color-primary-900: var(--color-indigo-900);
|
25
|
+
--color-secondary-50: var(--color-purple-50);
|
26
|
+
--color-secondary-100: var(--color-purple-100);
|
27
|
+
--color-secondary-200: var(--color-purple-200);
|
28
|
+
--color-secondary-300: var(--color-purple-300);
|
29
|
+
--color-secondary-400: var(--color-purple-400);
|
30
|
+
--color-secondary-500: var(--color-purple-500);
|
31
|
+
--color-secondary-600: var(--color-purple-600);
|
32
|
+
--color-secondary-700: var(--color-purple-700);
|
33
|
+
--color-secondary-800: var(--color-purple-800);
|
34
|
+
--color-secondary-900: var(--color-purple-900);
|
35
|
+
--color-success-50: var(--color-green-50);
|
36
|
+
--color-success-100: var(--color-green-100);
|
37
|
+
--color-success-200: var(--color-green-200);
|
38
|
+
--color-success-300: var(--color-green-300);
|
39
|
+
--color-success-400: var(--color-green-400);
|
40
|
+
--color-success-500: var(--color-green-500);
|
41
|
+
--color-success-600: var(--color-green-600);
|
42
|
+
--color-success-700: var(--color-green-700);
|
43
|
+
--color-success-800: var(--color-green-800);
|
44
|
+
--color-success-900: var(--color-green-900);
|
45
|
+
--color-danger-50: var(--color-red-50);
|
46
|
+
--color-danger-100: var(--color-red-100);
|
47
|
+
--color-danger-200: var(--color-red-200);
|
48
|
+
--color-danger-300: var(--color-red-300);
|
49
|
+
--color-danger-400: var(--color-red-400);
|
50
|
+
--color-danger-500: var(--color-red-500);
|
51
|
+
--color-danger-600: var(--color-red-600);
|
52
|
+
--color-danger-700: var(--color-red-700);
|
53
|
+
--color-danger-800: var(--color-red-800);
|
54
|
+
--color-danger-900: var(--color-red-900);
|
55
|
+
--color-warning-50: var(--color-amber-50);
|
56
|
+
--color-warning-100: var(--color-amber-100);
|
57
|
+
--color-warning-200: var(--color-amber-200);
|
58
|
+
--color-warning-300: var(--color-amber-300);
|
59
|
+
--color-warning-400: var(--color-amber-400);
|
60
|
+
--color-warning-500: var(--color-amber-500);
|
61
|
+
--color-warning-600: var(--color-amber-600);
|
62
|
+
--color-warning-700: var(--color-amber-700);
|
63
|
+
--color-warning-800: var(--color-amber-800);
|
64
|
+
--color-warning-900: var(--color-amber-900);
|
65
|
+
--color-info-50: var(--color-sky-50);
|
66
|
+
--color-info-100: var(--color-sky-100);
|
67
|
+
--color-info-200: var(--color-sky-200);
|
68
|
+
--color-info-300: var(--color-sky-300);
|
69
|
+
--color-info-400: var(--color-sky-400);
|
70
|
+
--color-info-500: var(--color-sky-500);
|
71
|
+
--color-info-600: var(--color-sky-600);
|
72
|
+
--color-info-700: var(--color-sky-700);
|
73
|
+
--color-info-800: var(--color-sky-800);
|
74
|
+
--color-info-900: var(--color-sky-900);
|
75
|
+
}
|
@@ -3,7 +3,7 @@ module OkonomiUiKit
|
|
3
3
|
def attribute_section(title:, description: nil, **options, &block)
|
4
4
|
builder = AttributeSectionBuilder.new(self)
|
5
5
|
|
6
|
-
render '
|
6
|
+
render 'okonomi/attribute_sections/section',
|
7
7
|
builder: builder,
|
8
8
|
title: title,
|
9
9
|
description: description,
|
@@ -1,189 +1,198 @@
|
|
1
1
|
module OkonomiUiKit
|
2
2
|
class FormBuilder < ActionView::Helpers::FormBuilder
|
3
|
-
|
3
|
+
delegate :tag, :content_tag, :safe_join, to: :@template
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def field(field_id = nil, options = {}, &block)
|
10
|
-
@template.render('okonomi_ui_kit/forms/tailwind/field', field_id:, options:, form: self, &block)
|
11
|
-
end
|
12
|
-
|
13
|
-
def upload_field(method, options = {})
|
14
|
-
@template.render('okonomi_ui_kit/forms/tailwind/upload_field', method:, options:, form: self)
|
15
|
-
end
|
16
|
-
|
17
|
-
def text_field(method, options = {})
|
18
|
-
css = input_field_classes(method, options, focus_ring: 'focus-within:ring-0.5')
|
19
|
-
super(method, { autocomplete: "off" }.merge(options).merge(class: css))
|
20
|
-
end
|
5
|
+
def ui
|
6
|
+
@template.ui
|
7
|
+
end
|
21
8
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
9
|
+
def field_set(options = {}, &block)
|
10
|
+
@template.render('okonomi/forms/tailwind/field_set', options:, form: self, &block)
|
11
|
+
end
|
26
12
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
13
|
+
def field(field_id = nil, options = {}, &block)
|
14
|
+
@template.render('okonomi/forms/tailwind/field', field_id:, options:, form: self, &block)
|
15
|
+
end
|
31
16
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
17
|
+
def upload_field(method, options = {})
|
18
|
+
@template.render('okonomi/forms/tailwind/upload_field', method:, options:, form: self)
|
19
|
+
end
|
36
20
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
21
|
+
def text_field(method, options = {})
|
22
|
+
css = input_field_classes(method, :text, options)
|
23
|
+
super(method, { autocomplete: "off" }.merge(options).merge(class: css))
|
24
|
+
end
|
41
25
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
26
|
+
def email_field(method, options = {})
|
27
|
+
css = input_field_classes(method, :email, options)
|
28
|
+
super(method, options.merge(class: css))
|
29
|
+
end
|
46
30
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
def url_field(method, options = {})
|
32
|
+
css = input_field_classes(method, :url, options)
|
33
|
+
super(method, options.merge(class: css))
|
34
|
+
end
|
51
35
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
36
|
+
def password_field(method, options = {})
|
37
|
+
css = input_field_classes(method, :password, options)
|
38
|
+
super(method, options.merge(class: css))
|
39
|
+
end
|
56
40
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
41
|
+
def number_field(method, options = {})
|
42
|
+
css = input_field_classes(method, :number, options)
|
43
|
+
super(method, options.merge(class: css))
|
44
|
+
end
|
61
45
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
46
|
+
def telephone_field(method, options = {})
|
47
|
+
css = input_field_classes(method, :telephone_field, options)
|
48
|
+
super(method, options.merge(class: css))
|
49
|
+
end
|
66
50
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
51
|
+
def search_field(method, options = {})
|
52
|
+
css = input_field_classes(method, :search, options)
|
53
|
+
super(method, options.merge(class: css))
|
54
|
+
end
|
71
55
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
'bg-red-100 text-red-600 ring-1 ring-inset ring-red-300 focus-within:ring-2 focus-within:ring-red-400',
|
77
|
-
select_class_default_state),
|
78
|
-
html_options[:class]
|
79
|
-
].compact.join(' ').split(' ').uniq
|
80
|
-
super(method, choices, options, html_options.merge(class: css), &block)
|
81
|
-
end
|
56
|
+
def date_field(method, options = {})
|
57
|
+
css = input_field_classes(method, :date, options)
|
58
|
+
super(method, options.merge(class: css))
|
59
|
+
end
|
82
60
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
'bg-red-100 text-red-600 ring-1 ring-inset ring-red-300 focus-within:ring-2 focus-within:ring-red-400',
|
88
|
-
select_class_default_state),
|
89
|
-
html_options[:class]
|
90
|
-
].compact.join(' ').split(' ').uniq
|
91
|
-
super(method, collection, value_method, text_method, options, html_options.merge(class: css))
|
92
|
-
end
|
61
|
+
def datetime_local_field(method, options = {})
|
62
|
+
css = input_field_classes(method, :datetime_local, options)
|
63
|
+
super(method, options.merge(class: css))
|
64
|
+
end
|
93
65
|
|
94
|
-
|
95
|
-
|
96
|
-
|
66
|
+
def time_field(method, options = {})
|
67
|
+
css = input_field_classes(method, :time, options)
|
68
|
+
super(method, options.merge(class: css))
|
69
|
+
end
|
97
70
|
|
98
|
-
|
99
|
-
|
100
|
-
|
71
|
+
def text_area(method, options = {})
|
72
|
+
css = input_field_classes(method, :textarea, options, include_disabled: false)
|
73
|
+
super(method, options.merge(class: css))
|
74
|
+
end
|
101
75
|
|
102
|
-
|
103
|
-
|
104
|
-
|
76
|
+
def select(method, choices = nil, options = {}, html_options = {}, &block)
|
77
|
+
css = [
|
78
|
+
ui.get_theme.dig(:components, :select, :root),
|
79
|
+
when_errors(
|
80
|
+
method,
|
81
|
+
ui.get_theme.dig(:components, :select, :error),
|
82
|
+
ui.get_theme.dig(:components, :select, :valid)
|
83
|
+
),
|
84
|
+
html_options[:class]
|
85
|
+
].compact.join(' ').split(' ').uniq
|
86
|
+
|
87
|
+
select_html = super(method, choices, options, html_options.merge(class: css), &block)
|
88
|
+
icon_html = @template.svg_icon(
|
89
|
+
ui.get_theme.dig(:components, :select, :icon, :file),
|
90
|
+
class: ui.get_theme.dig(:components, :select, :icon, :class)
|
91
|
+
)
|
92
|
+
|
93
|
+
@template.content_tag(:div, class: ui.get_theme.dig(:components, :select, :wrapper)) do
|
94
|
+
@template.concat(select_html)
|
95
|
+
@template.concat(icon_html)
|
96
|
+
end
|
97
|
+
end
|
105
98
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
99
|
+
def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
|
100
|
+
css = [
|
101
|
+
ui.get_theme.dig(:components, :select, :root),
|
102
|
+
when_errors(
|
103
|
+
method,
|
104
|
+
ui.get_theme.dig(:components, :select, :error),
|
105
|
+
ui.get_theme.dig(:components, :select, :valid)
|
106
|
+
),
|
107
|
+
html_options[:class]
|
108
|
+
].compact.join(' ').split(' ').uniq
|
109
|
+
|
110
|
+
select_html = super(method, collection, value_method, text_method, options, html_options.merge(class: css))
|
111
|
+
icon_html = @template.svg_icon(
|
112
|
+
ui.get_theme.dig(:components, :select, :icon, :file),
|
113
|
+
class: ui.get_theme.dig(:components, :select, :icon, :class)
|
114
|
+
)
|
115
|
+
|
116
|
+
@template.content_tag(:div, class: ui.get_theme.dig(:components, :select, :wrapper)) do
|
117
|
+
@template.concat(select_html)
|
118
|
+
@template.concat(icon_html)
|
119
|
+
end
|
120
|
+
end
|
110
121
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
122
|
+
def label(method, text = nil, options = {}, &block)
|
123
|
+
base_classes = ui.get_theme.dig(:components, :label, :root)
|
124
|
+
super(method, text, merge_class(options, base_classes), &block)
|
125
|
+
end
|
115
126
|
|
116
|
-
|
117
|
-
|
118
|
-
|
127
|
+
def submit(value = nil, options = {})
|
128
|
+
variant = options.delete(:variant) || 'contained'
|
129
|
+
color = options.delete(:color) || 'primary'
|
119
130
|
|
120
|
-
|
121
|
-
|
122
|
-
@template.concat check_box(
|
123
|
-
method,
|
124
|
-
{
|
125
|
-
class: 'cursor-pointer h-4 w-4 rounded-sm border-gray-300 text-primary-600 focus:ring-0 focus:ring-primary-600'
|
126
|
-
}.merge(options || {}),
|
127
|
-
checked_value,
|
128
|
-
unchecked_value
|
129
|
-
)
|
130
|
-
@template.concat @template.render('okonomi_ui_kit/forms/tailwind/checkbox_label', method:, options:, form: self)
|
131
|
+
base_classes = ui.button_class(variant:, color:)
|
132
|
+
super(value, merge_class(options, base_classes))
|
131
133
|
end
|
132
|
-
end
|
133
134
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
135
|
+
def check_box_with_label(method, options = {}, checked_value = true, unchecked_value = false)
|
136
|
+
@template.content_tag(:div, class: ui.get_theme.dig(:components, :checkbox, :wrapper)) do
|
137
|
+
@template.concat check_box(
|
138
|
+
method,
|
139
|
+
{
|
140
|
+
class: ui.get_theme.dig(:components, :checkbox, :input, :root)
|
141
|
+
}.merge(options || {}),
|
142
|
+
checked_value,
|
143
|
+
unchecked_value
|
144
|
+
)
|
145
|
+
@template.concat @template.render('okonomi/forms/tailwind/checkbox_label', method:, options:, form: self)
|
146
|
+
end
|
147
|
+
end
|
144
148
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
149
|
+
def show_if(field:, equals:, &block)
|
150
|
+
field_id = "#{object_name}_#{field}"
|
151
|
+
@template.tag.div(
|
152
|
+
class: "hidden",
|
153
|
+
data: {
|
154
|
+
controller: "form-field-visibility",
|
155
|
+
"form-field-visibility-field-id-value": field_id,
|
156
|
+
"form-field-visibility-equals-value": equals
|
157
|
+
},
|
158
|
+
&block
|
159
|
+
)
|
160
|
+
end
|
157
161
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
162
|
+
private
|
163
|
+
|
164
|
+
def input_field_classes(method, type, options, include_disabled: true)
|
165
|
+
css_classes = [
|
166
|
+
ui.get_theme.dig(:components, :input, :types, type, :root) || ui.get_theme.dig(:components, :input, :types, :text, :root),
|
167
|
+
when_errors(
|
168
|
+
method,
|
169
|
+
ui.get_theme.dig(:components, :input, :types, type, :error) || ui.get_theme.dig(:components, :input, :types, :text, :error),
|
170
|
+
ui.get_theme.dig(:components, :input, :types, type, :valid) || ui.get_theme.dig(:components, :input, :types, :text, :valid)
|
171
|
+
),
|
172
|
+
options[:class]
|
173
|
+
]
|
174
|
+
|
175
|
+
if include_disabled
|
176
|
+
css_classes << (
|
177
|
+
ui.get_theme.dig(:components, :input, :types, type, :disabled) || ui.get_theme.dig(:components, :input, :types, :text, :disabled)
|
178
|
+
)
|
179
|
+
end
|
180
|
+
|
181
|
+
css_classes.compact.join(' ').split(' ').uniq
|
182
|
+
end
|
174
183
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
184
|
+
def when_errors(method, value, default_value = nil)
|
185
|
+
key = method.to_s.gsub('_id', '').to_sym
|
186
|
+
if object.errors.include?(key) || object.errors.include?(method)
|
187
|
+
value
|
188
|
+
else
|
189
|
+
default_value
|
190
|
+
end
|
181
191
|
end
|
182
|
-
end
|
183
192
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
193
|
+
def merge_class(options, new_class)
|
194
|
+
options[:class] = [options[:class], new_class].compact.join(" ")
|
195
|
+
options
|
196
|
+
end
|
188
197
|
end
|
189
198
|
end
|
@@ -2,7 +2,7 @@ module OkonomiUiKit
|
|
2
2
|
module NavigationHelper
|
3
3
|
def navigation_menu(**options, &block)
|
4
4
|
builder = NavigationBuilder.new(self)
|
5
|
-
render '
|
5
|
+
render 'okonomi/navigation/menu', builder: builder, options: options, &block
|
6
6
|
end
|
7
7
|
|
8
8
|
class NavigationBuilder
|
@@ -49,7 +49,7 @@ module OkonomiUiKit
|
|
49
49
|
|
50
50
|
def nav_link(title, path, icon: nil, initials: nil, exact: false)
|
51
51
|
tag.li do
|
52
|
-
@template.render "
|
52
|
+
@template.render "okonomi/navigation/link",
|
53
53
|
path: path,
|
54
54
|
title: title,
|
55
55
|
icon: icon,
|
@@ -3,7 +3,7 @@ module OkonomiUiKit
|
|
3
3
|
def page(**options, &block)
|
4
4
|
builder = PageBuilder.new(self)
|
5
5
|
|
6
|
-
render '
|
6
|
+
render 'okonomi/page_builder/page', builder: builder, options: options, &block
|
7
7
|
end
|
8
8
|
|
9
9
|
class PageBuilder
|
@@ -3,7 +3,7 @@ module OkonomiUiKit
|
|
3
3
|
def table(**options, &block)
|
4
4
|
builder = TableBuilder.new(self)
|
5
5
|
|
6
|
-
render '
|
6
|
+
render 'okonomi/tables/table', builder: builder, options: options, &block
|
7
7
|
end
|
8
8
|
|
9
9
|
class TableBuilder
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module OkonomiUiKit
|
2
|
+
module Theme
|
3
|
+
LIGHT_THEME = {
|
4
|
+
components: {
|
5
|
+
typography: {
|
6
|
+
variants: {
|
7
|
+
body1: "text-base font-normal",
|
8
|
+
body2: "text-sm font-normal",
|
9
|
+
h1: "text-3xl font-bold",
|
10
|
+
h2: "text-2xl font-bold",
|
11
|
+
h3: "text-xl font-semibold",
|
12
|
+
h4: "text-lg font-semibold",
|
13
|
+
h5: "text-base font-semibold",
|
14
|
+
h6: "text-sm font-semibold"
|
15
|
+
},
|
16
|
+
colors: {
|
17
|
+
default: "text-default-700",
|
18
|
+
dark: "text-default-900",
|
19
|
+
muted: "text-default-500",
|
20
|
+
primary: "text-primary-600",
|
21
|
+
secondary: "text-secondary-600",
|
22
|
+
success: "text-success-600",
|
23
|
+
danger: "text-danger-600",
|
24
|
+
warning: "text-warning-600",
|
25
|
+
info: "text-info-600"
|
26
|
+
}
|
27
|
+
},
|
28
|
+
link: {
|
29
|
+
root: "hover:cursor-pointer",
|
30
|
+
outlined: {
|
31
|
+
root: "inline-flex border items-center justify-center px-4 py-2 font-medium focus:outline-none focus:ring-2 focus:ring-offset-2",
|
32
|
+
colors: {
|
33
|
+
default: "bg-white text-default-700 border-default-700 hover:bg-default-50",
|
34
|
+
primary: "bg-white text-primary-600 border-primary-600 hover:bg-primary-50",
|
35
|
+
secondary: "bg-white text-secondary-600 border-secondary-600 hover:bg-secondary-50",
|
36
|
+
success: "bg-white text-success-600 border-success-600 hover:bg-success-50",
|
37
|
+
danger: "bg-white text-danger-600 border-danger-600 hover:bg-danger-50",
|
38
|
+
warning: "bg-white text-warning-600 border-warning-600 hover:bg-warning-50",
|
39
|
+
info: "bg-white text-info-600 border-info-600 hover:bg-info-50"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
contained: {
|
43
|
+
root: "inline-flex border items-center justify-center px-4 py-2 font-medium focus:outline-none focus:ring-2 focus:ring-offset-2",
|
44
|
+
colors: {
|
45
|
+
default: "border-default-700 bg-default-600 text-white hover:bg-default-700",
|
46
|
+
primary: "border-primary-700 bg-primary-600 text-white hover:bg-primary-700",
|
47
|
+
secondary: "border-secondary-700 bg-secondary-600 text-white hover:bg-secondary-700",
|
48
|
+
success: "border-success-700 bg-success-600 text-white hover:bg-success-700",
|
49
|
+
danger: "border-danger-700 bg-danger-600 text-white hover:bg-danger-700",
|
50
|
+
warning: "border-warning-700 bg-warning-600 text-white hover:bg-warning-700",
|
51
|
+
info: "border-info-700 bg-info-600 text-white hover:bg-info-700"
|
52
|
+
}
|
53
|
+
},
|
54
|
+
text: {
|
55
|
+
root: "text-base",
|
56
|
+
colors: {
|
57
|
+
default: "text-default-700 hover:underline",
|
58
|
+
primary: "text-primary-600 hover:underline",
|
59
|
+
secondary: "text-secondary-600 hover:underline",
|
60
|
+
success: "text-success-600 hover:underline",
|
61
|
+
danger: "text-danger-600 hover:underline",
|
62
|
+
warning: "text-warning-600 hover:underline",
|
63
|
+
info: "text-info-600 hover:underline"
|
64
|
+
}
|
65
|
+
}
|
66
|
+
},
|
67
|
+
input: {
|
68
|
+
types: {
|
69
|
+
text: {
|
70
|
+
root: "w-full border-0 px-3 py-2 rounded-md ring-1 focus:outline-none focus-within:ring-1",
|
71
|
+
error: "bg-danger-100 text-danger-400 ring-danger-400 focus:ring-danger-600",
|
72
|
+
valid: "text-default-700 ring-gray-300 focus-within:ring-gray-400",
|
73
|
+
disabled: "disabled:bg-gray-50 disabled:cursor-not-allowed"
|
74
|
+
}
|
75
|
+
}
|
76
|
+
},
|
77
|
+
select: {
|
78
|
+
root: "col-start-1 row-start-1 w-full appearance-none rounded-md py-2 pr-8 pl-3 text-base outline-1 focus:outline-none sm:text-sm/6",
|
79
|
+
error: "bg-danger-100 text-danger-400 ring-1 ring-danger-400",
|
80
|
+
valid: "bg-white outline-default-300 text-default-700",
|
81
|
+
wrapper: "grid grid-cols-1",
|
82
|
+
icon: {
|
83
|
+
file: 'heroicons/solid/chevron-down',
|
84
|
+
class: "pointer-events-none col-start-1 row-start-1 mr-2 size-5 self-center justify-self-end text-gray-500 sm:size-4"
|
85
|
+
}
|
86
|
+
},
|
87
|
+
label: {
|
88
|
+
root: "block text-sm/6 font-medium text-default-700"
|
89
|
+
},
|
90
|
+
checkbox: {
|
91
|
+
wrapper: "flex gap-4 items-center",
|
92
|
+
input: {
|
93
|
+
root: "cursor-pointer size-5 rounded-sm border-gray-300 text-primary-600 focus:ring-0 focus:ring-primary-600"
|
94
|
+
},
|
95
|
+
label: {
|
96
|
+
root: "cursor-pointer font-medium text-gray-700"
|
97
|
+
},
|
98
|
+
hint: {
|
99
|
+
root: "cursor-pointer text-sm text-gray-400"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
DEFAULT_THEME = LIGHT_THEME
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module OkonomiUiKit
|
2
|
+
module ThemeHelper
|
3
|
+
def theme(t = {}, &block)
|
4
|
+
old_theme = theme
|
5
|
+
|
6
|
+
@_okonomi_ui_kit_theme = {}.merge(old_theme).merge(t || {})
|
7
|
+
|
8
|
+
yield(@_okonomi_ui_kit_theme)
|
9
|
+
|
10
|
+
@_okonomi_ui_kit_theme = old_theme
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_theme
|
14
|
+
@_okonomi_ui_kit_theme ||= OkonomiUiKit::Theme::DEFAULT_THEME
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|