lightning_ui_kit 0.2.3 → 0.2.5
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 +1 -1
- data/Rakefile +9 -2
- data/app/assets/builds/lightning_ui_kit.css +588 -31
- data/app/assets/builds/lightning_ui_kit.js +9 -2
- data/app/assets/builds/lightning_ui_kit.js.map +4 -4
- data/app/assets/vendor/lightning_ui_kit.css +582 -88
- data/app/assets/vendor/lightning_ui_kit.js +9 -2
- data/app/components/lightning_ui_kit/button_component.html.erb +4 -0
- data/app/components/lightning_ui_kit/button_component.rb +24 -3
- data/app/components/lightning_ui_kit/combobox_component.html.erb +137 -0
- data/app/components/lightning_ui_kit/combobox_component.rb +205 -0
- data/app/components/lightning_ui_kit/dropdown_component.html.erb +1 -1
- data/app/components/lightning_ui_kit/dropdown_component.rb +1 -1
- data/app/components/lightning_ui_kit/dropzone_component.html.erb +13 -38
- data/app/components/lightning_ui_kit/dropzone_component.rb +43 -16
- data/app/components/lightning_ui_kit/file_input_component.html.erb +4 -34
- data/app/components/lightning_ui_kit/file_input_component.rb +54 -20
- data/app/components/lightning_ui_kit/input_component.html.erb +14 -98
- data/app/components/lightning_ui_kit/input_component.rb +154 -19
- data/app/components/lightning_ui_kit/layout_component.html.erb +118 -0
- data/app/components/lightning_ui_kit/layout_component.rb +26 -0
- data/app/components/lightning_ui_kit/modal_component.html.erb +2 -2
- data/app/components/lightning_ui_kit/select_component.html.erb +6 -27
- data/app/components/lightning_ui_kit/select_component.rb +65 -23
- data/app/components/lightning_ui_kit/sidebar_link_component.html.erb +6 -0
- data/app/components/lightning_ui_kit/sidebar_link_component.rb +33 -0
- data/app/components/lightning_ui_kit/sidebar_section_component.html.erb +8 -0
- data/app/components/lightning_ui_kit/sidebar_section_component.rb +18 -0
- data/app/components/lightning_ui_kit/textarea_component.html.erb +5 -37
- data/app/components/lightning_ui_kit/textarea_component.rb +50 -17
- data/app/components/lightning_ui_kit/tooltip_component.html.erb +15 -0
- data/app/components/lightning_ui_kit/tooltip_component.rb +26 -0
- data/app/javascript/lightning_ui_kit/controllers/combobox_controller.js +704 -0
- data/app/javascript/lightning_ui_kit/controllers/field_controller.js +23 -0
- data/app/javascript/lightning_ui_kit/controllers/layout_controller.js +19 -0
- data/app/javascript/lightning_ui_kit/controllers/modal_controller.js +7 -1
- data/app/javascript/lightning_ui_kit/controllers/tooltip_controller.js +235 -0
- data/app/javascript/lightning_ui_kit/index.js +8 -0
- data/config/deploy.yml +2 -5
- data/lib/lightning_ui_kit/engine.rb +1 -6
- data/lib/lightning_ui_kit/version.rb +1 -1
- metadata +17 -17
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class LightningUiKit::SidebarLinkComponent < LightningUiKit::BaseComponent
|
|
4
|
+
def initialize(title:, url:, icon: nil, current: false, **options)
|
|
5
|
+
@title = title
|
|
6
|
+
@url = url
|
|
7
|
+
@icon = icon
|
|
8
|
+
@current = current
|
|
9
|
+
@options = options
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def classes
|
|
13
|
+
base_classes = "lui:flex lui:items-center lui:gap-3 lui:rounded-lg lui:px-3 lui:py-2 lui:text-sm lui:transition-colors"
|
|
14
|
+
|
|
15
|
+
if @current
|
|
16
|
+
merge_classes([base_classes, "lui:bg-zinc-950/5 lui:text-zinc-950 lui:font-semibold", @options[:class]].compact.join(" "))
|
|
17
|
+
else
|
|
18
|
+
merge_classes([base_classes, "lui:text-zinc-600 lui:hover:bg-zinc-950/5 lui:hover:text-zinc-950", @options[:class]].compact.join(" "))
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def icon_classes
|
|
23
|
+
if @current
|
|
24
|
+
"lui:size-5 lui:shrink-0 lui:text-zinc-600"
|
|
25
|
+
else
|
|
26
|
+
"lui:size-5 lui:shrink-0 lui:text-zinc-400"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def data
|
|
31
|
+
@options[:data] || {}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class LightningUiKit::SidebarSectionComponent < LightningUiKit::BaseComponent
|
|
4
|
+
renders_many :links, LightningUiKit::SidebarLinkComponent
|
|
5
|
+
|
|
6
|
+
def initialize(title: nil, **options)
|
|
7
|
+
@title = title
|
|
8
|
+
@options = options
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def classes
|
|
12
|
+
merge_classes(["lui:space-y-1", @options[:class]].compact.join(" "))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def title_classes
|
|
16
|
+
"lui:px-3 lui:py-2 lui:text-xs lui:font-medium lui:text-zinc-400 lui:uppercase lui:tracking-wider"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
class: "lui:[&>[data-slot=label]+[data-slot=control]]:mt-3 lui:[&>[data-slot=label]+[data-slot=description]]:mt-1
|
|
3
3
|
lui:[&>[data-slot=description]+[data-slot=control]]:mt-3 lui:[&>[data-slot=control]+[data-slot=description]]:mt-3
|
|
4
4
|
lui:[&>[data-slot=control]+[data-slot=error]]:mt-3 lui:*:data-[slot=label]:font-medium",
|
|
5
|
-
data:
|
|
5
|
+
data: data
|
|
6
6
|
) do %>
|
|
7
|
-
|
|
8
|
-
<%= tag.label(
|
|
9
|
-
@label,
|
|
10
|
-
class: "lui:text-base/6 lui:text-zinc-950 lui:select-none lui:data-disabled:opacity-50 lui:sm:text-sm/6",
|
|
11
|
-
data: label_data
|
|
12
|
-
) %>
|
|
13
|
-
<% end %>
|
|
7
|
+
<%= render_label %>
|
|
14
8
|
<% if @description %>
|
|
15
9
|
<%= tag.p(
|
|
16
10
|
@description,
|
|
@@ -18,35 +12,9 @@
|
|
|
18
12
|
data: description_data
|
|
19
13
|
) %>
|
|
20
14
|
<% end %>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@name,
|
|
25
|
-
value: @value,
|
|
26
|
-
rows: @rows,
|
|
27
|
-
cols: @cols,
|
|
28
|
-
multiple: @multiple,
|
|
29
|
-
data: input_data,
|
|
30
|
-
class: "lui:relative lui:block lui:w-full lui:appearance-none lui:rounded-lg lui:px-[calc(--spacing(3.5)-1px)] lui:py-[calc(--spacing(2.5)-1px)] lui:sm:px-[calc(--spacing(3)-1px)] lui:sm:py-[calc(--spacing(1.5)-1px)] lui:text-base/6 lui:text-zinc-950 lui:placeholder:text-zinc-500 lui:sm:text-sm/6 lui:border lui:border-zinc-950/10 lui:hover:border-zinc-950/20 lui:bg-transparent lui:focus:outline-hidden lui:data-invalid:border-red-500 lui:data-invalid:hover:border-red-500 lui:data-disabled:border-zinc-950/20",
|
|
31
|
-
disabled: @disabled,
|
|
32
|
-
autofocus: @autofocus
|
|
33
|
-
) %>
|
|
34
|
-
</span>
|
|
35
|
-
<% else %>
|
|
36
|
-
<span data-slot="control" class="lui:relative lui:block lui:w-full lui:before:absolute lui:before:inset-px lui:before:rounded-[calc(var(--radius-lg)-1px)] lui:before:bg-white lui:before:shadow-sm lui:after:pointer-events-none lui:after:absolute lui:after:inset-0 lui:after:rounded-lg lui:after:ring-transparent lui:after:ring-inset lui:sm:focus-within:after:ring-2 lui:sm:focus-within:after:ring-blue-500 lui:has-data-disabled:opacity-50 lui:has-data-disabled:before:bg-zinc-950/5 lui:has-data-disabled:before:shadow-none lui:has-data-invalid:before:shadow-red-500/10">
|
|
37
|
-
<%= text_area_tag(
|
|
38
|
-
@name,
|
|
39
|
-
@value,
|
|
40
|
-
rows: @rows,
|
|
41
|
-
cols: @cols,
|
|
42
|
-
multiple: @multiple,
|
|
43
|
-
data: input_data,
|
|
44
|
-
class: "lui:relative lui:block lui:w-full lui:appearance-none lui:rounded-lg lui:px-[calc(--spacing(3.5)-1px)] lui:py-[calc(--spacing(2.5)-1px)] lui:sm:px-[calc(--spacing(3)-1px)] lui:sm:py-[calc(--spacing(1.5)-1px)] lui:text-base/6 lui:text-zinc-950 lui:placeholder:text-zinc-500 lui:sm:text-sm/6 lui:border lui:border-zinc-950/10 lui:hover:border-zinc-950/20 lui:bg-transparent lui:focus:outline-hidden lui:data-invalid:border-red-500 lui:data-invalid:hover:border-red-500 lui:data-disabled:border-zinc-950/20",
|
|
45
|
-
disabled: @disabled,
|
|
46
|
-
autofocus: @autofocus
|
|
47
|
-
) %>
|
|
48
|
-
</span>
|
|
49
|
-
<% end %>
|
|
15
|
+
<span data-slot="control" class="<%= control_classes %>">
|
|
16
|
+
<%= render_textarea %>
|
|
17
|
+
</span>
|
|
50
18
|
<% if has_errors? %>
|
|
51
19
|
<%= tag.p(
|
|
52
20
|
error_messages,
|
|
@@ -20,38 +20,71 @@ class LightningUiKit::TextareaComponent < LightningUiKit::BaseComponent
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def data
|
|
23
|
-
@options[:data] || {}
|
|
23
|
+
{controller: "lui-field"}.merge(@options[:data] || {})
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def input_data
|
|
27
|
-
(@options[:input_data] || {}).tap do |data|
|
|
28
|
-
if has_errors?
|
|
29
|
-
data[:invalid] = "true"
|
|
30
|
-
end
|
|
27
|
+
{lui_field_target: "field"}.merge(@options[:input_data] || {}).dup.tap do |data|
|
|
28
|
+
data[:invalid] = "true" if has_errors?
|
|
31
29
|
end
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
def label_data
|
|
35
|
-
{slot: "label"}.merge(@options[:label_data] || {}).tap do |data|
|
|
36
|
-
if @disabled
|
|
37
|
-
data[:disabled] = "true"
|
|
38
|
-
end
|
|
33
|
+
{slot: "label"}.merge(@options[:label_data] || {}).dup.tap do |data|
|
|
34
|
+
data[:disabled] = "true" if @disabled
|
|
39
35
|
end
|
|
40
36
|
end
|
|
41
37
|
|
|
42
38
|
def description_data
|
|
43
|
-
{slot: "description"}.merge(@options[:description_data] || {}).tap do |data|
|
|
44
|
-
if @disabled
|
|
45
|
-
data[:disabled] = "true"
|
|
46
|
-
end
|
|
39
|
+
{slot: "description"}.merge(@options[:description_data] || {}).dup.tap do |data|
|
|
40
|
+
data[:disabled] = "true" if @disabled
|
|
47
41
|
end
|
|
48
42
|
end
|
|
49
43
|
|
|
50
44
|
def error_data
|
|
51
|
-
{slot: "error"}.merge(@options[:error_data] || {}).tap do |data|
|
|
52
|
-
if @disabled
|
|
53
|
-
data[:disabled] = "true"
|
|
54
|
-
end
|
|
45
|
+
{slot: "error"}.merge(@options[:error_data] || {}).dup.tap do |data|
|
|
46
|
+
data[:disabled] = "true" if @disabled
|
|
55
47
|
end
|
|
56
48
|
end
|
|
49
|
+
|
|
50
|
+
def label_html_options
|
|
51
|
+
{
|
|
52
|
+
class: "lui:text-base/6 lui:text-zinc-950 lui:select-none lui:data-disabled:opacity-50 lui:sm:text-sm/6",
|
|
53
|
+
data: label_data
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def render_label
|
|
58
|
+
return unless @label
|
|
59
|
+
|
|
60
|
+
if @form
|
|
61
|
+
@form.label(@name, @label, **label_html_options)
|
|
62
|
+
else
|
|
63
|
+
helpers.label_tag(@name, @label, **label_html_options)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def textarea_html_options
|
|
68
|
+
{
|
|
69
|
+
rows: @rows,
|
|
70
|
+
cols: @cols,
|
|
71
|
+
multiple: @multiple,
|
|
72
|
+
data: input_data,
|
|
73
|
+
class: "lui:relative lui:block lui:w-full lui:appearance-none lui:rounded-lg lui:px-[calc(--spacing(3.5)-1px)] lui:py-[calc(--spacing(2.5)-1px)] lui:sm:px-[calc(--spacing(3)-1px)] lui:sm:py-[calc(--spacing(1.5)-1px)] lui:text-base/6 lui:text-zinc-950 lui:placeholder:text-zinc-500 lui:sm:text-sm/6 lui:border lui:border-zinc-950/10 lui:data-[hover]:border-zinc-950/20 lui:bg-transparent lui:focus:outline-hidden lui:data-invalid:border-red-500 lui:data-invalid:data-[hover]:border-red-500 lui:data-disabled:border-zinc-950/20",
|
|
74
|
+
disabled: @disabled,
|
|
75
|
+
autofocus: @autofocus
|
|
76
|
+
}
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def render_textarea
|
|
80
|
+
if @form
|
|
81
|
+
@form.text_area(@name, **textarea_html_options)
|
|
82
|
+
else
|
|
83
|
+
helpers.text_area_tag(@name, @value, **textarea_html_options)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def control_classes
|
|
88
|
+
"lui:relative lui:block lui:w-full lui:before:absolute lui:before:inset-px lui:before:rounded-[7px] lui:before:bg-white lui:before:shadow-sm lui:after:pointer-events-none lui:after:absolute lui:after:inset-0 lui:after:rounded-lg lui:after:ring-transparent lui:after:ring-inset lui:sm:focus-within:after:ring-2 lui:sm:focus-within:after:ring-blue-500 lui:has-data-disabled:opacity-50 lui:has-data-disabled:before:bg-zinc-950/5 lui:has-data-disabled:before:shadow-none lui:has-data-invalid:before:shadow-red-500/10"
|
|
89
|
+
end
|
|
57
90
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<%= tag.div(
|
|
2
|
+
data: data.merge({
|
|
3
|
+
"lui-tooltip-active-value" => @active,
|
|
4
|
+
"lui-tooltip-position-value" => @position
|
|
5
|
+
}),
|
|
6
|
+
class: "lui:inline-block") do %>
|
|
7
|
+
<%= content %>
|
|
8
|
+
|
|
9
|
+
<%= tag.div(data: { "lui-tooltip-target" => "template" }, class: "lui:hidden") do %>
|
|
10
|
+
<%= tag.div( class: "lui:absolute lui:z-50 lui:px-3 lui:py-2 lui:text-sm lui:font-medium lui:text-white lui:bg-zinc-800 lui:rounded-lg lui:shadow-sm lui:opacity-0 lui:transition-opacity lui:duration-200 lui:ease-in-out") do %>
|
|
11
|
+
<%= @text %>
|
|
12
|
+
<%= tag.div( class: "tooltip-arrow lui:absolute lui:w-2 lui:h-2 lui:bg-zinc-800 lui:transform lui:rotate-45", data: { "tooltip-arrow" => "true" }) %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
15
|
+
<% end %>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class LightningUiKit::TooltipComponent < LightningUiKit::BaseComponent
|
|
4
|
+
POSITION_OPTIONS = [:top, :bottom, :left, :right]
|
|
5
|
+
DEFAULT_POSITION = :bottom
|
|
6
|
+
|
|
7
|
+
def initialize(text: nil, position: DEFAULT_POSITION, active: true, **options)
|
|
8
|
+
@text = text
|
|
9
|
+
@position = position || DEFAULT_POSITION
|
|
10
|
+
@active = active
|
|
11
|
+
@options = options
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def classes
|
|
15
|
+
merge_classes(["lui:w-full lui:flex lui:justify-center lui:fixed lui:bottom-5", @options[:class]].compact.join(" "))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def data
|
|
19
|
+
default_data = {
|
|
20
|
+
controller: "lui-tooltip",
|
|
21
|
+
action: "mouseenter->lui-tooltip#show mouseleave->lui-tooltip#hide focus->lui-tooltip#show blur->lui-tooltip#hide"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
default_data.merge(@options[:data] || {})
|
|
25
|
+
end
|
|
26
|
+
end
|