stimulus_plumbers 0.2.7 → 0.2.9
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/CHANGELOG.md +59 -0
- data/README.md +60 -41
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +760 -237
- data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -1
- data/lib/stimulus_plumbers/components/action_list/item.rb +27 -0
- data/lib/stimulus_plumbers/components/action_list/section.rb +21 -0
- data/lib/stimulus_plumbers/components/action_list.rb +23 -0
- data/lib/stimulus_plumbers/components/avatar.rb +72 -0
- data/lib/stimulus_plumbers/components/button/group.rb +17 -0
- data/lib/stimulus_plumbers/components/button.rb +27 -0
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb +2 -2
- data/lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb +2 -2
- data/lib/stimulus_plumbers/components/calendar/month/turbo.rb +55 -0
- data/lib/stimulus_plumbers/components/calendar.rb +33 -0
- data/lib/stimulus_plumbers/components/card/section.rb +25 -0
- data/lib/stimulus_plumbers/components/card.rb +27 -0
- data/lib/stimulus_plumbers/components/combobox/autocomplete.rb +53 -0
- data/lib/stimulus_plumbers/components/combobox/date.rb +50 -0
- data/lib/stimulus_plumbers/components/combobox/dropdown.rb +38 -0
- data/lib/stimulus_plumbers/components/combobox/options/option.rb +34 -0
- data/lib/stimulus_plumbers/components/combobox/options/option_group.rb +29 -0
- data/lib/stimulus_plumbers/components/combobox/options.rb +59 -0
- data/lib/stimulus_plumbers/components/combobox/popover.rb +20 -0
- data/lib/stimulus_plumbers/components/combobox/time/drum.rb +37 -0
- data/lib/stimulus_plumbers/components/combobox/time.rb +120 -0
- data/lib/stimulus_plumbers/components/combobox/trigger.rb +38 -0
- data/lib/stimulus_plumbers/components/combobox.rb +59 -0
- data/lib/stimulus_plumbers/components/date_picker/navigation.rb +1 -1
- data/lib/stimulus_plumbers/components/date_picker/navigator.rb +1 -1
- data/lib/stimulus_plumbers/components/icon.rb +49 -0
- data/lib/stimulus_plumbers/components/popover/builder.rb +25 -0
- data/lib/stimulus_plumbers/components/popover.rb +26 -0
- data/lib/stimulus_plumbers/form/builder.rb +64 -17
- data/lib/stimulus_plumbers/form/{field_component.rb → field.rb} +13 -11
- data/lib/stimulus_plumbers/form/fields/combobox.rb +41 -0
- data/lib/stimulus_plumbers/form/fields/error.rb +14 -0
- data/lib/stimulus_plumbers/form/fields/group.rb +14 -0
- data/lib/stimulus_plumbers/form/fields/hint.rb +14 -0
- data/lib/stimulus_plumbers/form/fields/label.rb +21 -0
- data/lib/stimulus_plumbers/form/fields/password.rb +55 -0
- data/lib/stimulus_plumbers/form/fields/renderer.rb +16 -21
- data/lib/stimulus_plumbers/form/fields/search.rb +54 -0
- data/lib/stimulus_plumbers/form/fields/select.rb +8 -2
- data/lib/stimulus_plumbers/form/fields/submit.rb +23 -0
- data/lib/stimulus_plumbers/form/fields/text.rb +12 -4
- data/lib/stimulus_plumbers/helpers/action_list_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/avatar_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/button_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/calendar_helper.rb +1 -1
- data/lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb +1 -1
- data/lib/stimulus_plumbers/helpers/card_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers/combobox_helper.rb +74 -0
- data/lib/stimulus_plumbers/helpers/popover_helper.rb +2 -2
- data/lib/stimulus_plumbers/helpers.rb +2 -2
- data/lib/stimulus_plumbers/plumber/base.rb +20 -0
- data/lib/stimulus_plumbers/plumber/dispatcher.rb +111 -0
- data/lib/stimulus_plumbers/plumber/html_options.rb +51 -0
- data/lib/stimulus_plumbers/plumber/renderer.rb +89 -0
- data/lib/stimulus_plumbers/themes/base.rb +9 -15
- data/lib/stimulus_plumbers/themes/schema/ranges.rb +5 -5
- data/lib/stimulus_plumbers/themes/schema.rb +97 -0
- data/lib/stimulus_plumbers/themes/tailwind/calendar.rb +48 -2
- data/lib/stimulus_plumbers/themes/tailwind/combobox.rb +75 -0
- data/lib/stimulus_plumbers/themes/tailwind/form.rb +10 -6
- data/lib/stimulus_plumbers/themes/tailwind_theme.rb +2 -0
- data/lib/stimulus_plumbers/version.rb +1 -1
- data/lib/stimulus_plumbers.rb +41 -14
- metadata +42 -23
- data/lib/stimulus_plumbers/components/action_list/renderer.rb +0 -47
- data/lib/stimulus_plumbers/components/avatar/renderer.rb +0 -74
- data/lib/stimulus_plumbers/components/button/renderer.rb +0 -33
- data/lib/stimulus_plumbers/components/calendar/month/turbo/renderer.rb +0 -57
- data/lib/stimulus_plumbers/components/calendar/renderer.rb +0 -35
- data/lib/stimulus_plumbers/components/card/renderer.rb +0 -41
- data/lib/stimulus_plumbers/components/date_picker/renderer.rb +0 -82
- data/lib/stimulus_plumbers/components/icon/renderer.rb +0 -51
- data/lib/stimulus_plumbers/components/plumber/base.rb +0 -22
- data/lib/stimulus_plumbers/components/plumber/dispatcher.rb +0 -113
- data/lib/stimulus_plumbers/components/plumber/html_options.rb +0 -34
- data/lib/stimulus_plumbers/components/plumber/renderer.rb +0 -91
- data/lib/stimulus_plumbers/components/popover/renderer.rb +0 -46
- data/lib/stimulus_plumbers/helpers/date_picker_helper.rb +0 -17
- data/lib/stimulus_plumbers/themes/action_list.rb +0 -14
- data/lib/stimulus_plumbers/themes/avatar.rb +0 -14
- data/lib/stimulus_plumbers/themes/button.rb +0 -18
- data/lib/stimulus_plumbers/themes/calendar.rb +0 -15
- data/lib/stimulus_plumbers/themes/card.rb +0 -12
- data/lib/stimulus_plumbers/themes/form.rb +0 -30
- data/lib/stimulus_plumbers/themes/layout.rb +0 -12
data/lib/stimulus_plumbers.rb
CHANGED
|
@@ -5,32 +5,59 @@ require_relative "stimulus_plumbers/version"
|
|
|
5
5
|
require "active_support"
|
|
6
6
|
require "active_support/core_ext/string"
|
|
7
7
|
|
|
8
|
+
# -- Core infrastructure --
|
|
8
9
|
require_relative "stimulus_plumbers/configuration"
|
|
9
10
|
require_relative "stimulus_plumbers/helpers"
|
|
10
11
|
require_relative "stimulus_plumbers/logger"
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
require_relative "stimulus_plumbers/
|
|
14
|
-
require_relative "stimulus_plumbers/
|
|
15
|
-
require_relative "stimulus_plumbers/
|
|
13
|
+
# -- Plumber base --
|
|
14
|
+
require_relative "stimulus_plumbers/plumber/html_options"
|
|
15
|
+
require_relative "stimulus_plumbers/plumber/dispatcher"
|
|
16
|
+
require_relative "stimulus_plumbers/plumber/renderer"
|
|
17
|
+
require_relative "stimulus_plumbers/plumber/base"
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
require_relative "stimulus_plumbers/components/
|
|
19
|
-
require_relative "stimulus_plumbers/components/
|
|
20
|
-
require_relative "stimulus_plumbers/components/
|
|
21
|
-
require_relative "stimulus_plumbers/components/
|
|
22
|
-
require_relative "stimulus_plumbers/components/
|
|
19
|
+
# -- UI components --
|
|
20
|
+
require_relative "stimulus_plumbers/components/icon"
|
|
21
|
+
require_relative "stimulus_plumbers/components/avatar"
|
|
22
|
+
require_relative "stimulus_plumbers/components/button"
|
|
23
|
+
require_relative "stimulus_plumbers/components/button/group"
|
|
24
|
+
require_relative "stimulus_plumbers/components/card"
|
|
25
|
+
require_relative "stimulus_plumbers/components/card/section"
|
|
26
|
+
require_relative "stimulus_plumbers/components/action_list"
|
|
27
|
+
require_relative "stimulus_plumbers/components/action_list/section"
|
|
28
|
+
require_relative "stimulus_plumbers/components/action_list/item"
|
|
29
|
+
require_relative "stimulus_plumbers/components/popover"
|
|
30
|
+
require_relative "stimulus_plumbers/components/popover/builder"
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
# -- Calendar --
|
|
33
|
+
require_relative "stimulus_plumbers/components/calendar"
|
|
34
|
+
require_relative "stimulus_plumbers/components/calendar/month/turbo"
|
|
25
35
|
require_relative "stimulus_plumbers/components/calendar/month/turbo/days_of_week"
|
|
26
36
|
require_relative "stimulus_plumbers/components/calendar/month/turbo/days_of_month"
|
|
27
|
-
require_relative "stimulus_plumbers/components/calendar/month/turbo/renderer"
|
|
28
37
|
|
|
38
|
+
# -- Date picker --
|
|
29
39
|
require_relative "stimulus_plumbers/components/date_picker/navigator"
|
|
30
40
|
require_relative "stimulus_plumbers/components/date_picker/navigation"
|
|
31
|
-
require_relative "stimulus_plumbers/components/date_picker/renderer"
|
|
32
41
|
|
|
33
|
-
|
|
42
|
+
# -- Combobox --
|
|
43
|
+
require_relative "stimulus_plumbers/components/combobox"
|
|
44
|
+
require_relative "stimulus_plumbers/components/combobox/trigger"
|
|
45
|
+
require_relative "stimulus_plumbers/components/combobox/popover"
|
|
46
|
+
require_relative "stimulus_plumbers/components/combobox/options"
|
|
47
|
+
require_relative "stimulus_plumbers/components/combobox/options/option"
|
|
48
|
+
require_relative "stimulus_plumbers/components/combobox/options/option_group"
|
|
49
|
+
require_relative "stimulus_plumbers/components/combobox/date"
|
|
50
|
+
require_relative "stimulus_plumbers/components/combobox/dropdown"
|
|
51
|
+
require_relative "stimulus_plumbers/components/combobox/autocomplete"
|
|
52
|
+
require_relative "stimulus_plumbers/components/combobox/time"
|
|
53
|
+
require_relative "stimulus_plumbers/components/combobox/time/drum"
|
|
54
|
+
|
|
55
|
+
# -- Form --
|
|
56
|
+
require_relative "stimulus_plumbers/form/field"
|
|
57
|
+
require_relative "stimulus_plumbers/form/fields/group"
|
|
58
|
+
require_relative "stimulus_plumbers/form/fields/label"
|
|
59
|
+
require_relative "stimulus_plumbers/form/fields/hint"
|
|
60
|
+
require_relative "stimulus_plumbers/form/fields/error"
|
|
34
61
|
require_relative "stimulus_plumbers/form/builder"
|
|
35
62
|
|
|
36
63
|
module StimulusPlumbers
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stimulus_plumbers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Chang
|
|
@@ -37,37 +37,57 @@ executables: []
|
|
|
37
37
|
extensions: []
|
|
38
38
|
extra_rdoc_files: []
|
|
39
39
|
files:
|
|
40
|
+
- CHANGELOG.md
|
|
40
41
|
- README.md
|
|
41
42
|
- app/assets/javascripts/stimulus-plumbers/.keep
|
|
42
43
|
- app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js
|
|
43
44
|
- app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js
|
|
44
45
|
- app/assets/stylesheets/stimulus_plumbers/tokens.css
|
|
45
46
|
- lib/stimulus_plumbers.rb
|
|
46
|
-
- lib/stimulus_plumbers/components/action_list
|
|
47
|
-
- lib/stimulus_plumbers/components/
|
|
48
|
-
- lib/stimulus_plumbers/components/
|
|
47
|
+
- lib/stimulus_plumbers/components/action_list.rb
|
|
48
|
+
- lib/stimulus_plumbers/components/action_list/item.rb
|
|
49
|
+
- lib/stimulus_plumbers/components/action_list/section.rb
|
|
50
|
+
- lib/stimulus_plumbers/components/avatar.rb
|
|
51
|
+
- lib/stimulus_plumbers/components/button.rb
|
|
52
|
+
- lib/stimulus_plumbers/components/button/group.rb
|
|
53
|
+
- lib/stimulus_plumbers/components/calendar.rb
|
|
54
|
+
- lib/stimulus_plumbers/components/calendar/month/turbo.rb
|
|
49
55
|
- lib/stimulus_plumbers/components/calendar/month/turbo/days_of_month.rb
|
|
50
56
|
- lib/stimulus_plumbers/components/calendar/month/turbo/days_of_week.rb
|
|
51
|
-
- lib/stimulus_plumbers/components/
|
|
52
|
-
- lib/stimulus_plumbers/components/
|
|
53
|
-
- lib/stimulus_plumbers/components/
|
|
57
|
+
- lib/stimulus_plumbers/components/card.rb
|
|
58
|
+
- lib/stimulus_plumbers/components/card/section.rb
|
|
59
|
+
- lib/stimulus_plumbers/components/combobox.rb
|
|
60
|
+
- lib/stimulus_plumbers/components/combobox/autocomplete.rb
|
|
61
|
+
- lib/stimulus_plumbers/components/combobox/date.rb
|
|
62
|
+
- lib/stimulus_plumbers/components/combobox/dropdown.rb
|
|
63
|
+
- lib/stimulus_plumbers/components/combobox/options.rb
|
|
64
|
+
- lib/stimulus_plumbers/components/combobox/options/option.rb
|
|
65
|
+
- lib/stimulus_plumbers/components/combobox/options/option_group.rb
|
|
66
|
+
- lib/stimulus_plumbers/components/combobox/popover.rb
|
|
67
|
+
- lib/stimulus_plumbers/components/combobox/time.rb
|
|
68
|
+
- lib/stimulus_plumbers/components/combobox/time/drum.rb
|
|
69
|
+
- lib/stimulus_plumbers/components/combobox/trigger.rb
|
|
54
70
|
- lib/stimulus_plumbers/components/date_picker/navigation.rb
|
|
55
71
|
- lib/stimulus_plumbers/components/date_picker/navigator.rb
|
|
56
|
-
- lib/stimulus_plumbers/components/
|
|
57
|
-
- lib/stimulus_plumbers/components/
|
|
58
|
-
- lib/stimulus_plumbers/components/
|
|
59
|
-
- lib/stimulus_plumbers/components/plumber/dispatcher.rb
|
|
60
|
-
- lib/stimulus_plumbers/components/plumber/html_options.rb
|
|
61
|
-
- lib/stimulus_plumbers/components/plumber/renderer.rb
|
|
62
|
-
- lib/stimulus_plumbers/components/popover/renderer.rb
|
|
72
|
+
- lib/stimulus_plumbers/components/icon.rb
|
|
73
|
+
- lib/stimulus_plumbers/components/popover.rb
|
|
74
|
+
- lib/stimulus_plumbers/components/popover/builder.rb
|
|
63
75
|
- lib/stimulus_plumbers/configuration.rb
|
|
64
76
|
- lib/stimulus_plumbers/engine.rb
|
|
65
77
|
- lib/stimulus_plumbers/form/builder.rb
|
|
66
|
-
- lib/stimulus_plumbers/form/
|
|
78
|
+
- lib/stimulus_plumbers/form/field.rb
|
|
67
79
|
- lib/stimulus_plumbers/form/fields/choice.rb
|
|
80
|
+
- lib/stimulus_plumbers/form/fields/combobox.rb
|
|
81
|
+
- lib/stimulus_plumbers/form/fields/error.rb
|
|
68
82
|
- lib/stimulus_plumbers/form/fields/file.rb
|
|
83
|
+
- lib/stimulus_plumbers/form/fields/group.rb
|
|
84
|
+
- lib/stimulus_plumbers/form/fields/hint.rb
|
|
85
|
+
- lib/stimulus_plumbers/form/fields/label.rb
|
|
86
|
+
- lib/stimulus_plumbers/form/fields/password.rb
|
|
69
87
|
- lib/stimulus_plumbers/form/fields/renderer.rb
|
|
88
|
+
- lib/stimulus_plumbers/form/fields/search.rb
|
|
70
89
|
- lib/stimulus_plumbers/form/fields/select.rb
|
|
90
|
+
- lib/stimulus_plumbers/form/fields/submit.rb
|
|
71
91
|
- lib/stimulus_plumbers/form/fields/text.rb
|
|
72
92
|
- lib/stimulus_plumbers/form/fields/text_area.rb
|
|
73
93
|
- lib/stimulus_plumbers/helpers.rb
|
|
@@ -77,24 +97,23 @@ files:
|
|
|
77
97
|
- lib/stimulus_plumbers/helpers/calendar_helper.rb
|
|
78
98
|
- lib/stimulus_plumbers/helpers/calendar_turbo_helper.rb
|
|
79
99
|
- lib/stimulus_plumbers/helpers/card_helper.rb
|
|
80
|
-
- lib/stimulus_plumbers/helpers/
|
|
100
|
+
- lib/stimulus_plumbers/helpers/combobox_helper.rb
|
|
81
101
|
- lib/stimulus_plumbers/helpers/plumber_helper.rb
|
|
82
102
|
- lib/stimulus_plumbers/helpers/popover_helper.rb
|
|
83
103
|
- lib/stimulus_plumbers/logger.rb
|
|
84
|
-
- lib/stimulus_plumbers/
|
|
85
|
-
- lib/stimulus_plumbers/
|
|
104
|
+
- lib/stimulus_plumbers/plumber/base.rb
|
|
105
|
+
- lib/stimulus_plumbers/plumber/dispatcher.rb
|
|
106
|
+
- lib/stimulus_plumbers/plumber/html_options.rb
|
|
107
|
+
- lib/stimulus_plumbers/plumber/renderer.rb
|
|
86
108
|
- lib/stimulus_plumbers/themes/base.rb
|
|
87
|
-
- lib/stimulus_plumbers/themes/
|
|
88
|
-
- lib/stimulus_plumbers/themes/calendar.rb
|
|
89
|
-
- lib/stimulus_plumbers/themes/card.rb
|
|
90
|
-
- lib/stimulus_plumbers/themes/form.rb
|
|
91
|
-
- lib/stimulus_plumbers/themes/layout.rb
|
|
109
|
+
- lib/stimulus_plumbers/themes/schema.rb
|
|
92
110
|
- lib/stimulus_plumbers/themes/schema/ranges.rb
|
|
93
111
|
- lib/stimulus_plumbers/themes/tailwind/action_list.rb
|
|
94
112
|
- lib/stimulus_plumbers/themes/tailwind/avatar.rb
|
|
95
113
|
- lib/stimulus_plumbers/themes/tailwind/button.rb
|
|
96
114
|
- lib/stimulus_plumbers/themes/tailwind/calendar.rb
|
|
97
115
|
- lib/stimulus_plumbers/themes/tailwind/card.rb
|
|
116
|
+
- lib/stimulus_plumbers/themes/tailwind/combobox.rb
|
|
98
117
|
- lib/stimulus_plumbers/themes/tailwind/form.rb
|
|
99
118
|
- lib/stimulus_plumbers/themes/tailwind/layout.rb
|
|
100
119
|
- lib/stimulus_plumbers/themes/tailwind_theme.rb
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module ActionList
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def list(**kwargs, &block)
|
|
8
|
-
html_options = merge_html_options(
|
|
9
|
-
{ classes: theme.resolve(:action_list).fetch(:classes, "") },
|
|
10
|
-
kwargs
|
|
11
|
-
)
|
|
12
|
-
template.content_tag(:div, template.capture(&block), **html_options)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def section(title: nil, **kwargs, &block)
|
|
16
|
-
html_options = merge_html_options(kwargs)
|
|
17
|
-
template.content_tag(:div, **html_options) do
|
|
18
|
-
template.safe_join(
|
|
19
|
-
[
|
|
20
|
-
(template.content_tag(:p, title) if title.present?),
|
|
21
|
-
template.content_tag(:ul, template.capture(&block))
|
|
22
|
-
].compact
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def item(content = nil, url: nil, external: false, active: false, **kwargs, &block)
|
|
28
|
-
content = template.capture(&block) if block_given?
|
|
29
|
-
html_options = merge_html_options(
|
|
30
|
-
{ classes: theme.resolve(:action_list_item, active: active).fetch(:classes, "") },
|
|
31
|
-
kwargs
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
inner = if url
|
|
35
|
-
html_options[:target] = "_blank" if external
|
|
36
|
-
template.content_tag(:a, content, href: url, **html_options)
|
|
37
|
-
else
|
|
38
|
-
html_options[:type] ||= "button"
|
|
39
|
-
template.content_tag(:button, content, **html_options)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
template.content_tag(:li, inner)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Avatar
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def avatar(name: nil, initials: nil, url: nil, color: nil, size: :md, **kwargs, &block)
|
|
8
|
-
color_css = resolve_color(color, name, initials) unless url || block_given?
|
|
9
|
-
|
|
10
|
-
html_options = merge_html_options(
|
|
11
|
-
{
|
|
12
|
-
classes: [theme.resolve(:avatar, size: size).fetch(:classes, ""), color_css],
|
|
13
|
-
"aria-label": name,
|
|
14
|
-
role: "img"
|
|
15
|
-
},
|
|
16
|
-
kwargs
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
template.content_tag(:span, inner(name, initials, url, &block), **html_options)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
def inner(name, initials, url, &block)
|
|
25
|
-
if block_given?
|
|
26
|
-
template.capture(&block)
|
|
27
|
-
elsif url
|
|
28
|
-
template.tag.img(src: url, alt: name.present? ? "#{name}'s avatar" : "", onerror: "this.src=''")
|
|
29
|
-
elsif initials
|
|
30
|
-
initials_svg(initials)
|
|
31
|
-
else
|
|
32
|
-
fallback_svg
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def resolve_color(color, name, initials)
|
|
37
|
-
if color
|
|
38
|
-
theme.avatar_colors.fetch(color, nil)
|
|
39
|
-
elsif (seed = name || initials)
|
|
40
|
-
theme.avatar_color_range[seed.bytes.reduce(:^) % theme.avatar_color_range.length]
|
|
41
|
-
else
|
|
42
|
-
theme.avatar_color_range.first
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def initials_svg(initials)
|
|
47
|
-
template.content_tag(:svg, viewBox: "0 0 40 40") do
|
|
48
|
-
template.content_tag(
|
|
49
|
-
:text,
|
|
50
|
-
initials.upcase,
|
|
51
|
-
x: "50%",
|
|
52
|
-
y: "50%",
|
|
53
|
-
dy: "0.35em",
|
|
54
|
-
fill: "currentColor",
|
|
55
|
-
"font-size": "20",
|
|
56
|
-
"text-anchor": "middle"
|
|
57
|
-
)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def fallback_svg
|
|
62
|
-
template.content_tag(:svg, viewBox: "0 0 40 40") do
|
|
63
|
-
template.tag.path(
|
|
64
|
-
fill: "currentColor",
|
|
65
|
-
d: "M8.28 27.5A14.95 14.95 0 0120 21.8c4.76 0 8.97 2.24 11.72 5.7a14.02 " \
|
|
66
|
-
"14.02 0 01-8.25 5.91 14.82 14.82 0 01-6.94 0 14.02 14.02 0 01-8.25-5.9z" \
|
|
67
|
-
"M13.99 12.78a6.02 6.02 0 1112.03 0 6.02 6.02 0 01-12.03 0z"
|
|
68
|
-
)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Button
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def button(content = nil, url: nil, external: false, variant: :primary, size: :md, **kwargs, &block)
|
|
8
|
-
content = template.capture(&block) if block_given?
|
|
9
|
-
html_options = merge_html_options(
|
|
10
|
-
{ classes: theme.resolve(:button, variant: variant, size: size).fetch(:classes, "") },
|
|
11
|
-
kwargs
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
if url
|
|
15
|
-
html_options[:target] = "_blank" if external
|
|
16
|
-
template.content_tag(:a, content, href: url, **html_options)
|
|
17
|
-
else
|
|
18
|
-
html_options[:type] ||= "button"
|
|
19
|
-
template.content_tag(:button, content, **html_options)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def group(alignment: :left, direction: :row, **kwargs, &block)
|
|
24
|
-
html_options = merge_html_options(
|
|
25
|
-
{ classes: theme.resolve(:button_group, alignment: alignment, direction: direction).fetch(:classes, "") },
|
|
26
|
-
kwargs
|
|
27
|
-
)
|
|
28
|
-
template.content_tag(:div, template.capture(&block), **html_options)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Calendar
|
|
6
|
-
module Month
|
|
7
|
-
module Turbo
|
|
8
|
-
class Renderer < Plumber::Base
|
|
9
|
-
STIMULUS_CONTROLLER = "calendar-month-observer"
|
|
10
|
-
|
|
11
|
-
def render(
|
|
12
|
-
date: Date.today,
|
|
13
|
-
today: Date.today,
|
|
14
|
-
selectable: false,
|
|
15
|
-
selected_date: nil,
|
|
16
|
-
show_other_months: false,
|
|
17
|
-
**kwargs
|
|
18
|
-
)
|
|
19
|
-
html_options = merge_html_options(
|
|
20
|
-
{
|
|
21
|
-
classes: theme.resolve(:calendar).fetch(:classes, ""),
|
|
22
|
-
data: { controller: STIMULUS_CONTROLLER, action: "click->#{STIMULUS_CONTROLLER}#select" }
|
|
23
|
-
},
|
|
24
|
-
kwargs
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
template.content_tag(:div, role: "grid", **html_options) do
|
|
28
|
-
template.safe_join(
|
|
29
|
-
[
|
|
30
|
-
days_of_week,
|
|
31
|
-
days_of_month(
|
|
32
|
-
date: date,
|
|
33
|
-
today: today,
|
|
34
|
-
selectable: selectable,
|
|
35
|
-
selected_date: selected_date,
|
|
36
|
-
show_other_months: show_other_months
|
|
37
|
-
)
|
|
38
|
-
]
|
|
39
|
-
)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
private
|
|
44
|
-
|
|
45
|
-
def days_of_week(**kwargs)
|
|
46
|
-
DaysOfWeek.new(template).render(**kwargs)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def days_of_month(**kwargs)
|
|
50
|
-
DaysOfMonth.new(template, **kwargs).render
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Calendar
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
STIMULUS_CONTROLLER = "calendar-month"
|
|
8
|
-
OBSERVER_STIMULUS_CONTROLLER = "calendar-month-observer"
|
|
9
|
-
STIMULUS_DATA = {
|
|
10
|
-
controller: "#{STIMULUS_CONTROLLER} #{OBSERVER_STIMULUS_CONTROLLER}",
|
|
11
|
-
action: "click->#{OBSERVER_STIMULUS_CONTROLLER}#select"
|
|
12
|
-
}.freeze
|
|
13
|
-
|
|
14
|
-
def month(**kwargs)
|
|
15
|
-
html_options = merge_html_options(
|
|
16
|
-
{ classes: theme.resolve(:calendar).fetch(:classes, ""), data: STIMULUS_DATA },
|
|
17
|
-
kwargs
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
template.content_tag(:div, role: "grid", **html_options) do
|
|
21
|
-
template.safe_join(
|
|
22
|
-
[
|
|
23
|
-
template.tag.div(data: { "#{STIMULUS_CONTROLLER}-target" => "daysOfWeek" }),
|
|
24
|
-
template.tag.div(
|
|
25
|
-
role: "rowgroup",
|
|
26
|
-
data: { "#{STIMULUS_CONTROLLER}-target" => "daysOfMonth" }
|
|
27
|
-
)
|
|
28
|
-
]
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Card
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
def card(title: nil, **kwargs, &block)
|
|
8
|
-
html_options = merge_html_options(
|
|
9
|
-
{ classes: theme.resolve(:card).fetch(:classes, "") },
|
|
10
|
-
kwargs
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
template.content_tag(:div, **html_options) do
|
|
14
|
-
template.safe_join(
|
|
15
|
-
[
|
|
16
|
-
(template.content_tag(:h2, title) if title.present?),
|
|
17
|
-
template.capture(&block)
|
|
18
|
-
].compact
|
|
19
|
-
)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def section(title: nil, **kwargs, &block)
|
|
24
|
-
html_options = merge_html_options(
|
|
25
|
-
{ classes: theme.resolve(:card_section).fetch(:classes, "") },
|
|
26
|
-
kwargs
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
template.content_tag(:div, **html_options) do
|
|
30
|
-
template.safe_join(
|
|
31
|
-
[
|
|
32
|
-
(template.content_tag(:h3, title) if title.present?),
|
|
33
|
-
template.capture(&block)
|
|
34
|
-
].compact
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module DatePicker
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
STIMULUS_CONTROLLER = "datepicker"
|
|
8
|
-
POPOVER_CONTROLLER = "popover"
|
|
9
|
-
CALENDAR_CONTROLLER = Calendar::Renderer::OBSERVER_STIMULUS_CONTROLLER
|
|
10
|
-
CALENDAR_OUTLET = "#{STIMULUS_CONTROLLER}_#{Calendar::Renderer::STIMULUS_CONTROLLER}_outlet".freeze
|
|
11
|
-
STIMULUS_DATA = {
|
|
12
|
-
controller: "#{STIMULUS_CONTROLLER} #{POPOVER_CONTROLLER}",
|
|
13
|
-
action: "#{CALENDAR_CONTROLLER}:selected->#{STIMULUS_CONTROLLER}#selected " \
|
|
14
|
-
"#{CALENDAR_CONTROLLER}:selected->#{POPOVER_CONTROLLER}#hide"
|
|
15
|
-
}.freeze
|
|
16
|
-
|
|
17
|
-
def render(calendar_id: nil, calendar_dialog_id: nil, **kwargs)
|
|
18
|
-
data = calendar_id ? STIMULUS_DATA.merge(CALENDAR_OUTLET => "##{calendar_id}") : STIMULUS_DATA
|
|
19
|
-
html_options = merge_html_options(
|
|
20
|
-
{ classes: theme.resolve(:datepicker).fetch(:classes, ""), data: data },
|
|
21
|
-
kwargs
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
template.content_tag(:div, **html_options) do
|
|
25
|
-
template.safe_join([display_input(calendar_dialog_id), hidden_input, popover(calendar_id, calendar_dialog_id)])
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
def display_input(calendar_dialog_id)
|
|
32
|
-
template.tag.input(
|
|
33
|
-
type: "text",
|
|
34
|
-
role: "combobox",
|
|
35
|
-
aria: { label: "Date", haspopup: "dialog", controls: calendar_dialog_id },
|
|
36
|
-
data: {
|
|
37
|
-
"#{STIMULUS_CONTROLLER}_target": "display",
|
|
38
|
-
"#{POPOVER_CONTROLLER}_target": "activator",
|
|
39
|
-
action: [
|
|
40
|
-
"focus->#{POPOVER_CONTROLLER}#show",
|
|
41
|
-
"click->#{POPOVER_CONTROLLER}#show"
|
|
42
|
-
].join(" ")
|
|
43
|
-
}
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def hidden_input
|
|
48
|
-
template.tag.input(
|
|
49
|
-
type: "hidden",
|
|
50
|
-
data: { "#{STIMULUS_CONTROLLER}_target": "input" }
|
|
51
|
-
)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def popover(calendar_id, calendar_dialog_id)
|
|
55
|
-
template.content_tag(
|
|
56
|
-
:div,
|
|
57
|
-
id: calendar_dialog_id,
|
|
58
|
-
role: "dialog",
|
|
59
|
-
aria: { label: "Date picker" },
|
|
60
|
-
data: { "#{POPOVER_CONTROLLER}_target": "content" },
|
|
61
|
-
hidden: ""
|
|
62
|
-
) do
|
|
63
|
-
template.safe_join(
|
|
64
|
-
[
|
|
65
|
-
navigation(stimulus_controller: STIMULUS_CONTROLLER, step: "month"),
|
|
66
|
-
calendar_month(id: calendar_id)
|
|
67
|
-
]
|
|
68
|
-
)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def navigation(**kwargs)
|
|
73
|
-
Navigation.new(template).render(stimulus_controller: STIMULUS_CONTROLLER, step: "month", **kwargs)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def calendar_month(**kwargs)
|
|
77
|
-
Calendar::Renderer.new(template).month(**kwargs)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Icon
|
|
6
|
-
class Renderer < Plumber::Base
|
|
7
|
-
ICONS = {
|
|
8
|
-
"arrow-left" => "M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18",
|
|
9
|
-
"arrow-right" => "M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3",
|
|
10
|
-
"arrow-up" => "M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18",
|
|
11
|
-
"arrow-down" => "M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"
|
|
12
|
-
}.freeze
|
|
13
|
-
|
|
14
|
-
def icon(name:, **kwargs)
|
|
15
|
-
html_options = merge_html_options(
|
|
16
|
-
{ classes: theme.resolve(:icon).fetch(:classes, "") },
|
|
17
|
-
kwargs
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
if ICONS[name]
|
|
21
|
-
svg_icon(ICONS[name], html_options)
|
|
22
|
-
else
|
|
23
|
-
template.content_tag(:span, nil, **html_options)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
private
|
|
28
|
-
|
|
29
|
-
def svg_icon(path, html_options)
|
|
30
|
-
template.content_tag(
|
|
31
|
-
:svg,
|
|
32
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
-
fill: "none",
|
|
34
|
-
viewBox: "0 0 24 24",
|
|
35
|
-
width: "24",
|
|
36
|
-
height: "24",
|
|
37
|
-
"stroke-width": "1.5",
|
|
38
|
-
stroke: "currentColor",
|
|
39
|
-
**html_options
|
|
40
|
-
) do
|
|
41
|
-
template.tag.path(
|
|
42
|
-
"stroke-linecap": "round",
|
|
43
|
-
"stroke-linejoin": "round",
|
|
44
|
-
d: path
|
|
45
|
-
)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module StimulusPlumbers
|
|
4
|
-
module Components
|
|
5
|
-
module Plumber
|
|
6
|
-
class Base
|
|
7
|
-
include HtmlOptions
|
|
8
|
-
include Renderer
|
|
9
|
-
|
|
10
|
-
attr_reader :template
|
|
11
|
-
|
|
12
|
-
def initialize(template)
|
|
13
|
-
@template = template
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def theme
|
|
17
|
-
StimulusPlumbers.config.theme
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|