ariadne_view_components 0.0.93.2 → 0.0.94
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +13 -4
- data/app/assets/javascripts/ariadne_view_components.js +14 -14
- data/app/assets/javascripts/ariadne_view_components.js.br +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.gz +0 -0
- data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css +1 -1
- data/app/assets/stylesheets/ariadne_view_components.css.br +0 -0
- data/app/assets/stylesheets/ariadne_view_components.css.gz +0 -0
- data/app/components/ariadne/base_component.rb +25 -22
- data/app/components/ariadne/behaviors/tooltipable.rb +12 -12
- data/app/components/ariadne/form/checkbox/component.rb +2 -2
- data/app/components/ariadne/form/group/component.rb +1 -1
- data/app/components/ariadne/form/radio_button/component.rb +2 -2
- data/app/components/ariadne/form/select/component.rb +1 -1
- data/app/components/ariadne/form/text_field/component.html.erb +2 -2
- data/app/components/ariadne/form/text_field/component.rb +14 -7
- data/app/components/ariadne/form/toggle/component.rb +2 -2
- data/app/components/ariadne/form/toggle_group/component.rb +1 -1
- data/app/components/ariadne/form/toggle_group/option/component.rb +1 -1
- data/app/components/ariadne/layout/grid/component.rb +1 -1
- data/app/components/ariadne/layout/grid/item/component.rb +2 -2
- data/app/components/ariadne/layout/label_block/component.rb +1 -1
- data/app/components/ariadne/layout/narrow/component.rb +1 -1
- data/app/components/ariadne/ui/accordion/component.rb +3 -1
- data/app/components/ariadne/ui/accordion/item/component.html.erb +10 -10
- data/app/components/ariadne/ui/accordion/item/component.rb +12 -3
- data/app/components/ariadne/ui/avatar/component.html.erb +9 -7
- data/app/components/ariadne/ui/avatar/component.rb +55 -7
- data/app/components/ariadne/ui/badge/component.rb +35 -16
- data/app/components/ariadne/ui/banner/component.html.erb +23 -0
- data/app/components/ariadne/ui/banner/component.rb +226 -0
- data/app/components/ariadne/ui/banner/component.ts +46 -0
- data/app/components/ariadne/ui/blankslate/component.html.erb +2 -2
- data/app/components/ariadne/ui/blankslate/component.rb +12 -1
- data/app/components/ariadne/ui/button/component.rb +35 -24
- data/app/components/ariadne/ui/card/body/component.rb +1 -1
- data/app/components/ariadne/ui/card/component.rb +11 -7
- data/app/components/ariadne/ui/card/footer/component.rb +1 -1
- data/app/components/ariadne/ui/card/header/component.html.erb +2 -2
- data/app/components/ariadne/ui/card/header/component.rb +25 -16
- data/app/components/ariadne/ui/clipboard_copy/component.html.erb +1 -0
- data/app/components/ariadne/ui/clipboard_copy/component.rb +17 -21
- data/app/components/ariadne/ui/clipboard_copy/component.ts +15 -0
- data/app/components/ariadne/ui/color_dot/component.html.erb +5 -5
- data/app/components/ariadne/ui/color_dot/component.rb +19 -4
- data/app/components/ariadne/ui/combobox/component.html.erb +1 -1
- data/app/components/ariadne/ui/combobox/component.rb +54 -23
- data/app/components/ariadne/ui/combobox/component.ts +2 -0
- data/app/components/ariadne/ui/dialog/body/component.html.erb +3 -0
- data/app/components/ariadne/ui/dialog/body/component.rb +28 -0
- data/app/components/ariadne/ui/dialog/component.html.erb +25 -24
- data/app/components/ariadne/ui/dialog/component.rb +87 -18
- data/app/components/ariadne/ui/dialog/component.ts +5 -1
- data/app/components/ariadne/ui/dialog/footer/component.html.erb +3 -0
- data/app/components/ariadne/ui/dialog/footer/component.rb +34 -0
- data/app/components/ariadne/ui/heroicon/component.rb +21 -21
- data/app/components/ariadne/ui/image/component.rb +11 -23
- data/app/components/ariadne/ui/link/component.html.erb +1 -3
- data/app/components/ariadne/ui/link/component.rb +17 -4
- data/app/components/ariadne/ui/list/component.html.erb +5 -9
- data/app/components/ariadne/ui/list/component.rb +31 -7
- data/app/components/ariadne/ui/list/item/component.rb +6 -5
- data/app/components/ariadne/ui/pagination/component.rb +1 -2
- data/app/components/ariadne/ui/popover/component.html.erb +1 -1
- data/app/components/ariadne/ui/popover/component.rb +31 -26
- data/app/components/ariadne/ui/relative_time/component.html.erb +1 -0
- data/app/components/ariadne/ui/{time_ago → relative_time}/component.rb +15 -15
- data/app/components/ariadne/ui/{time_ago → relative_time}/component.ts +1 -1
- data/app/components/ariadne/ui/shortcut/component.html.erb +0 -1
- data/app/components/ariadne/ui/shortcut/component.rb +31 -5
- data/app/components/ariadne/ui/shortcut/component.ts +1 -1
- data/app/components/ariadne/ui/skeleton/component.rb +2 -8
- data/app/components/ariadne/ui/stats_panel/component.html.erb +3 -3
- data/app/components/ariadne/ui/stats_panel/component.rb +25 -1
- data/app/components/ariadne/ui/stats_panel/item/component.html.erb +3 -3
- data/app/components/ariadne/ui/stats_panel/item/component.rb +6 -6
- data/app/components/ariadne/ui/table/cell/component.rb +1 -1
- data/app/components/ariadne/ui/table/row/component.rb +1 -1
- data/app/components/ariadne/ui/typography/component.rb +3 -1
- data/app/frontend/controllers/tooltip_controller.ts +8 -3
- data/app/frontend/stylesheets/ariadne_view_components.css +1 -0
- data/app/frontend/stylesheets/theme.css +88 -0
- data/app/frontend/utils/createController.ts +9 -0
- data/app/helpers/ariadne/color_helper.rb +158 -0
- data/app/helpers/ariadne/form_helper.rb +1 -0
- data/app/helpers/ariadne/size_helper.rb +7 -0
- data/app/lib/ariadne/attributes_helper.rb +4 -4
- data/app/lib/ariadne/view_component/style_variants.rb +1 -1
- data/app/lib/ariadne/view_helper.rb +0 -6
- data/lib/ariadne/accessibility.rb +64 -0
- data/lib/ariadne/forms/dsl/form_object.rb +5 -1
- data/lib/ariadne/forms/dsl/input.rb +1 -1
- data/lib/ariadne/static/generate_arguments.rb +54 -0
- data/lib/ariadne/static/generate_audited_at.rb +17 -0
- data/lib/ariadne/static/generate_constants.rb +19 -0
- data/lib/ariadne/static/generate_previews.rb +53 -0
- data/lib/ariadne/static/generate_statuses.rb +17 -0
- data/lib/ariadne/static/generate_structure.rb +279 -0
- data/lib/ariadne/static.rb +68 -0
- data/lib/ariadne/view_components/constants.rb +2 -2
- data/lib/ariadne/view_components/version.rb +1 -1
- data/lib/ariadne/view_components.rb +0 -51
- data/lib/ariadne/yard/component_manifest.rb +81 -81
- data/lib/ariadne/yard/component_ref.rb +1 -1
- data/lib/ariadne/yard/docs_helper.rb +24 -16
- data/lib/ariadne/yard/dry_initializer/common_handler.rb +103 -0
- data/lib/ariadne/yard/dry_initializer/option_handler.rb +38 -0
- data/lib/ariadne/yard/dry_initializer/param_handler.rb +57 -0
- data/lib/ariadne/yard/registry.rb +2 -5
- data/lib/ariadne/yard/{info_arch_docs_helper.rb → structure_docs_helper.rb} +5 -5
- data/lib/ariadne/yard.rb +20 -8
- data/lib/rubocop/config/default.yml +0 -3
- metadata +34 -37
- data/app/components/ariadne/behaviors/captionable.rb +0 -55
- data/app/components/ariadne/turbo/frame/component.html.erb +0 -3
- data/app/components/ariadne/turbo/frame/component.rb +0 -16
- data/app/components/ariadne/turbo/stream_action/component.html.erb +0 -4
- data/app/components/ariadne/turbo/stream_action/component.rb +0 -25
- data/app/components/ariadne/ui/data_table/component.html.erb +0 -1
- data/app/components/ariadne/ui/data_table/component.rb +0 -11
- data/app/components/ariadne/ui/flash/component.html.erb +0 -18
- data/app/components/ariadne/ui/flash/component.rb +0 -151
- data/app/components/ariadne/ui/flash/component.ts +0 -56
- data/app/components/ariadne/ui/overlay/component.html.erb +0 -12
- data/app/components/ariadne/ui/overlay/component.rb +0 -54
- data/app/components/ariadne/ui/overlay/component.ts +0 -92
- data/app/components/ariadne/ui/time_ago/component.html.erb +0 -1
- data/lib/ariadne/view_components/commands.rb +0 -90
- data/lib/ariadne/view_components/statuses.rb +0 -14
- data/lib/ariadne/view_components/upstream.rb +0 -19
- data/lib/ariadne/yard/lookbook_pages_backend.rb +0 -235
- data/lib/rubocop/cop/ariadne/no_tag_memoize.rb +0 -44
- data/static/arguments.yml +0 -879
- data/static/assets/view-components.svg +0 -18
- data/static/classes.yml +0 -211
- data/static/constants.json +0 -743
- data/static/statuses.json +0 -58
- data/static/tailwindcss.yml +0 -727
- /data/app/components/ariadne/ui/{time_ago → relative_time}/en.yml +0 -0
@@ -4,21 +4,35 @@
|
|
4
4
|
module Ariadne
|
5
5
|
module UI
|
6
6
|
module ColorDot
|
7
|
+
# Creates a colored circle.
|
7
8
|
class Component < Ariadne::BaseComponent
|
9
|
+
# @param [Symbol] color The hex color of the dot (without the hash)
|
8
10
|
option :color
|
9
|
-
|
11
|
+
|
12
|
+
DEFAULT_SIZE = :md
|
13
|
+
# @param [Symbol] size (Ariadne::UI::ColorDot::DEFAULT_SIZE) Indicates the button's size. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
|
14
|
+
option :size, default: -> { DEFAULT_SIZE }
|
15
|
+
|
16
|
+
def before_render
|
17
|
+
raise ArgumentError, "Color must be a 6-character hex string" unless color.match?(/\A[a-fA-F0-9]{6}\z/)
|
18
|
+
end
|
10
19
|
|
11
20
|
style do
|
12
21
|
base do
|
13
|
-
|
22
|
+
[
|
23
|
+
"ariadne-inline-flex",
|
24
|
+
"ariadne-items-center",
|
25
|
+
"ariadne-truncate",
|
26
|
+
]
|
14
27
|
end
|
15
28
|
|
16
29
|
variants do
|
17
30
|
size do
|
18
31
|
xs { "ariadne-ps-0.5" }
|
19
32
|
sm { "ariadne-ps-0.5" }
|
20
|
-
base { "ariadne-ps-1" }
|
21
33
|
md { "ariadne-ps-1" }
|
34
|
+
lg { "ariadne-ps-1" }
|
35
|
+
xl { "ariadne-ps-1" }
|
22
36
|
end
|
23
37
|
end
|
24
38
|
end
|
@@ -28,8 +42,9 @@ module Ariadne
|
|
28
42
|
size do
|
29
43
|
xs { "ariadne-size-2" }
|
30
44
|
sm { "ariadne-size-2.5" }
|
31
|
-
base { "ariadne-size-3" }
|
32
45
|
md { "ariadne-size-3" }
|
46
|
+
lg { "ariadne-size-3" }
|
47
|
+
xl { "ariadne-ps-1" }
|
33
48
|
end
|
34
49
|
end
|
35
50
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<details class="ariadne-inline" <%= html_attrs.to_html %>>
|
2
2
|
<summary class="ariadne-list-none ariadne-rounded" data-<%= stimulus_name %>-target="button" data-action="click-><%= stimulus_name %>#toggle">
|
3
|
-
<%=
|
3
|
+
<%= reveal_button %>
|
4
4
|
</summary>
|
5
5
|
<details-menu
|
6
6
|
class="<%= merged_styles(:popover, size:) %>"
|
@@ -4,41 +4,71 @@
|
|
4
4
|
module Ariadne
|
5
5
|
module UI
|
6
6
|
module Combobox
|
7
|
+
# The combobox is used to present a list of options for selection.
|
8
|
+
#
|
9
|
+
# Style overrides:
|
10
|
+
#
|
11
|
+
# - `popover` - The popover that contains the combobox options.
|
7
12
|
class Component < Ariadne::BaseComponent
|
8
|
-
|
13
|
+
DEFAULT_SIZE = :md
|
9
14
|
|
10
|
-
|
15
|
+
# @param [Symbol] size (Ariadne::UI::Combobox::DEFAULT_SIZE) The size of the badge. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
|
16
|
+
option :size, default: proc { DEFAULT_SIZE }
|
17
|
+
|
18
|
+
DEFAULT_PLACEMENT = "bottom"
|
19
|
+
# according to `floating-ui/dom`
|
20
|
+
VALID_PLACEMENTS = ["top", "right", "bottom", "left", "top-start", "top-end", "right-start", "right-end", "bottom-start", "bottom-end", "left-start", "left-end"]
|
21
|
+
# @param [String] size (bottom) The location of the menu.
|
22
|
+
option :placement, default: proc { DEFAULT_PLACEMENT }
|
23
|
+
|
24
|
+
# @param [Boolean] clamped (false) Indicates if the menu should be clamped to the viewport.
|
11
25
|
option :clamped, default: proc { false }
|
12
26
|
|
27
|
+
# @param [String] changed_action A stimulus action to call when a value within the combobox changes.
|
13
28
|
option :changed_action, optional: true
|
14
29
|
|
30
|
+
# The list of options to display in the combobox.
|
31
|
+
#
|
32
|
+
# @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::List::Component) %>.
|
15
33
|
renders_one :list, lambda { |**options|
|
16
|
-
|
17
|
-
|
34
|
+
options[:as_menu] = true
|
35
|
+
Ariadne::UI::List::Component.new(**options)
|
36
|
+
}
|
37
|
+
|
38
|
+
# The button which renders the combobox.
|
39
|
+
#
|
40
|
+
# @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Button::Component) %>.
|
41
|
+
renders_one :reveal_button, lambda { |**options|
|
42
|
+
options[:html_attrs] ||= {}
|
43
|
+
options[:html_attrs][:role] = "combobox"
|
44
|
+
|
45
|
+
options[:html_attrs][:aria] = merge_aria(
|
46
|
+
options[:html_attrs], {
|
47
|
+
aria: {
|
48
|
+
haspopup: "dialog",
|
49
|
+
expanded: "false",
|
50
|
+
},
|
51
|
+
}
|
52
|
+
)
|
53
|
+
|
54
|
+
options[:scheme] ||= :nude
|
55
|
+
options[:html_attrs][:id] ||= Ariadne::UI::Button::Component.generate_id
|
56
|
+
Ariadne::UI::Button::Component.new(**options)
|
18
57
|
}
|
19
|
-
renders_one :button, Ariadne::UI::Button::Component
|
20
58
|
|
21
59
|
accepts_html_attributes do |html_attrs|
|
22
|
-
|
23
|
-
|
24
|
-
controller: "#{stimulus_name} #{html_attrs[:data].delete(:controller)}".strip,
|
60
|
+
component_data_attrs = {
|
61
|
+
controller: stimulus_name,
|
25
62
|
"#{stimulus_name}-target": "wrapper",
|
26
63
|
"#{stimulus_name}-placement-value": placement,
|
27
64
|
"#{stimulus_name}-clamped-value": clamped,
|
28
|
-
}
|
65
|
+
}
|
29
66
|
|
30
67
|
if changed_action
|
31
|
-
|
68
|
+
component_data_attrs[:action] = "#{stimulus_name}:changed->#{changed_action}"
|
32
69
|
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def initialize(**options)
|
36
|
-
super
|
37
|
-
validate!
|
38
|
-
end
|
39
70
|
|
40
|
-
|
41
|
-
# raise ArgumentError, "Must provide only `options` or `items`, not both" if items? && options?
|
71
|
+
html_attrs[:data] = merge_data_attributes(html_attrs, component_data_attrs)
|
42
72
|
end
|
43
73
|
|
44
74
|
accepts_styles :popover
|
@@ -52,10 +82,8 @@ module Ariadne
|
|
52
82
|
"ariadne-scrollbar-trigger",
|
53
83
|
"ariadne-rounded-lg",
|
54
84
|
"ariadne-shadow-lg",
|
55
|
-
"ariadne-bg-
|
56
|
-
"
|
57
|
-
"ariadne-text-content",
|
58
|
-
"dark:ariadne-text-content-dark",
|
85
|
+
"ariadne-bg-popover",
|
86
|
+
"text-popover-foreground",
|
59
87
|
]
|
60
88
|
end
|
61
89
|
|
@@ -72,7 +100,10 @@ module Ariadne
|
|
72
100
|
|
73
101
|
style :options do
|
74
102
|
base do
|
75
|
-
[
|
103
|
+
[
|
104
|
+
"ariadne-overflow-auto",
|
105
|
+
"ariadne-p-2",
|
106
|
+
]
|
76
107
|
end
|
77
108
|
end
|
78
109
|
end
|
@@ -29,6 +29,7 @@ export default class ComboboxController extends controllerFactory<HTMLDetailsEle
|
|
29
29
|
if (this.changedIds.size > 0) {
|
30
30
|
this.dispatch('changed')
|
31
31
|
this.changedIds.clear()
|
32
|
+
this.buttonTarget.setAttribute('aria-expanded', 'false')
|
32
33
|
}
|
33
34
|
}
|
34
35
|
|
@@ -115,5 +116,6 @@ export default class ComboboxController extends controllerFactory<HTMLDetailsEle
|
|
115
116
|
toggle(): void {
|
116
117
|
this.element.open = !this.element.open
|
117
118
|
this.setupAutoUpdate()
|
119
|
+
this.buttonTarget.setAttribute('aria-expanded', 'true')
|
118
120
|
}
|
119
121
|
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Ariadne
|
5
|
+
module UI
|
6
|
+
module Dialog
|
7
|
+
module Body
|
8
|
+
# A `Dialog::Body` is a compositional component, used to render the
|
9
|
+
# innards of a dialog. See <%= link_to_component(Ariadne::UI::Dialog::Component) %>.
|
10
|
+
class Component < Ariadne::BaseComponent
|
11
|
+
attr_accessor :context
|
12
|
+
|
13
|
+
accepts_html_attributes do |html_attrs|
|
14
|
+
html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
|
15
|
+
|
16
|
+
html_attrs
|
17
|
+
end
|
18
|
+
|
19
|
+
style do
|
20
|
+
base do
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,29 +1,30 @@
|
|
1
1
|
<div
|
2
|
-
class="ariadne-contents"
|
3
2
|
data-controller="<%= stimulus_name %>"
|
4
|
-
data-action="click@window-><%= stimulus_name %>#windowClick"
|
5
|
-
<%=
|
6
|
-
<%= trigger %>
|
7
|
-
|
3
|
+
data-action="click@window-><%= stimulus_name %>#windowClick">
|
4
|
+
<%= reveal_button %>
|
8
5
|
<dialog
|
9
|
-
class="<%=
|
10
|
-
data-<%= stimulus_name %>-target="dialog"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
<div class="ariadne-flex ariadne-gap-2 ariadne-flex-wrap"><%= footer %></div>
|
20
|
-
<% end %>
|
21
|
-
</div>
|
22
|
-
<div class="ariadne-absolute ariadne-end-3 ariadne-top-3">
|
23
|
-
<%= render Ariadne::UI::Button::Component.new(
|
24
|
-
theme: :nude,
|
25
|
-
html_attrs: { "data-action": "click->#{stimulus_name}#triggerClick", aria: { label: trigger_close_label } }).as_icon(icon: "x-mark", variant: :outline) %>
|
26
|
-
</div>
|
6
|
+
class="<%= html_attrs[:class] %>"
|
7
|
+
data-<%= stimulus_name %>-target="dialog"
|
8
|
+
<%= html_attributes %>>
|
9
|
+
<div class="ariadne-flex ariadne-flex-col ariadne-space-y-2 ariadne-text-center sm:ariadne-text-left">
|
10
|
+
<span id="<%= dialog_id %>-title" class="ariadne-text-lg ariadne-font-semibold"><%= title %></span>
|
11
|
+
<% if content.present? %>
|
12
|
+
<%= content %>
|
13
|
+
<% else %>
|
14
|
+
<div data-labelled-by="<%= labelledby %>">
|
15
|
+
<%= body %>
|
27
16
|
</div>
|
28
|
-
|
17
|
+
<% end %>
|
18
|
+
<% if footer? %>
|
19
|
+
<%= footer %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<div class="ariadne-absolute ariadne-end-3 ariadne-top-3">
|
23
|
+
<%= render Ariadne::UI::Button::Component.new(
|
24
|
+
scheme: :nude,
|
25
|
+
size: :xs,
|
26
|
+
html_attrs: { "data-action": "click->#{stimulus_name}#swapVisibility", aria: { label: dialog_close_label } }).as_icon(icon: "x-mark", variant: :outline) %>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</dialog>
|
29
30
|
</div>
|
@@ -4,16 +4,83 @@
|
|
4
4
|
module Ariadne
|
5
5
|
module UI
|
6
6
|
module Dialog
|
7
|
+
# A `Dialog` is used to remove the user from the main application flow,
|
8
|
+
# to confirm actions, ask for disambiguation or to present small forms.
|
9
|
+
#
|
10
|
+
# @accessibility
|
11
|
+
# - **Dialog Accessible Name**: A dialog should have an accessible name,
|
12
|
+
# so screen readers are aware of the purpose of the dialog when it opens.
|
13
|
+
# Give an accessible name by setting `:title`. The accessible name will be
|
14
|
+
# used as the main heading inside the dialog.
|
15
|
+
# - **Dialog unique id**: A dialog should be unique. Give a unique id by
|
16
|
+
# setting `:dialog_id`. If no `:dialog_id` is given, a random
|
17
|
+
# hex id is generated.
|
18
|
+
#
|
19
|
+
# The combination of both `:title` and `:dialog_id` establishes an
|
20
|
+
# `aria-labelledby` relationship between the title and the unique id of
|
21
|
+
# the dialog.
|
7
22
|
class Component < Ariadne::BaseComponent
|
23
|
+
# @param title [String] The id of the dialog.
|
8
24
|
option :title
|
9
|
-
|
10
|
-
option :
|
11
|
-
option :width, default: proc { :base }
|
25
|
+
# @param dialog_close_label [String] ("Close") The aria label for the button which closes the dialog. Necessary if using the `close_button` slot.
|
26
|
+
option :dialog_close_label, default: -> { "Close" }
|
12
27
|
|
13
|
-
|
14
|
-
|
28
|
+
# @param dialog_id [String] (UUID) The id of the dialog. If no `:dialog_id` is given, a random
|
29
|
+
# UUID-based ID is generated.
|
30
|
+
option :dialog_id, default: -> { self.class.generate_id }
|
15
31
|
|
16
|
-
|
32
|
+
# @param [Symbol] width (:narrow) Indicates the width of the button. Can be either `:narrow` or `:full`.
|
33
|
+
option :width, default: proc { :narrow }
|
34
|
+
|
35
|
+
# The button to open the dialog.
|
36
|
+
#
|
37
|
+
# @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Button::Component) %>.
|
38
|
+
renders_one :reveal_button, lambda { |**options|
|
39
|
+
component_data_attrs = {
|
40
|
+
action: "#{Ariadne::UI::Dialog::Component.stimulus_name}#swapVisibility",
|
41
|
+
}
|
42
|
+
|
43
|
+
options[:html_attrs] ||= {}
|
44
|
+
options[:html_attrs][:data] = merge_data_attributes(options[:html_attrs], component_data_attrs)
|
45
|
+
Ariadne::UI::Button::Component.new(**options)
|
46
|
+
}
|
47
|
+
|
48
|
+
# The content.
|
49
|
+
#
|
50
|
+
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Dialog::Body::Component) %>.
|
51
|
+
renders_one :body, Ariadne::UI::Dialog::Body::Component
|
52
|
+
|
53
|
+
# Optional footer content to the dialog; usually buttons.
|
54
|
+
#
|
55
|
+
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Dialog::Footer::Component) %>.
|
56
|
+
renders_one :footer, Ariadne::UI::Dialog::Footer::Component
|
57
|
+
|
58
|
+
accepts_html_attributes do |html_attrs|
|
59
|
+
html_attrs[:class] = merge_tailwind_classes([style(width:), html_attrs[:class]].join(" "))
|
60
|
+
|
61
|
+
@dialog_id = html_attrs[:id].presence || @dialog_id
|
62
|
+
html_attrs[:id] = @dialog_id
|
63
|
+
|
64
|
+
html_attrs[:aria] = { modal: true }
|
65
|
+
html_attrs[:aria] = merge_aria(
|
66
|
+
html_attrs, {
|
67
|
+
aria: {
|
68
|
+
labelledby: labelledby,
|
69
|
+
describedby: describedby,
|
70
|
+
},
|
71
|
+
}
|
72
|
+
)
|
73
|
+
|
74
|
+
html_attrs
|
75
|
+
end
|
76
|
+
|
77
|
+
def labelledby
|
78
|
+
"#{@dialog_id}-title"
|
79
|
+
end
|
80
|
+
|
81
|
+
def describedby
|
82
|
+
"#{@dialog_id}-description"
|
83
|
+
end
|
17
84
|
|
18
85
|
style do
|
19
86
|
base do
|
@@ -22,27 +89,29 @@ module Ariadne
|
|
22
89
|
"ariadne-max-h-[90-vh]",
|
23
90
|
"ariadne-shadow-xl",
|
24
91
|
"ariadne-rounded-2xl",
|
25
|
-
"ariadne-bg-
|
26
|
-
"
|
92
|
+
"ariadne-bg-card",
|
93
|
+
"ariadne-text-card-foreground",
|
27
94
|
"ariadne-text-content",
|
28
95
|
"dark:ariadne-text-content-dark",
|
29
96
|
"backdrop:ariadne-bg-zinc-900/20",
|
30
97
|
"backdrop:dark:ariadne-bg-zinc-100/20",
|
98
|
+
"ariadne-relative",
|
99
|
+
"ariadne-px-4",
|
100
|
+
"ariadne-pb-4",
|
101
|
+
"ariadne-pt-5",
|
102
|
+
"ariadne-text-left",
|
103
|
+
"ariadne-shadow-xl",
|
104
|
+
"ariadne-transition-all",
|
105
|
+
"sm:ariadne-w-full",
|
106
|
+
"sm:ariadne-max-w-xl",
|
107
|
+
"sm:ariadne-p-6",
|
31
108
|
]
|
32
109
|
end
|
33
110
|
variants do
|
34
111
|
width do
|
35
|
-
|
36
|
-
[
|
37
|
-
"ariadne-w-96",
|
38
|
-
"ariadne-max-w-[90vw]",
|
39
|
-
]
|
40
|
-
end
|
41
|
-
|
42
|
-
wide do
|
112
|
+
full do
|
43
113
|
[
|
44
|
-
"ariadne-w-
|
45
|
-
"ariadne-max-w-[90vw]",
|
114
|
+
"ariadne-w-full",
|
46
115
|
]
|
47
116
|
end
|
48
117
|
end
|
@@ -9,17 +9,21 @@ export default class DialogController extends controllerFactory()({
|
|
9
9
|
this.dialogTarget.close()
|
10
10
|
enableBodyScroll(this.dialogTarget)
|
11
11
|
}
|
12
|
+
|
12
13
|
disconnect() {
|
13
14
|
this.close()
|
14
15
|
}
|
16
|
+
|
15
17
|
open() {
|
16
18
|
this.dialogTarget.showModal()
|
17
19
|
disableBodyScroll(this.dialogTarget, {reserveScrollBarGap: true})
|
18
20
|
}
|
19
|
-
|
21
|
+
|
22
|
+
swapVisibility() {
|
20
23
|
if (this.dialogTarget.open) this.close()
|
21
24
|
else this.open()
|
22
25
|
}
|
26
|
+
|
23
27
|
windowClick(e: MouseEvent) {
|
24
28
|
if (e.target === this.dialogTarget) {
|
25
29
|
this.close()
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Ariadne
|
5
|
+
module UI
|
6
|
+
module Dialog
|
7
|
+
module Footer
|
8
|
+
# A `Dialog::Footer` is a compositional component, used to render the
|
9
|
+
# innards of a dialog. See <%= link_to_component(Ariadne::UI::Dialog::Component) %>.
|
10
|
+
class Component < Ariadne::BaseComponent
|
11
|
+
attr_accessor :context
|
12
|
+
|
13
|
+
accepts_html_attributes do |html_attrs|
|
14
|
+
html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
|
15
|
+
|
16
|
+
html_attrs
|
17
|
+
end
|
18
|
+
|
19
|
+
style do
|
20
|
+
base do
|
21
|
+
[
|
22
|
+
"ariadne-flex",
|
23
|
+
"ariadne-flex-col-reverse",
|
24
|
+
"sm:ariadne-flex-row",
|
25
|
+
"sm:ariadne-justify-end",
|
26
|
+
"sm:ariadne-space-x-2",
|
27
|
+
]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -6,36 +6,36 @@ require "heroicons_helper"
|
|
6
6
|
module Ariadne
|
7
7
|
module UI
|
8
8
|
module Heroicon
|
9
|
-
#
|
10
|
-
# <%= render(Ariadne::UI::Heroicon::Component.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE)) %>
|
11
|
-
# <%= render(Ariadne::UI::Heroicon::Component.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_SOLID)) %>
|
12
|
-
#
|
13
|
-
# @example Medium
|
14
|
-
# <%= render(Ariadne::UI::Heroicon::Component.new(icon: :"user-group", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, size: :md)) %>
|
15
|
-
#
|
16
|
-
# @example Helper
|
17
|
-
# <%= ariadne_heroicon(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE) %>
|
18
|
-
#
|
19
|
-
# @param tag [Symbol, String] The rendered tag name
|
20
|
-
# @param classes [String] <%= link_to_classes_docs %>
|
21
|
-
# @param icon [Symbol, String] Name of <%= link_to_heroicons %> to use.
|
22
|
-
# @param variant [String] <%= one_of(HeroiconsHelper::Icon::VALID_VARIANTS, sort: false) %>
|
23
|
-
# @param size [Symbol] <%= one_of(Ariadne::UI::Heroicon::Component::SIZE_MAPPINGS, sort: false) %>
|
9
|
+
# Use this component whenever you need to render a [Heroicon](https://heroicons.com/) SVG icon.
|
24
10
|
class Component < Ariadne::BaseComponent
|
25
|
-
|
11
|
+
DEFAULT_SIZE = :md
|
26
12
|
|
13
|
+
# @param icon [Symbol, String] The name of <%= link_to_heroicons %> to use.
|
27
14
|
option :icon
|
15
|
+
# @param variant [String] The type of variant to use. <%= one_of(HeroiconsHelper::Icon::VALID_VARIANTS) %>
|
28
16
|
option :variant
|
29
|
-
|
17
|
+
# @param [Symbol] size (Ariadne::UI::Heroicon::DEFAULT_SIZE) The size of the badge. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
|
18
|
+
option :size, default: proc { DEFAULT_SIZE }
|
30
19
|
|
31
20
|
include IconHelper
|
32
21
|
include HeroiconsHelper
|
33
22
|
|
34
23
|
accepts_html_attributes do |html_attrs|
|
35
|
-
classes = [
|
36
|
-
|
37
|
-
|
38
|
-
|
24
|
+
classes = [
|
25
|
+
@heroicon.attributes["class"],
|
26
|
+
style(size: @size),
|
27
|
+
html_attrs[:class],
|
28
|
+
]
|
29
|
+
|
30
|
+
html_attrs[:class] = merge_tailwind_classes(classes)
|
31
|
+
|
32
|
+
html_attrs[:aria] ||= {}
|
33
|
+
|
34
|
+
if html_attrs[:aria][:label] || html_attrs[:"aria-label"]
|
35
|
+
html_attrs[:role] = "img"
|
36
|
+
else
|
37
|
+
html_attrs[:aria][:hidden] = true
|
38
|
+
end
|
39
39
|
end
|
40
40
|
|
41
41
|
def initialize(**options)
|
@@ -4,36 +4,24 @@
|
|
4
4
|
module Ariadne
|
5
5
|
module UI
|
6
6
|
module Image
|
7
|
-
#
|
7
|
+
# Component for rendering images.
|
8
8
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# @example Helper
|
12
|
-
#
|
13
|
-
# <%= ariadne_image(src: "https://github.com/github.png", alt: "GitHub") %>
|
14
|
-
#
|
15
|
-
# @example Lazy loading
|
16
|
-
#
|
17
|
-
# <%= render(Ariadne::ImageComponent.new(src: "https://github.com/github.png", alt: "GitHub", lazy: true)) %>
|
18
|
-
#
|
19
|
-
# @example Custom size
|
20
|
-
#
|
21
|
-
# <%= render(Ariadne::ImageComponent.new(src: "https://github.com/github.png", alt: "GitHub", attributes: { height: 100, width: 100 })) %>
|
22
|
-
#
|
23
|
-
# @param tag [Symbol, String] The rendered tag name
|
24
|
-
# @param src [String] The source url of the image.
|
25
|
-
# @param alt [String] Specifies an alternate text for the image.
|
26
|
-
# @param lazy [Boolean] Whether or not to lazily load the image.
|
27
|
-
# @param classes [String] <%= link_to_classes_docs %>
|
28
|
-
# @param attributes [Hash] <%= link_to_attributes_docs %>
|
9
|
+
# @accessibility
|
10
|
+
# Always provide a meaningful `alt`.
|
29
11
|
class Component < Ariadne::BaseComponent
|
12
|
+
DEFAULT_SIZE = :md
|
13
|
+
|
14
|
+
# @param src [String] The source url of the image.
|
30
15
|
option :src
|
16
|
+
# @param alt [String] Specifies an alternate text for the image.
|
31
17
|
option :alt
|
32
|
-
|
18
|
+
# @param [Symbol] size (Ariadne::UI::Image::DEFAULT_SIZE) The size of the badge. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
|
19
|
+
option :size, default: -> { DEFAULT_SIZE }
|
20
|
+
# @param lazy [Boolean] Whether or not to lazily load the image.
|
33
21
|
option :lazy, default: -> { false }
|
34
22
|
|
35
23
|
accepts_html_attributes do |html_attrs|
|
36
|
-
html_attrs[:class] =
|
24
|
+
html_attrs[:class] = merge_tailwind_classes([style(size: @size), html_attrs[:class]].join(" "))
|
37
25
|
|
38
26
|
html_attrs[:src] = @src
|
39
27
|
html_attrs[:alt] = @alt
|
@@ -4,16 +4,27 @@
|
|
4
4
|
module Ariadne
|
5
5
|
module UI
|
6
6
|
module Link
|
7
|
+
# Use this to navigate from one page to another. `Link` styles anchor tags with default styling and hover text-decoration.
|
8
|
+
#
|
9
|
+
# @behaviors <%= link_to_component(Ariadne::Behaviors::Tooltipable) %>
|
7
10
|
class Component < Ariadne::BaseComponent
|
11
|
+
# @param [String] href URL to be used for the link.
|
8
12
|
option :href
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
DEFAULT_SIZE = :md
|
15
|
+
DEFAULT_SCHEME = :base
|
16
|
+
SCHEME_OPTIONS = [DEFAULT_SCHEME, :nude, :none, :thick].freeze
|
17
|
+
|
18
|
+
# @param [Symbol] theme (:primary) Indicates the link's design scheme. <%= one_of(Ariadne::UI::Link::Component::SCHEME_OPTIONS) %>
|
19
|
+
option :scheme, default: -> { :base }
|
20
|
+
|
21
|
+
# @param [Symbol] size (Ariadne::UI::Link::DEFAULT_SIZE) The size of the link. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
|
22
|
+
option :size, default: proc { DEFAULT_SIZE }
|
12
23
|
|
13
24
|
include Ariadne::Behaviors::Tooltipable
|
14
25
|
|
15
26
|
accepts_html_attributes do |html_attrs|
|
16
|
-
html_attrs[:class] =
|
27
|
+
html_attrs[:class] = merge_tailwind_classes([style(scheme:, size:), html_attrs[:class]].join(" "))
|
17
28
|
end
|
18
29
|
|
19
30
|
style do
|
@@ -30,7 +41,7 @@ module Ariadne
|
|
30
41
|
end
|
31
42
|
|
32
43
|
variants do
|
33
|
-
|
44
|
+
scheme do
|
34
45
|
base do
|
35
46
|
[
|
36
47
|
"ariadne-text-indigo-600",
|
@@ -75,11 +86,13 @@ module Ariadne
|
|
75
86
|
]
|
76
87
|
end
|
77
88
|
end
|
89
|
+
|
78
90
|
size do
|
79
91
|
xs { "ariadne-text-xs ariadne-gap-0.5 [&>svg]:ariadne-size-3" }
|
80
92
|
sm { "ariadne-text-sm ariadne-gap-0.5 [&>svg]:ariadne-size-4" }
|
81
93
|
md { "ariadne-text-base ariadne-gap-1 [&>svg]:ariadne-size-4" }
|
82
94
|
lg { "ariadne-text-lg ariadne-gap-1 [&>svg]:ariadne-size-5" }
|
95
|
+
xl { "ariadne-text-xl ariadne-gap-1 [&>svg]:ariadne-size-6" }
|
83
96
|
end
|
84
97
|
end
|
85
98
|
end
|