ariadne_view_components 0.0.59 → 0.0.65
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +70 -0
- data/LICENSE.txt +661 -49
- data/README.md +52 -4
- data/app/assets/javascripts/ariadne_view_components.js +98 -7
- 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 -7
- 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 +79 -27
- data/app/components/ariadne/behaviors/tooltipable.rb +120 -0
- data/app/components/ariadne/conditional_wrapper.rb +21 -0
- data/app/components/ariadne/form/base_component.rb +74 -0
- data/app/components/ariadne/form/base_input_component.rb +60 -0
- data/app/components/ariadne/form/caption/component.html.erb +10 -0
- data/app/components/ariadne/form/caption/component.rb +29 -0
- data/app/components/ariadne/form/form_control/component.html.erb +19 -0
- data/app/components/ariadne/form/form_control/component.rb +27 -0
- data/app/components/ariadne/form/form_reference/component.html.erb +1 -0
- data/app/components/ariadne/form/form_reference/component.rb +18 -0
- data/app/components/ariadne/form/group/component.html.erb +5 -0
- data/app/components/ariadne/form/group/component.rb +27 -0
- data/app/components/ariadne/form/hidden_field/component.html.erb +1 -0
- data/app/components/ariadne/form/hidden_field/component.rb +15 -0
- data/app/components/ariadne/form/separator/component.html.erb +1 -0
- data/app/components/ariadne/form/separator/component.rb +8 -0
- data/app/components/ariadne/form/spacing_wrapper/component.html.erb +3 -0
- data/app/components/ariadne/form/spacing_wrapper/component.rb +8 -0
- data/app/components/ariadne/form/text_field/component.html.erb +25 -0
- data/app/components/ariadne/form/text_field/component.rb +132 -0
- data/app/components/ariadne/form/validation_message/component.html.erb +5 -0
- data/app/components/ariadne/form/validation_message/component.rb +14 -0
- data/app/components/ariadne/layout/narrow/component.html.erb +10 -0
- data/app/components/ariadne/layout/narrow/component.rb +24 -0
- data/app/components/ariadne/layout/nav_bar/component.css +0 -0
- data/app/components/ariadne/layout/nav_bar/component.html.erb +123 -0
- data/app/components/ariadne/layout/nav_bar/component.rb +77 -0
- data/app/components/ariadne/ui/button/component.html.erb +5 -0
- data/app/components/ariadne/ui/button/component.rb +184 -0
- data/app/components/ariadne/ui/clipboard_copy/component.html.erb +8 -0
- data/app/components/ariadne/ui/clipboard_copy/component.rb +102 -0
- data/app/components/ariadne/ui/clipboard_copy/component.ts +54 -0
- data/app/components/ariadne/ui/combobox/component.html.erb +32 -0
- data/app/components/ariadne/ui/combobox/component.rb +83 -0
- data/app/components/ariadne/ui/combobox/component.ts +119 -0
- data/app/components/ariadne/ui/combobox/menu_item/component.html.erb +9 -0
- data/app/components/ariadne/ui/combobox/menu_item/component.rb +53 -0
- data/app/components/ariadne/ui/combobox/option/component.html.erb +11 -0
- data/app/components/ariadne/ui/combobox/option/component.rb +45 -0
- data/app/components/ariadne/ui/heroicon/component.html.erb +3 -0
- data/app/components/ariadne/ui/heroicon/component.rb +141 -0
- data/app/components/ariadne/ui/image/component.rb +69 -0
- data/app/components/ariadne/ui/link/component.html.erb +3 -0
- data/app/components/ariadne/ui/link/component.rb +56 -0
- data/app/components/ariadne/ui/typography/component.html.erb +3 -0
- data/app/components/ariadne/ui/typography/component.rb +41 -0
- data/app/frontend/ariadne/index.ts +14 -0
- data/app/frontend/ariadne/stimulus_app.ts +53 -0
- data/app/frontend/ariadne/theme.ts +8 -0
- data/app/frontend/controllers/tooltip.ts +75 -0
- data/app/frontend/entrypoints/application.ts +1 -0
- data/app/frontend/stylesheets/ariadne_view_components.css +18 -0
- data/app/frontend/stylesheets/scrollbar.css +28 -0
- data/app/frontend/stylesheets/tippy.js/themes/tomato.css +4 -0
- data/app/frontend/stylesheets/typography.css +117 -0
- data/app/frontend/utils/createController.ts +95 -0
- data/app/helpers/ariadne/form_helper.rb +31 -0
- data/app/lib/ariadne/attributes_helper.rb +119 -0
- data/app/lib/ariadne/fetch_or_fallback_helper.rb +1 -1
- data/app/lib/ariadne/form.rb +16 -0
- data/app/lib/ariadne/view_helper.rb +2 -5
- data/app/lib/view_components_contrib/html_attrs.rb +64 -0
- data/app/lib/view_components_contrib/style_variants.rb +14 -0
- data/lib/ariadne/forms/acts_as_component.rb +125 -0
- data/lib/ariadne/forms/base.html.erb +8 -0
- data/lib/ariadne/forms/base.rb +132 -0
- data/lib/ariadne/forms/buffer_rewriter.rb +51 -0
- data/lib/ariadne/forms/builder.rb +88 -0
- data/lib/ariadne/forms/dsl/button_input.rb +33 -0
- data/lib/ariadne/forms/dsl/form_object.rb +26 -0
- data/lib/ariadne/forms/dsl/input.rb +322 -0
- data/lib/ariadne/forms/dsl/input_group.rb +34 -0
- data/lib/ariadne/forms/dsl/input_methods.rb +157 -0
- data/lib/ariadne/forms/dsl/submit_button_input.rb +36 -0
- data/lib/ariadne/forms/dsl/text_field_input.rb +73 -0
- data/lib/ariadne/forms/utils.rb +34 -0
- data/lib/ariadne/generate.rb +11 -0
- data/lib/ariadne/view_components/engine.rb +24 -7
- data/lib/ariadne/view_components/version.rb +1 -1
- data/lib/ariadne/view_components.rb +1 -1
- data/lib/ariadne/yard/backend.rb +24 -0
- data/lib/ariadne/yard/component_manifest.rb +148 -0
- data/lib/ariadne/yard/component_ref.rb +49 -0
- data/lib/ariadne/yard/docs_helper.rb +98 -0
- data/lib/ariadne/yard/info_arch_docs_helper.rb +31 -0
- data/lib/ariadne/yard/lookbook_docs_helper.rb +32 -0
- data/lib/ariadne/yard/lookbook_pages_backend.rb +235 -0
- data/lib/ariadne/yard/registry.rb +136 -0
- data/lib/ariadne/yard/renders_many_handler.rb +23 -0
- data/lib/ariadne/yard/renders_one_handler.rb +23 -0
- data/lib/ariadne/yard.rb +19 -0
- data/static/arguments.yml +141 -48
- data/static/audited_at.json +0 -9
- data/static/classes.yml +210 -209
- data/static/constants.json +2 -209
- data/static/statuses.json +0 -9
- metadata +140 -210
- data/app/assets/builds/ariadne_view_components.css +0 -2202
- data/app/assets/javascripts/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
- data/app/assets/javascripts/components/ariadne/ariadne-form.d.ts +0 -22
- data/app/assets/javascripts/components/ariadne/ariadne.d.ts +0 -2
- data/app/assets/javascripts/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
- data/app/assets/javascripts/components/ariadne/dropdown/menu_component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/events_controller/events_controller.d.ts +0 -4
- data/app/assets/javascripts/components/ariadne/options_controller/options_controller.d.ts +0 -39
- data/app/assets/javascripts/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
- data/app/assets/javascripts/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
- data/app/assets/javascripts/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
- data/app/assets/javascripts/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
- data/app/assets/javascripts/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
- data/app/assets/javascripts/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
- data/app/assets/javascripts/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
- data/app/assets/javascripts/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
- data/app/assets/stylesheets/dropdown.css +0 -46
- data/app/assets/stylesheets/prosemirror.css +0 -323
- data/app/assets/stylesheets/tooltip-component.css +0 -37
- data/app/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
- data/app/components/ariadne/accumulator_controller/accumulator_controller.js +0 -39
- data/app/components/ariadne/accumulator_controller/accumulator_controller.ts +0 -48
- data/app/components/ariadne/action_card_component.html.erb +0 -13
- data/app/components/ariadne/action_card_component.rb +0 -88
- data/app/components/ariadne/ariadne-form.d.ts +0 -22
- data/app/components/ariadne/ariadne-form.js +0 -85
- data/app/components/ariadne/ariadne.d.ts +0 -2
- data/app/components/ariadne/ariadne.js +0 -24
- data/app/components/ariadne/ariadne.ts +0 -29
- data/app/components/ariadne/avatar_component.rb +0 -81
- data/app/components/ariadne/avatar_stack_component/avatar_stack_component.html.erb +0 -12
- data/app/components/ariadne/avatar_stack_component.rb +0 -75
- data/app/components/ariadne/base_button.rb +0 -70
- data/app/components/ariadne/blankslate_component/blankslate_component.html.erb +0 -26
- data/app/components/ariadne/blankslate_component.rb +0 -148
- data/app/components/ariadne/body_component.rb +0 -30
- data/app/components/ariadne/bottom_tab_component.html.erb +0 -4
- data/app/components/ariadne/bottom_tab_component.rb +0 -44
- data/app/components/ariadne/bottom_tab_nav_component.html.erb +0 -5
- data/app/components/ariadne/bottom_tab_nav_component.rb +0 -33
- data/app/components/ariadne/breadcrumbs_component.html.erb +0 -13
- data/app/components/ariadne/breadcrumbs_component.rb +0 -31
- data/app/components/ariadne/button_component/button_component.html.erb +0 -4
- data/app/components/ariadne/button_component.rb +0 -165
- data/app/components/ariadne/checkbox_component.html.erb +0 -5
- data/app/components/ariadne/checkbox_component.rb +0 -43
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js +0 -18
- data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts +0 -19
- data/app/components/ariadne/clipboard_copy_component/clipboard_copy_component.html.erb +0 -9
- data/app/components/ariadne/clipboard_copy_component.rb +0 -90
- data/app/components/ariadne/close_button_component.html.erb +0 -4
- data/app/components/ariadne/close_button_component.rb +0 -33
- data/app/components/ariadne/combobox_component.html.erb +0 -14
- data/app/components/ariadne/combobox_component.rb +0 -76
- data/app/components/ariadne/component.rb +0 -127
- data/app/components/ariadne/container_component/container_component.html.erb +0 -3
- data/app/components/ariadne/container_component.rb +0 -25
- data/app/components/ariadne/content.rb +0 -12
- data/app/components/ariadne/counter_component.rb +0 -100
- data/app/components/ariadne/details_component/details_component.html.erb +0 -4
- data/app/components/ariadne/details_component.rb +0 -81
- data/app/components/ariadne/dropdown/menu_component.d.ts +0 -1
- data/app/components/ariadne/dropdown/menu_component.html.erb +0 -20
- data/app/components/ariadne/dropdown/menu_component.js +0 -1
- data/app/components/ariadne/dropdown/menu_component.rb +0 -101
- data/app/components/ariadne/dropdown/menu_component.ts +0 -1
- data/app/components/ariadne/dropdown_component/dropdown_component.html.erb +0 -8
- data/app/components/ariadne/dropdown_component.rb +0 -172
- data/app/components/ariadne/events_controller/events_controller.d.ts +0 -4
- data/app/components/ariadne/events_controller/events_controller.js +0 -6
- data/app/components/ariadne/events_controller/events_controller.ts +0 -7
- data/app/components/ariadne/flash_component/flash_component.html.erb +0 -31
- data/app/components/ariadne/flash_component.rb +0 -128
- data/app/components/ariadne/flex_component/flex_component.html.erb +0 -5
- data/app/components/ariadne/flex_component.rb +0 -56
- data/app/components/ariadne/footer_component/footer_component.html.erb +0 -7
- data/app/components/ariadne/footer_component.rb +0 -23
- data/app/components/ariadne/grid_component/grid_component.html.erb +0 -26
- data/app/components/ariadne/grid_component.rb +0 -67
- data/app/components/ariadne/header_component/header_component.html.erb +0 -29
- data/app/components/ariadne/header_component.rb +0 -111
- data/app/components/ariadne/heading_component.rb +0 -49
- data/app/components/ariadne/heroicon_component/heroicon_component.html.erb +0 -4
- data/app/components/ariadne/heroicon_component.rb +0 -166
- data/app/components/ariadne/image_component.rb +0 -53
- data/app/components/ariadne/inline_flex_component/inline_flex_component.html.erb +0 -6
- data/app/components/ariadne/inline_flex_component.rb +0 -72
- data/app/components/ariadne/layout_component.html.erb +0 -21
- data/app/components/ariadne/layout_component.rb +0 -69
- data/app/components/ariadne/link_component.rb +0 -65
- data/app/components/ariadne/list_component/list_component.html.erb +0 -3
- data/app/components/ariadne/list_component.rb +0 -70
- data/app/components/ariadne/modal_component.html.erb +0 -11
- data/app/components/ariadne/modal_component.rb +0 -88
- data/app/components/ariadne/narrow_container_component/narrow_container_component.html.erb +0 -3
- data/app/components/ariadne/narrow_container_component.rb +0 -30
- data/app/components/ariadne/options_controller/options_controller.d.ts +0 -39
- data/app/components/ariadne/options_controller/options_controller.js +0 -89
- data/app/components/ariadne/options_controller/options_controller.ts +0 -122
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.js +0 -237
- data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.ts +0 -278
- data/app/components/ariadne/panel_bar_component/panel_bar_component.html.erb +0 -20
- data/app/components/ariadne/panel_bar_component.rb +0 -80
- data/app/components/ariadne/pill_component/pill_component.html.erb +0 -3
- data/app/components/ariadne/pill_component.rb +0 -44
- data/app/components/ariadne/popover_component.html.erb +0 -10
- data/app/components/ariadne/popover_component.rb +0 -81
- data/app/components/ariadne/progress_bar_component.html.erb +0 -5
- data/app/components/ariadne/progress_bar_component.rb +0 -63
- data/app/components/ariadne/relative_time_component.html.erb +0 -3
- data/app/components/ariadne/relative_time_component.rb +0 -61
- data/app/components/ariadne/show_more_button_component.html.erb +0 -11
- data/app/components/ariadne/show_more_button_component.rb +0 -47
- data/app/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
- data/app/components/ariadne/slideover_component/slideover-component.js +0 -11
- data/app/components/ariadne/slideover_component/slideover-component.ts +0 -17
- data/app/components/ariadne/slideover_component/slideover_component.html.erb +0 -9
- data/app/components/ariadne/slideover_component.rb +0 -66
- data/app/components/ariadne/spinner_component.html.erb +0 -16
- data/app/components/ariadne/spinner_component.rb +0 -45
- data/app/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
- data/app/components/ariadne/string_match_controller/string_match_controller.js +0 -51
- data/app/components/ariadne/string_match_controller/string_match_controller.ts +0 -65
- data/app/components/ariadne/subheader_component.html.erb +0 -11
- data/app/components/ariadne/subheader_component.rb +0 -65
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.js +0 -207
- data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.ts +0 -256
- data/app/components/ariadne/tab_component/tab_component.html.erb +0 -3
- data/app/components/ariadne/tab_component.rb +0 -98
- data/app/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
- data/app/components/ariadne/tab_container_component/tab-container-component.js +0 -23
- data/app/components/ariadne/tab_container_component/tab-container-component.ts +0 -24
- data/app/components/ariadne/tab_container_component.erb +0 -10
- data/app/components/ariadne/tab_container_component.rb +0 -68
- data/app/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
- data/app/components/ariadne/tab_nav_component/tab-nav-component.js +0 -33
- data/app/components/ariadne/tab_nav_component/tab-nav-component.ts +0 -34
- data/app/components/ariadne/tab_nav_component/tab_nav_component.html.erb +0 -7
- data/app/components/ariadne/tab_nav_component.rb +0 -72
- data/app/components/ariadne/table_nav_component/table_nav_component.html.erb +0 -52
- data/app/components/ariadne/table_nav_component.rb +0 -338
- data/app/components/ariadne/text.rb +0 -25
- data/app/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
- data/app/components/ariadne/time_ago_component/time-ago-component.js +0 -1
- data/app/components/ariadne/time_ago_component/time-ago-component.ts +0 -1
- data/app/components/ariadne/time_ago_component.rb +0 -56
- data/app/components/ariadne/timeline_component/timeline_component.html.erb +0 -19
- data/app/components/ariadne/timeline_component.rb +0 -34
- data/app/components/ariadne/toggle_component/toggle_component.html.erb +0 -15
- data/app/components/ariadne/toggle_component.rb +0 -95
- data/app/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
- data/app/components/ariadne/toggleable_controller/toggleable_controller.js +0 -54
- data/app/components/ariadne/toggleable_controller/toggleable_controller.ts +0 -77
- data/app/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
- data/app/components/ariadne/tooltip_component/tooltip-component.js +0 -43
- data/app/components/ariadne/tooltip_component/tooltip-component.ts +0 -57
- data/app/components/ariadne/tooltip_component/tooltip_component.html.erb +0 -4
- data/app/components/ariadne/tooltip_component.rb +0 -108
- data/app/lib/ariadne/action_view_extensions/form_helper.rb +0 -30
- data/app/lib/ariadne/audited/dsl.rb +0 -32
- data/app/lib/ariadne/form_builder.rb +0 -80
- data/app/lib/ariadne/status/dsl.rb +0 -41
- data/config/importmap.rb +0 -3
- data/exe/tailwindcss +0 -21
- data/lib/rubocop/cop/ariadne/base_cop.rb +0 -26
- data/tailwind.config.js +0 -70
@@ -0,0 +1,69 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Ariadne
|
5
|
+
module UI
|
6
|
+
module Image
|
7
|
+
# @example Default
|
8
|
+
#
|
9
|
+
# <%= render(Ariadne::ImageComponent.new(src: "https://github.com/github.png", alt: "GitHub")) %>
|
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 %>
|
29
|
+
class Component < Ariadne::BaseComponent
|
30
|
+
option :src
|
31
|
+
option :alt
|
32
|
+
option :size, default: -> { :original }
|
33
|
+
option :lazy, default: -> { false }
|
34
|
+
|
35
|
+
accepts_html_attributes do |html_attrs|
|
36
|
+
html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(size: @size), html_attrs[:class]].join(" "))
|
37
|
+
|
38
|
+
html_attrs[:src] = @src
|
39
|
+
html_attrs[:alt] = @alt
|
40
|
+
|
41
|
+
next unless @lazy
|
42
|
+
|
43
|
+
html_attrs[:loading] = :lazy
|
44
|
+
html_attrs[:decoding] = :async
|
45
|
+
end
|
46
|
+
|
47
|
+
style do
|
48
|
+
base do
|
49
|
+
["ariadne-object-cover", "ariadne-object-center"]
|
50
|
+
end
|
51
|
+
|
52
|
+
variants do
|
53
|
+
size do
|
54
|
+
xs { "ariadne-w-4" }
|
55
|
+
sm { "ariadne-w-6" }
|
56
|
+
md { "ariadne-w-8" }
|
57
|
+
lg { "ariadne-w-12" }
|
58
|
+
xl { "ariadne-w-16" }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
erb_template <<~ERB
|
64
|
+
<img class="<%= html_attrs[:class] %>" <%= html_attributes %> />
|
65
|
+
ERB
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Ariadne
|
5
|
+
module UI
|
6
|
+
module Link
|
7
|
+
class Component < Ariadne::BaseComponent
|
8
|
+
option :href
|
9
|
+
|
10
|
+
option :theme, default: proc { :base }
|
11
|
+
option :size, default: proc { :base }
|
12
|
+
|
13
|
+
include Ariadne::Behaviors::Tooltipable
|
14
|
+
|
15
|
+
style do
|
16
|
+
base do
|
17
|
+
[
|
18
|
+
"ariadne-inline-flex",
|
19
|
+
"ariadne-items-center",
|
20
|
+
"ariadne-border-b",
|
21
|
+
"ariadne-border-transparent",
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
variants do
|
26
|
+
theme do
|
27
|
+
base do
|
28
|
+
[
|
29
|
+
"[&>svg]:ariadne-text-zinc-400",
|
30
|
+
"[&>svg]:dark:ariadne-text-zinc-600",
|
31
|
+
"hover:ariadne-text-indigo-600",
|
32
|
+
"dark:hover:ariadne-text-indigo-400",
|
33
|
+
"hover:ariadne-border-indigo-600",
|
34
|
+
"dark:hover:ariadne-border-indigo-400",
|
35
|
+
"focus:ariadne-text-indigo-600",
|
36
|
+
"dark:focus:ariadne-text-indigo-400",
|
37
|
+
"focus:!ariadne-border-transparent",
|
38
|
+
"active:ariadne-bg-indigo-700/10",
|
39
|
+
"active:dark:ariadne-bg-indigo-300/10",
|
40
|
+
]
|
41
|
+
end
|
42
|
+
nude { "" }
|
43
|
+
thick { "ariadne-font-semibold" }
|
44
|
+
end
|
45
|
+
size do
|
46
|
+
xs { "ariadne-text-xs ariadne-gap-0.5 [&>svg]:ariadne-size-3" }
|
47
|
+
sm { "ariadne-text-sm ariadne-gap-0.5 [&>svg]:ariadne-size-4" }
|
48
|
+
md { "ariadne-text-base ariadne-gap-1 [&>svg]:ariadne-size-4" }
|
49
|
+
lg { "ariadne-text-lg ariadne-gap-1 [&>svg]:ariadne-size-5" }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Ariadne
|
5
|
+
module UI
|
6
|
+
module Typography
|
7
|
+
class Component < Ariadne::BaseComponent
|
8
|
+
option :type
|
9
|
+
|
10
|
+
accepts_html_attributes do |html_attrs|
|
11
|
+
html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(type: @type), html_attrs[:class]].join(" "))
|
12
|
+
end
|
13
|
+
|
14
|
+
def tag_name
|
15
|
+
case type
|
16
|
+
when :heading
|
17
|
+
:h1
|
18
|
+
else
|
19
|
+
:span
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
style do
|
24
|
+
variants do
|
25
|
+
type do
|
26
|
+
heading do
|
27
|
+
[
|
28
|
+
"ariadne-scroll-m-20",
|
29
|
+
"ariadne-text-4xl",
|
30
|
+
"ariadne-font-extrabold",
|
31
|
+
"ariadne-tracking-tight",
|
32
|
+
"lg:ariadne-text-5xl",
|
33
|
+
]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import '@github/auto-check-element'
|
2
|
+
import '@github/auto-complete-element'
|
3
|
+
import '@github/details-menu-element'
|
4
|
+
import '@github/image-crop-element'
|
5
|
+
import '@github/include-fragment-element'
|
6
|
+
import '@github/markdown-toolbar-element'
|
7
|
+
import '@github/relative-time-element'
|
8
|
+
|
9
|
+
import '~/stylesheets/ariadne_view_components.css'
|
10
|
+
import '~/stylesheets/typography.css'
|
11
|
+
|
12
|
+
import './theme'
|
13
|
+
|
14
|
+
export * from './stimulus_app'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import {Application, type ControllerConstructor} from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
const application = Application.start()
|
4
|
+
|
5
|
+
application.debug = import.meta.env.DEV
|
6
|
+
|
7
|
+
declare global {
|
8
|
+
interface Window {
|
9
|
+
Stimulus: Application
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
window.Stimulus = application
|
14
|
+
|
15
|
+
// Force Vite to process component JS
|
16
|
+
const componentModules = import.meta.glob(['../../components/**/component.ts'], {eager: true})
|
17
|
+
import.meta.glob(['../../components/**/component.css'], {eager: true})
|
18
|
+
|
19
|
+
for (const [path, module] of Object.entries(componentModules)) {
|
20
|
+
const dirs = path.split('/')
|
21
|
+
|
22
|
+
// Dropping ../../components and component.ts parts to end up
|
23
|
+
// with something like "ariadne-ui-component-name"
|
24
|
+
const name = dirs
|
25
|
+
.slice(3, dirs.length - 1)
|
26
|
+
.join('-')
|
27
|
+
.replaceAll('_', '-')
|
28
|
+
.toLocaleLowerCase()
|
29
|
+
|
30
|
+
application.register(
|
31
|
+
// @tag stimulus-id
|
32
|
+
name,
|
33
|
+
(module as {default: ControllerConstructor}).default,
|
34
|
+
)
|
35
|
+
}
|
36
|
+
|
37
|
+
const controllerModules = import.meta.glob(['~/controllers/*.ts'], {eager: true})
|
38
|
+
|
39
|
+
for (const [path, module] of Object.entries(controllerModules)) {
|
40
|
+
const dirs = path.split('/')
|
41
|
+
|
42
|
+
// Dropping ../controllers to end up
|
43
|
+
// with something like "ariadne-component-name"
|
44
|
+
const name = dirs.slice(2, dirs.length).join('-').replace('.ts', '').replaceAll('_', '-').toLocaleLowerCase()
|
45
|
+
|
46
|
+
application.register(
|
47
|
+
// @tag stimulus-id
|
48
|
+
`ariadne-${name}`,
|
49
|
+
(module as {default: ControllerConstructor}).default,
|
50
|
+
)
|
51
|
+
}
|
52
|
+
|
53
|
+
export {application}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
const userTheme = localStorage.getItem('theme') || ''
|
2
|
+
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches
|
3
|
+
|
4
|
+
const themeCheck = () => {
|
5
|
+
if (userTheme === 'dark' || (!userTheme && systemTheme)) {
|
6
|
+
document.documentElement.classList.add('dark')
|
7
|
+
}
|
8
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import {controllerFactory} from '@utils/createController'
|
2
|
+
import {computePosition, arrow, offset, flip, shift} from '@floating-ui/dom'
|
3
|
+
|
4
|
+
import '~/stylesheets/tippy.js/themes/tomato.css'
|
5
|
+
|
6
|
+
export default class TooltipController extends controllerFactory<HTMLElement>()({
|
7
|
+
targets: {
|
8
|
+
activator: HTMLElement,
|
9
|
+
wrapper: HTMLDivElement,
|
10
|
+
tooltip: HTMLDivElement,
|
11
|
+
arrow: HTMLDivElement,
|
12
|
+
},
|
13
|
+
}) {
|
14
|
+
async update() {
|
15
|
+
computePosition(this.activatorTarget, this.tooltipTarget, {
|
16
|
+
placement: 'top',
|
17
|
+
middleware: [offset(10), flip(), shift({padding: 5}), arrow({element: this.arrowTarget})],
|
18
|
+
// eslint-disable-next-line github/no-then
|
19
|
+
}).then(({x, y, placement, middlewareData}) => {
|
20
|
+
Object.assign(this.tooltipTarget.style, {
|
21
|
+
left: `${x}px`,
|
22
|
+
top: `${y}px`,
|
23
|
+
})
|
24
|
+
|
25
|
+
// Reset any previously set styles on the arrow
|
26
|
+
Object.assign(this.arrowTarget.style, {
|
27
|
+
left: '',
|
28
|
+
top: '',
|
29
|
+
right: '',
|
30
|
+
bottom: '',
|
31
|
+
})
|
32
|
+
|
33
|
+
const {x: arrowX, y: arrowY} = middlewareData.arrow || {}
|
34
|
+
const primaryPlacement = placement.split('-')[0]
|
35
|
+
|
36
|
+
switch (primaryPlacement) {
|
37
|
+
case 'top':
|
38
|
+
Object.assign(this.arrowTarget.style, {
|
39
|
+
left: arrowX ? `${arrowX}px` : '',
|
40
|
+
bottom: '-4px', // Aligns arrow to the bottom edge of the tooltip
|
41
|
+
})
|
42
|
+
break
|
43
|
+
case 'bottom':
|
44
|
+
Object.assign(this.arrowTarget.style, {
|
45
|
+
left: arrowX ? `${arrowX}px` : '',
|
46
|
+
top: '-4px', // Aligns arrow to the top edge of the tooltip
|
47
|
+
})
|
48
|
+
break
|
49
|
+
case 'left':
|
50
|
+
Object.assign(this.arrowTarget.style, {
|
51
|
+
top: arrowY ? `${arrowY}px` : '',
|
52
|
+
right: '-4px', // Aligns arrow to the right edge of the tooltip
|
53
|
+
})
|
54
|
+
break
|
55
|
+
case 'right':
|
56
|
+
Object.assign(this.arrowTarget.style, {
|
57
|
+
top: arrowY ? `${arrowY}px` : '',
|
58
|
+
left: '-4px', // Aligns arrow to the left edge of the tooltip
|
59
|
+
})
|
60
|
+
break
|
61
|
+
}
|
62
|
+
})
|
63
|
+
}
|
64
|
+
|
65
|
+
showTooltip(_event: Event) {
|
66
|
+
this.wrapperTarget.classList.add('block')
|
67
|
+
this.wrapperTarget.classList.remove('hidden')
|
68
|
+
this.update()
|
69
|
+
}
|
70
|
+
|
71
|
+
hideTooltip(_event: Event) {
|
72
|
+
this.wrapperTarget.classList.add('hidden')
|
73
|
+
this.wrapperTarget.classList.remove('block')
|
74
|
+
}
|
75
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
import '~/ariadne'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@import 'scrollbar.css';
|
2
|
+
|
3
|
+
@tailwind base;
|
4
|
+
@tailwind components;
|
5
|
+
@tailwind utilities;
|
6
|
+
|
7
|
+
/* Fix summary element usage in Safari only */
|
8
|
+
summary::-webkit-details-marker {
|
9
|
+
display: none;
|
10
|
+
}
|
11
|
+
|
12
|
+
@media (prefers-reduced-motion) {
|
13
|
+
/* Disabling animations everywhere at once */
|
14
|
+
* {
|
15
|
+
animation-duration: 0.01s;
|
16
|
+
transition-duration: 0.01s;
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
.scroll {
|
2
|
+
scrollbar-color: theme('colors.gray.500/20') transparent;
|
3
|
+
|
4
|
+
*::-webkit-scrollbar {
|
5
|
+
@apply ariadne-h-4 ariadne-w-2;
|
6
|
+
}
|
7
|
+
|
8
|
+
*::-webkit-scrollbar:horizontal {
|
9
|
+
@apply ariadne-h-2 ariadne-w-4;
|
10
|
+
}
|
11
|
+
|
12
|
+
*::-webkit-scrollbar-track {
|
13
|
+
@apply ariadne-bg-transparent;
|
14
|
+
}
|
15
|
+
|
16
|
+
*::-webkit-scrollbar-thumb {
|
17
|
+
@apply ariadne-bg-gray-500/20 hover:ariadne-bg-gray-500/40;
|
18
|
+
@apply ariadne-transition-opacity;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
.scrollbar-trigger *::-webkit-scrollbar-thumb {
|
23
|
+
@apply md:ariadne-invisible;
|
24
|
+
}
|
25
|
+
|
26
|
+
.scrollbar-trigger:hover *::-webkit-scrollbar-thumb {
|
27
|
+
@apply md:ariadne-visible;
|
28
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
.typography p,
|
2
|
+
.typography ol,
|
3
|
+
.typography ul {
|
4
|
+
max-width: 600px;
|
5
|
+
}
|
6
|
+
|
7
|
+
.typography a {
|
8
|
+
@apply ariadne-font-medium ariadne-underline;
|
9
|
+
}
|
10
|
+
|
11
|
+
.typography strong {
|
12
|
+
@apply ariadne-font-bold;
|
13
|
+
}
|
14
|
+
|
15
|
+
.typography ol {
|
16
|
+
@apply ariadne-pl-6 ariadne-relative ariadne-list-none;
|
17
|
+
|
18
|
+
counter-reset: list-number;
|
19
|
+
}
|
20
|
+
|
21
|
+
.typography ol > li::before {
|
22
|
+
@apply ariadne-absolute ariadne-left-0 ariadne-overflow-hidden ariadne-w-5 ariadne-text-right;
|
23
|
+
|
24
|
+
counter-increment: list-number;
|
25
|
+
content: counter(list-number) '.';
|
26
|
+
}
|
27
|
+
|
28
|
+
.typography ul {
|
29
|
+
@apply ariadne-pl-6 ariadne-relative ariadne-list-none;
|
30
|
+
}
|
31
|
+
|
32
|
+
.typography ul > li::before {
|
33
|
+
@apply ariadne-absolute ariadne-left-0 ariadne-overflow-hidden ariadne-w-5 ariadne-text-center;
|
34
|
+
|
35
|
+
content: '\25AA';
|
36
|
+
}
|
37
|
+
|
38
|
+
.typography dt {
|
39
|
+
@apply ariadne-font-semibold;
|
40
|
+
}
|
41
|
+
|
42
|
+
.typography hr {
|
43
|
+
@apply ariadne-border-t;
|
44
|
+
}
|
45
|
+
|
46
|
+
.typography blockquote {
|
47
|
+
@apply ariadne-font-medium ariadne-italic ariadne-border-l-4 ariadne-pl-2;
|
48
|
+
}
|
49
|
+
|
50
|
+
.typography blockquote p:first-of-type::before {
|
51
|
+
content: open-quote;
|
52
|
+
}
|
53
|
+
|
54
|
+
.typography blockquote p:last-of-type::after {
|
55
|
+
content: close-quote;
|
56
|
+
}
|
57
|
+
|
58
|
+
.typography kbd {
|
59
|
+
@apply ariadne-font-medium ariadne-text-inherit;
|
60
|
+
|
61
|
+
font-family: inherit;
|
62
|
+
}
|
63
|
+
|
64
|
+
.typography code {
|
65
|
+
@apply ariadne-font-mono ariadne-font-semibold;
|
66
|
+
}
|
67
|
+
|
68
|
+
.typography pre {
|
69
|
+
@apply ariadne-px-3 ariadne-py-2 ariadne-rounded-lg ariadne-bg-zinc-300 dark:ariadne-bg-zinc-700 ariadne-bg-opacity-10 dark:ariadne-bg-opacity-10 ariadne-font-mono ariadne-overflow-x-auto;
|
70
|
+
}
|
71
|
+
|
72
|
+
.typography pre code {
|
73
|
+
@apply ariadne-text-inherit;
|
74
|
+
|
75
|
+
font: inherit;
|
76
|
+
}
|
77
|
+
|
78
|
+
.typography :not(pre) > code {
|
79
|
+
@apply ariadne-p-1 ariadne-bg-zinc-300 dark:ariadne-bg-zinc-700 ariadne-bg-opacity-10 dark:ariadne-bg-opacity-10 ariadne-rounded-lg;
|
80
|
+
}
|
81
|
+
|
82
|
+
.typography pre code::before,
|
83
|
+
.typography pre code::after {
|
84
|
+
@apply ariadne-content-none;
|
85
|
+
}
|
86
|
+
|
87
|
+
.typography table {
|
88
|
+
@apply ariadne-w-full ariadne-table-auto ariadne-text-left;
|
89
|
+
}
|
90
|
+
|
91
|
+
.typography thead {
|
92
|
+
@apply ariadne-border-b ariadne-border-b-slate-50/10;
|
93
|
+
}
|
94
|
+
|
95
|
+
.typography thead th {
|
96
|
+
@apply ariadne-font-semibold ariadne-align-bottom ariadne-py-1;
|
97
|
+
}
|
98
|
+
|
99
|
+
.typography tbody tr {
|
100
|
+
@apply ariadne-border-b ariadne-border-b-slate-50/10;
|
101
|
+
}
|
102
|
+
|
103
|
+
.typography tbody tr:last-child {
|
104
|
+
@apply ariadne-border-b-0;
|
105
|
+
}
|
106
|
+
|
107
|
+
.typography tbody td {
|
108
|
+
@apply ariadne-align-baseline ariadne-py-1;
|
109
|
+
}
|
110
|
+
|
111
|
+
.typography tfoot {
|
112
|
+
@apply ariadne-border-t;
|
113
|
+
}
|
114
|
+
|
115
|
+
.typography tfoot td {
|
116
|
+
@apply ariadne-align-top;
|
117
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import type * as H from 'hotscript'
|
2
|
+
|
3
|
+
import {Controller} from '@hotwired/stimulus'
|
4
|
+
import {type Fn} from 'hotscript'
|
5
|
+
|
6
|
+
type ObjIterator<T, Y extends Fn> = H.Pipe<
|
7
|
+
T,
|
8
|
+
[H.Objects.Entries, H.Unions.ToTuple, H.Tuples.FlatMap<Y>, H.Tuples.ToUnion, H.Objects.FromEntries]
|
9
|
+
>
|
10
|
+
|
11
|
+
/*
|
12
|
+
* Covering `has<Name>` and `<name>Value` for Stimulus values.
|
13
|
+
*/
|
14
|
+
interface ValuesFn extends Fn {
|
15
|
+
return: [
|
16
|
+
[`${this['arg0'][0]}Value`, ReturnType<this['arg0'][1]>],
|
17
|
+
[`has${Capitalize<this['arg0'][0]>}Value`, boolean],
|
18
|
+
]
|
19
|
+
}
|
20
|
+
/*
|
21
|
+
* Covering `has<Name>`, `<name>Target` and `<name>Targets` for Stimulus targets.
|
22
|
+
*/
|
23
|
+
interface TargetsFn extends Fn {
|
24
|
+
return: [
|
25
|
+
[`has${Capitalize<this['arg0'][0]>}Target`, boolean],
|
26
|
+
[`${this['arg0'][0]}Target`, this['arg0'][1] extends null ? HTMLElement : InstanceType<this['arg0'][1]>],
|
27
|
+
[`${this['arg0'][0]}Targets`, this['arg0'][1] extends null ? HTMLElement[] : InstanceType<this['arg0'][1]>[]],
|
28
|
+
]
|
29
|
+
}
|
30
|
+
|
31
|
+
type TargetsConfig = Record<string, (new () => HTMLElement) | null>
|
32
|
+
type ValuesConfig = Record<string, unknown>
|
33
|
+
|
34
|
+
type ControllerWithTargets<E extends HTMLElement, T extends TargetsConfig, Y extends ValuesConfig> = Controller<E> &
|
35
|
+
ObjIterator<T, TargetsFn> &
|
36
|
+
ObjIterator<Y, ValuesFn>
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Creates a new Stimulus controller class with automatically defined target properties.
|
40
|
+
* The function takes an array of target identifiers, which can be either strings or tuples.
|
41
|
+
* For each target, it creates three properties on the controller class:
|
42
|
+
* - `<name>Target` for single target elements,
|
43
|
+
* - `<name>Targets` for all target elements,
|
44
|
+
* - `has<Name>Target` as a boolean indicating the presence of the target.
|
45
|
+
*
|
46
|
+
* The single target elements are typed according to the provided class in the tuple,
|
47
|
+
* or as HTMLElement by default if a string is provided.
|
48
|
+
*
|
49
|
+
* @returns {Function} A new controller class extending the base Stimulus controller with the defined target properties.
|
50
|
+
*
|
51
|
+
* @example
|
52
|
+
* export default class extends controllerFactory<HTMLDivElement>()({
|
53
|
+
* targets: {
|
54
|
+
* one: null,
|
55
|
+
* two: HTMLInputElement,
|
56
|
+
* three: HTMLButtonElement
|
57
|
+
* },
|
58
|
+
* values: {
|
59
|
+
* key: String,
|
60
|
+
* }
|
61
|
+
*}) {
|
62
|
+
* example() {
|
63
|
+
* this.oneTarget // <- HTMLElement
|
64
|
+
* this.twoTarget // <- HTMLInputElement
|
65
|
+
* this.threeTarget // <- HTMLButtonElement
|
66
|
+
*
|
67
|
+
* this.hasOneTarget // <- boolean
|
68
|
+
* this.oneTargets // <- HTMLElement[]
|
69
|
+
*
|
70
|
+
* this.hasKeyValue // <- boolean
|
71
|
+
* this.keyValue // <- string
|
72
|
+
*
|
73
|
+
* this.element // <- HTMLDivElement
|
74
|
+
* }
|
75
|
+
*}
|
76
|
+
*/
|
77
|
+
export function controllerFactory<E extends HTMLElement>() {
|
78
|
+
return function createControllerClass<
|
79
|
+
const T extends TargetsConfig = TargetsConfig,
|
80
|
+
const Y extends ValuesConfig = ValuesConfig,
|
81
|
+
>({
|
82
|
+
targets,
|
83
|
+
values,
|
84
|
+
}: {
|
85
|
+
targets?: T
|
86
|
+
values?: Y
|
87
|
+
} = {}): new () => ControllerWithTargets<E, T, Y> {
|
88
|
+
class ExtendedController extends Controller<E> {
|
89
|
+
static targets = Object.keys(targets ?? {})
|
90
|
+
static values = values ?? {}
|
91
|
+
}
|
92
|
+
|
93
|
+
return ExtendedController as unknown as new () => ControllerWithTargets<E, T, Y>
|
94
|
+
}
|
95
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ariadne
|
4
|
+
# :nocov:
|
5
|
+
# :nodoc:
|
6
|
+
module FormHelper
|
7
|
+
def ariadne_form_with(**kwargs, &block)
|
8
|
+
form_with(**kwargs, skip_default_ids: false, builder: Ariadne::Forms::Builder, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def ariadne_fields_for(record_name, record_object = nil, options = {}, &block)
|
12
|
+
fields_for(
|
13
|
+
record_name,
|
14
|
+
record_object,
|
15
|
+
options.merge(
|
16
|
+
skip_default_ids: false,
|
17
|
+
builder: Ariadne::Forms::Builder,
|
18
|
+
),
|
19
|
+
&block
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def inline_form(*args, &block)
|
24
|
+
Ariadne::Form.inline_form(*args, &block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def render_inline_form(*args, &block)
|
28
|
+
render(inline_form(*args, &block))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|