ariadne_view_components 0.0.93.2 → 0.0.94

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.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +13 -4
  4. data/app/assets/javascripts/ariadne_view_components.js +14 -14
  5. data/app/assets/javascripts/ariadne_view_components.js.br +0 -0
  6. data/app/assets/javascripts/ariadne_view_components.js.gz +0 -0
  7. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  8. data/app/assets/stylesheets/ariadne_view_components.css +1 -1
  9. data/app/assets/stylesheets/ariadne_view_components.css.br +0 -0
  10. data/app/assets/stylesheets/ariadne_view_components.css.gz +0 -0
  11. data/app/components/ariadne/base_component.rb +25 -22
  12. data/app/components/ariadne/behaviors/tooltipable.rb +12 -12
  13. data/app/components/ariadne/form/checkbox/component.rb +2 -2
  14. data/app/components/ariadne/form/group/component.rb +1 -1
  15. data/app/components/ariadne/form/radio_button/component.rb +2 -2
  16. data/app/components/ariadne/form/select/component.rb +1 -1
  17. data/app/components/ariadne/form/text_field/component.html.erb +2 -2
  18. data/app/components/ariadne/form/text_field/component.rb +14 -7
  19. data/app/components/ariadne/form/toggle/component.rb +2 -2
  20. data/app/components/ariadne/form/toggle_group/component.rb +1 -1
  21. data/app/components/ariadne/form/toggle_group/option/component.rb +1 -1
  22. data/app/components/ariadne/layout/grid/component.rb +1 -1
  23. data/app/components/ariadne/layout/grid/item/component.rb +2 -2
  24. data/app/components/ariadne/layout/label_block/component.rb +1 -1
  25. data/app/components/ariadne/layout/narrow/component.rb +1 -1
  26. data/app/components/ariadne/ui/accordion/component.rb +3 -1
  27. data/app/components/ariadne/ui/accordion/item/component.html.erb +10 -10
  28. data/app/components/ariadne/ui/accordion/item/component.rb +12 -3
  29. data/app/components/ariadne/ui/avatar/component.html.erb +9 -7
  30. data/app/components/ariadne/ui/avatar/component.rb +55 -7
  31. data/app/components/ariadne/ui/badge/component.rb +35 -16
  32. data/app/components/ariadne/ui/banner/component.html.erb +23 -0
  33. data/app/components/ariadne/ui/banner/component.rb +226 -0
  34. data/app/components/ariadne/ui/banner/component.ts +46 -0
  35. data/app/components/ariadne/ui/blankslate/component.html.erb +2 -2
  36. data/app/components/ariadne/ui/blankslate/component.rb +12 -1
  37. data/app/components/ariadne/ui/button/component.rb +35 -24
  38. data/app/components/ariadne/ui/card/body/component.rb +1 -1
  39. data/app/components/ariadne/ui/card/component.rb +11 -7
  40. data/app/components/ariadne/ui/card/footer/component.rb +1 -1
  41. data/app/components/ariadne/ui/card/header/component.html.erb +2 -2
  42. data/app/components/ariadne/ui/card/header/component.rb +25 -16
  43. data/app/components/ariadne/ui/clipboard_copy/component.html.erb +1 -0
  44. data/app/components/ariadne/ui/clipboard_copy/component.rb +17 -21
  45. data/app/components/ariadne/ui/clipboard_copy/component.ts +15 -0
  46. data/app/components/ariadne/ui/color_dot/component.html.erb +5 -5
  47. data/app/components/ariadne/ui/color_dot/component.rb +19 -4
  48. data/app/components/ariadne/ui/combobox/component.html.erb +1 -1
  49. data/app/components/ariadne/ui/combobox/component.rb +54 -23
  50. data/app/components/ariadne/ui/combobox/component.ts +2 -0
  51. data/app/components/ariadne/ui/dialog/body/component.html.erb +3 -0
  52. data/app/components/ariadne/ui/dialog/body/component.rb +28 -0
  53. data/app/components/ariadne/ui/dialog/component.html.erb +25 -24
  54. data/app/components/ariadne/ui/dialog/component.rb +87 -18
  55. data/app/components/ariadne/ui/dialog/component.ts +5 -1
  56. data/app/components/ariadne/ui/dialog/footer/component.html.erb +3 -0
  57. data/app/components/ariadne/ui/dialog/footer/component.rb +34 -0
  58. data/app/components/ariadne/ui/heroicon/component.rb +21 -21
  59. data/app/components/ariadne/ui/image/component.rb +11 -23
  60. data/app/components/ariadne/ui/link/component.html.erb +1 -3
  61. data/app/components/ariadne/ui/link/component.rb +17 -4
  62. data/app/components/ariadne/ui/list/component.html.erb +5 -9
  63. data/app/components/ariadne/ui/list/component.rb +31 -7
  64. data/app/components/ariadne/ui/list/item/component.rb +6 -5
  65. data/app/components/ariadne/ui/pagination/component.rb +1 -2
  66. data/app/components/ariadne/ui/popover/component.html.erb +1 -1
  67. data/app/components/ariadne/ui/popover/component.rb +31 -26
  68. data/app/components/ariadne/ui/relative_time/component.html.erb +1 -0
  69. data/app/components/ariadne/ui/{time_ago → relative_time}/component.rb +15 -15
  70. data/app/components/ariadne/ui/{time_ago → relative_time}/component.ts +1 -1
  71. data/app/components/ariadne/ui/shortcut/component.html.erb +0 -1
  72. data/app/components/ariadne/ui/shortcut/component.rb +31 -5
  73. data/app/components/ariadne/ui/shortcut/component.ts +1 -1
  74. data/app/components/ariadne/ui/skeleton/component.rb +2 -8
  75. data/app/components/ariadne/ui/stats_panel/component.html.erb +3 -3
  76. data/app/components/ariadne/ui/stats_panel/component.rb +25 -1
  77. data/app/components/ariadne/ui/stats_panel/item/component.html.erb +3 -3
  78. data/app/components/ariadne/ui/stats_panel/item/component.rb +6 -6
  79. data/app/components/ariadne/ui/table/cell/component.rb +1 -1
  80. data/app/components/ariadne/ui/table/row/component.rb +1 -1
  81. data/app/components/ariadne/ui/typography/component.rb +3 -1
  82. data/app/frontend/controllers/tooltip_controller.ts +8 -3
  83. data/app/frontend/stylesheets/ariadne_view_components.css +1 -0
  84. data/app/frontend/stylesheets/theme.css +88 -0
  85. data/app/frontend/utils/createController.ts +9 -0
  86. data/app/helpers/ariadne/color_helper.rb +158 -0
  87. data/app/helpers/ariadne/form_helper.rb +1 -0
  88. data/app/helpers/ariadne/size_helper.rb +7 -0
  89. data/app/lib/ariadne/attributes_helper.rb +4 -4
  90. data/app/lib/ariadne/view_component/style_variants.rb +1 -1
  91. data/app/lib/ariadne/view_helper.rb +0 -6
  92. data/lib/ariadne/accessibility.rb +64 -0
  93. data/lib/ariadne/forms/dsl/form_object.rb +5 -1
  94. data/lib/ariadne/forms/dsl/input.rb +1 -1
  95. data/lib/ariadne/static/generate_arguments.rb +54 -0
  96. data/lib/ariadne/static/generate_audited_at.rb +17 -0
  97. data/lib/ariadne/static/generate_constants.rb +19 -0
  98. data/lib/ariadne/static/generate_previews.rb +53 -0
  99. data/lib/ariadne/static/generate_statuses.rb +17 -0
  100. data/lib/ariadne/static/generate_structure.rb +279 -0
  101. data/lib/ariadne/static.rb +68 -0
  102. data/lib/ariadne/view_components/constants.rb +2 -2
  103. data/lib/ariadne/view_components/version.rb +1 -1
  104. data/lib/ariadne/view_components.rb +0 -51
  105. data/lib/ariadne/yard/component_manifest.rb +81 -81
  106. data/lib/ariadne/yard/component_ref.rb +1 -1
  107. data/lib/ariadne/yard/docs_helper.rb +24 -16
  108. data/lib/ariadne/yard/dry_initializer/common_handler.rb +103 -0
  109. data/lib/ariadne/yard/dry_initializer/option_handler.rb +38 -0
  110. data/lib/ariadne/yard/dry_initializer/param_handler.rb +57 -0
  111. data/lib/ariadne/yard/registry.rb +2 -5
  112. data/lib/ariadne/yard/{info_arch_docs_helper.rb → structure_docs_helper.rb} +5 -5
  113. data/lib/ariadne/yard.rb +20 -8
  114. data/lib/rubocop/config/default.yml +0 -3
  115. metadata +34 -37
  116. data/app/components/ariadne/behaviors/captionable.rb +0 -55
  117. data/app/components/ariadne/turbo/frame/component.html.erb +0 -3
  118. data/app/components/ariadne/turbo/frame/component.rb +0 -16
  119. data/app/components/ariadne/turbo/stream_action/component.html.erb +0 -4
  120. data/app/components/ariadne/turbo/stream_action/component.rb +0 -25
  121. data/app/components/ariadne/ui/data_table/component.html.erb +0 -1
  122. data/app/components/ariadne/ui/data_table/component.rb +0 -11
  123. data/app/components/ariadne/ui/flash/component.html.erb +0 -18
  124. data/app/components/ariadne/ui/flash/component.rb +0 -151
  125. data/app/components/ariadne/ui/flash/component.ts +0 -56
  126. data/app/components/ariadne/ui/overlay/component.html.erb +0 -12
  127. data/app/components/ariadne/ui/overlay/component.rb +0 -54
  128. data/app/components/ariadne/ui/overlay/component.ts +0 -92
  129. data/app/components/ariadne/ui/time_ago/component.html.erb +0 -1
  130. data/lib/ariadne/view_components/commands.rb +0 -90
  131. data/lib/ariadne/view_components/statuses.rb +0 -14
  132. data/lib/ariadne/view_components/upstream.rb +0 -19
  133. data/lib/ariadne/yard/lookbook_pages_backend.rb +0 -235
  134. data/lib/rubocop/cop/ariadne/no_tag_memoize.rb +0 -44
  135. data/static/arguments.yml +0 -879
  136. data/static/assets/view-components.svg +0 -18
  137. data/static/classes.yml +0 -211
  138. data/static/constants.json +0 -743
  139. data/static/statuses.json +0 -58
  140. data/static/tailwindcss.yml +0 -727
  141. /data/app/components/ariadne/ui/{time_ago → relative_time}/en.yml +0 -0
@@ -9,24 +9,20 @@
9
9
  <div class="" role="menuitem"><%= link %></div>
10
10
  <% end %>
11
11
  <% checkboxes.each do |checkbox| %>
12
- <div
13
- class="<%= style(:item) %>"
14
- data-<%= stimulus_name %>-target="searchString">
12
+ <div class="<%= style(:item) %>" data-<%= stimulus_name %>-target="searchString">
15
13
  <div class="ariadne-truncate ariadne-w-full" role="menuitemcheckbox"><%= checkbox %></div>
16
14
  </div>
17
15
  <% end %>
18
16
  <% radio_buttons.each do |radio_button| %>
19
- <div
20
- class="<%= style(:item) %>"
21
- data-<%= stimulus_name %>-target="searchString">
17
+ <div class="<%= style(:item) %>" data-<%= stimulus_name %>-target="searchString">
22
18
  <div class="ariadne-truncate" role="menuitemradiobutton"><%= radio_button %></div>
23
19
  </div>
24
20
  <% end %>
25
21
  <% items.each do |item| %>
26
22
  <%= item %>
27
23
  <% end %>
28
- <div class="ariadne-text-center ariadne-hidden" data-<%= stimulus_name %>-target="emptyRoot">
29
- <span class="ariadne-py-3 ariadne-text-md ariadne-text-zinc-600 dark:ariadne-text-zinc-400"><%= @empty_placeholder %> </span>
30
- </div>
24
+ </div>
25
+ <div class="ariadne-text-center ariadne-hidden" data-<%= stimulus_name %>-target="emptyRoot">
26
+ <span class="ariadne-py-3 ariadne-text-md ariadne-text-zinc-600 dark:ariadne-text-zinc-400"><%= @empty_placeholder %> </span>
31
27
  </div>
32
28
  </div>
@@ -4,9 +4,18 @@
4
4
  module Ariadne
5
5
  module UI
6
6
  module List
7
+ # Use this for a vertical list of interactive actions or options.
8
+ # It's composed of items presented in a consistent, single-column format, with room for icons, descriptions, side information, and other visuals.
7
9
  class Component < Ariadne::BaseComponent
8
- option :size, default: proc { :md }
10
+ DEFAULT_SIZE = :md
9
11
 
12
+ # @param [Symbol] size (Ariadne::UI::List::DEFAULT_SIZE) The size of the badge. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
13
+ option :size, default: proc { DEFAULT_SIZE }
14
+
15
+ # Renders a filter field for the list. You will need to provide an option for `empty_placeholder`, which is a string
16
+ # that will be displayed when the results of the filter is empty.
17
+ #
18
+ # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::Form::TextField::Component) %>.
10
19
  renders_one :filter_field, lambda { |**options|
11
20
  raise ArgumentError, "Must provide text for `empty_placeholder`" if options[:empty_placeholder].blank?
12
21
 
@@ -22,17 +31,28 @@ module Ariadne
22
31
  autocomplete: "off",
23
32
  autofocus: true,
24
33
  type: "search",
25
- data: {
26
- "#{stimulus_name}-target": "input",
27
- action: "#{stimulus_name}#handleInput",
28
- },
29
34
  })
30
35
 
36
+ component_data_attrs = {
37
+ "#{stimulus_name}-target": "input",
38
+ action: "#{stimulus_name}#handleInput",
39
+ }
40
+ options[:html_attrs][:data] = merge_data_attributes(options[:html_attrs], component_data_attrs)
41
+
31
42
  Ariadne::Form::TextField::Component.new(**options)
32
43
  }
33
44
 
45
+ # Renders a checkbox in the list.
46
+ #
47
+ # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::Form::Checkbox::Component) %>.
34
48
  renders_many :checkboxes, Ariadne::Form::Checkbox::Component
49
+ # Renders a radiobutton in the list.
50
+ #
51
+ # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::Form::RadioButton::Component) %>.
35
52
  renders_many :radio_buttons, Ariadne::Form::RadioButton::Component
53
+ # Renders a link in the list.
54
+ #
55
+ # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Link::Component) %>.
36
56
  renders_many :links, lambda { |**options|
37
57
  options[:theme] = :nude
38
58
  options[:"data-#{stimulus_name}-target"] = "searchString"
@@ -57,13 +77,17 @@ module Ariadne
57
77
  Ariadne::UI::Link::Component.new(**options)
58
78
  }
59
79
 
80
+ # Renders an item in the list. Use this slot for custom items, or items which ought to be displayed rather than interacted with.
81
+ #
82
+ # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::List::Item::Component) %>.
60
83
  renders_many :items, Ariadne::UI::List::Item::Component
61
84
 
62
85
  accepts_html_attributes do |html_attrs|
63
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style, html_attrs[:class]].join(" "))
64
- html_attrs[:data] = {
86
+ html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
87
+ component_data_attrs = {
65
88
  controller: stimulus_name,
66
89
  }
90
+ html_attrs[:data] = merge_data_attributes(html_attrs, component_data_attrs)
67
91
  end
68
92
 
69
93
  SHARED_BACKGROUND_COLORS = [
@@ -5,16 +5,17 @@ module Ariadne
5
5
  module UI
6
6
  module List
7
7
  module Item
8
+ # Use this class as a wrapper for any custom content you wish to insert into the list.
8
9
  class Component < Ariadne::BaseComponent
9
10
  option :as_menu, default: proc { false }
10
11
 
11
12
  accepts_html_attributes do |html_attrs|
12
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(:item), html_attrs[:class]].join(" "))
13
+ html_attrs[:class] = merge_tailwind_classes([style(:item), html_attrs[:class]].join(" "))
13
14
 
14
- html_attrs[:data] ||= {}
15
- html_attrs[:data] = {
16
- "#{stimulus_name}-target": "searchString",
17
- }.merge(html_attrs[:data])
15
+ component_data_attrs = {
16
+ "#{stimulus_name.sub("-item", "")}-target": "searchString",
17
+ }
18
+ html_attrs[:data] = merge_data_attributes(html_attrs, component_data_attrs)
18
19
  end
19
20
 
20
21
  style :item do
@@ -4,6 +4,7 @@
4
4
  module Ariadne
5
5
  module UI
6
6
  module Pagination
7
+ # Pagination is a horizontal set of links to navigate paginated content.
7
8
  class Component < Ariadne::BaseComponent
8
9
  option :label
9
10
  option :goto_label
@@ -13,8 +14,6 @@ module Ariadne
13
14
 
14
15
  option :callback_page_url
15
16
 
16
- option :page_size_options, default: proc { [10, 25, 50, 100] }
17
-
18
17
  def page_links
19
18
  (1..pages_count).each_with_object([]) do |page, list|
20
19
  if [1, pages_count].include?(page) || page.between?(current_page - 2, current_page + 2)
@@ -1,5 +1,5 @@
1
1
  <div data-controller="<%= @stimulus_controllers %>">
2
- <%= button %>
2
+ <%= reveal_button %>
3
3
  <div class="<%= html_attrs[:class] %>" <%= html_attributes %>>
4
4
  <%= content %>
5
5
  </div>
@@ -4,6 +4,8 @@
4
4
  module Ariadne
5
5
  module UI
6
6
  module Popover
7
+ # A component that displays rich content in a card, triggered by a button. Typically
8
+ # you would use this component to display a menu, a form, or any other card within a hover or trigger.
7
9
  class Component < Ariadne::BaseComponent
8
10
  ALIGNMENT_DEFAULT = :center
9
11
  ALIGNMENT_OPTIONS = [:left, :right, ALIGNMENT_DEFAULT]
@@ -11,41 +13,48 @@ module Ariadne
11
13
  POSITION_DEFAULT = :auto
12
14
  POSITION_OPTIONS = [POSITION_DEFAULT, :above, :below]
13
15
 
14
- option :target_id, optional: true
16
+ # @param [String] target_id (Ariadne::UI::Popover::Component.generate_id) The ID of the element that triggers the popover.
17
+ option :target_id, default: -> { self.class.generate_id }
15
18
 
16
- option :position, default: proc { POSITION_DEFAULT }
17
- option :alignment, default: proc { ALIGNMENT_DEFAULT }
19
+ # @param [Symbol] position (:auto) The position of the popover. <%= one_of(Ariadne::UI::Popover::Component::POSITION_OPTIONS) %>
20
+ option :position, default: -> { POSITION_DEFAULT }
21
+ # @param [Symbol] alignment (:center) The alignment of the popover. <%= one_of(Ariadne::UI::Popover::Component::ALIGNMENT_OPTIONS) %>
22
+ option :alignment, default: -> { ALIGNMENT_DEFAULT }
18
23
 
19
- renders_one :button, lambda { |**options|
20
- options[:html_attrs] ||= {}
21
- options[:html_attrs] = {
22
- popovertarget: target_id,
23
- popovertargetaction: "toggle",
24
- }.merge(options[:html_attrs])
24
+ # The button which reveals the popover.
25
+ #
26
+ # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::Button::Component) %>.
27
+ renders_one :reveal_button, lambda { |**options|
28
+ options[:html_attrs] ||= {}
25
29
 
26
- # requires CSS Anchor Positioning
27
- # options[:html_attrs][:style] = "anchor-name: --popover-#{target_id};"
30
+ options[:html_attrs] = {
31
+ popovertarget: target_id,
32
+ popovertargetaction: "toggle",
33
+ }.merge(options[:html_attrs])
28
34
 
29
- options[:html_attrs][:data] ||= {}
30
- options[:html_attrs][:data] = {
31
- "#{stimulus_name}-target" => ["button", html_attrs.fetch(:data, {}).fetch(:target, nil)].compact.join(" "),
32
- }.merge(options[:html_attrs][:data])
35
+ # requires CSS Anchor Positioning
36
+ # options[:html_attrs][:style] = "anchor-name: --popover-#{target_id};"
37
+
38
+ component_data_attrs = {
39
+ "#{stimulus_name}-target" => "button",
40
+ action: "click->#{stimulus_name}#toggle",
41
+ }
42
+ options[:html_attrs][:data] = merge_data_attributes(options[:html_attrs], component_data_attrs)
33
43
 
34
- Ariadne::UI::Button::Component.new(**options)
35
- }
44
+ Ariadne::UI::Button::Component.new(**options)
45
+ }
36
46
 
37
47
  accepts_html_attributes do |html_attrs|
38
48
  html_attrs[:id] ||= target_id
39
49
  html_attrs[:popover] = ""
40
50
 
41
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style, html_attrs[:class]].join(" "))
51
+ html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
42
52
 
43
53
  # requires CSS Anchor Positioning
44
54
  # as a `style` to account for future feature where the popover can be moved
45
55
  # html_attrs[:style] = "inset: unset; top: anchor(--popover-#{target_id} bottom); right: anchor(--popover-#{target_id} left, -1rem);"
46
56
 
47
- @stimulus_controllers =
48
- [stimulus_name, html_attrs.fetch(:data, {}).delete(:controller)].compact.join(" ")
57
+ @stimulus_controllers = [stimulus_name, html_attrs.fetch(:data, {}).delete(:controller)].compact.join(" ")
49
58
 
50
59
  html_attrs[:data] ||= {}
51
60
  html_attrs[:data] = {
@@ -67,10 +76,6 @@ module Ariadne
67
76
  placement
68
77
  end
69
78
 
70
- def target_id
71
- @target_id ||= ::Ariadne::ViewHelper.generate_id
72
- end
73
-
74
79
  style do
75
80
  base do
76
81
  [
@@ -78,8 +83,8 @@ module Ariadne
78
83
  "ariadne-z-20",
79
84
  "ariadne-rounded-lg",
80
85
  "ariadne-shadow-lg",
81
- "ariadne-bg-foreground",
82
- "dark:ariadne-bg-foreground-dark",
86
+ "ariadne-bg-popover",
87
+ "dark:ariadne-bg-popover-dark",
83
88
  ]
84
89
  end
85
90
  end
@@ -0,0 +1 @@
1
+ <relative-time <%= html_attributes %>><%= @datetime.strftime("%B %-d, %Y %H:%M") %></relative-time>
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Ariadne
5
5
  module UI
6
- module TimeAgo
6
+ module RelativeTime
7
7
  # Formats a timestamp as a localized string or as relative text that auto-updates in the user's browser.
8
8
  class Component < Ariadne::BaseComponent
9
9
  include FetchOrFallbackHelper
@@ -88,33 +88,33 @@ module Ariadne
88
88
 
89
89
  # @param datetime [Time] The time to be formatted.
90
90
  option :datetime
91
- # @param tense [Symbol] Which tense to use. <%= one_of(Primer::Beta::RelativeTime::TENSE_OPTIONS) %>
91
+ # @param tense [Symbol] (TENSE_DEFAULT) Which tense to use. <%= one_of(Ariadne::UI::RelativeTime::Component::TENSE_OPTIONS) %>
92
92
  option :tense, default: -> { TENSE_DEFAULT }
93
- # @param prefix [sring] What to prefix the relative time display with.
93
+ # @param prefix [String] What to prefix the relative time display with.
94
94
  option :prefix, default: -> { nil }
95
- # @param second [Symbol] What format seconds should take. <%= one_of(Primer::Beta::RelativeTime::SECOND_OPTIONS) %>
95
+ # @param second [Symbol] (SECOND_DEFAULT) What format seconds should take. <%= one_of(Ariadne::UI::RelativeTime::Component::SECOND_OPTIONS) %>
96
96
  option :second, default: -> { SECOND_DEFAULT }
97
- # @param minute [Symbol] What format minues should take. <%= one_of(Primer::Beta::RelativeTime::MINUTE_OPTIONS) %>
97
+ # @param minute [Symbol] (MINUTE_DEFAULT) What format minues should take. <%= one_of(Ariadne::UI::RelativeTime::Component::MINUTE_OPTIONS) %>
98
98
  option :minute, default: -> { MINUTE_DEFAULT }
99
- # @param hour [Symbol] What format hours should take. <%= one_of(Primer::Beta::RelativeTime::HOUR_OPTIONS) %>
99
+ # @param hour [Symbol] (HOUR_DEFAULT) What format hours should take. <%= one_of(Ariadne::UI::RelativeTime::Component::HOUR_OPTIONS) %>
100
100
  option :hour, default: -> { HOUR_DEFAULT }
101
- # @param weekday [Symbol] What format weekdays should take. <%= one_of(Primer::Beta::RelativeTime::WEEKDAY_OPTIONS) %>
101
+ # @param weekday [Symbol] (WEEKDAY_DEFAULT) What format weekdays should take. <%= one_of(Ariadne::UI::RelativeTime::Component::WEEKDAY_OPTIONS) %>
102
102
  option :weekday, default: -> { WEEKDAY_DEFAULT }
103
- # @param day [Symbol] What format days should take. <%= one_of(Primer::Beta::RelativeTime::DAY_OPTIONS) %>
103
+ # @param day [Symbol] (DAY_DEFAULT) What format days should take. <%= one_of(Ariadne::UI::RelativeTime::Component::DAY_OPTIONS) %>
104
104
  option :day, default: -> { DAY_DEFAULT }
105
- # @param month [Symbol] What format months should take. <%= one_of(Primer::Beta::RelativeTime::MONTH_OPTIONS) %>
105
+ # @param month [Symbol] (MONTH_DEFAULT) What format months should take. <%= one_of(Ariadne::UI::RelativeTime::Component::MONTH_OPTIONS) %>
106
106
  option :month, default: -> { MONTH_DEFAULT }
107
- # @param year [Symbol] What format years should take. <%= one_of(Primer::Beta::RelativeTime::YEAR_OPTIONS) %>
107
+ # @param year [Symbol] (YEAR_DEFAULT) What format years should take. <%= one_of(Ariadne::UI::RelativeTime::Component::YEAR_OPTIONS) %>
108
108
  option :year, default: -> { YEAR_DEFAULT }
109
- # @param time_zone_name [Symbol] What format the time zone should take. <%= one_of(Primer::Beta::RelativeTime::TIMEZONENAME_OPTIONS) %>
109
+ # @param time_zone_name [Symbol] (TIMEZONENAME_DEFAULT) What format the time zone should take. <%= one_of(Ariadne::UI::RelativeTime::Component::TIMEZONENAME_OPTIONS) %>
110
110
  option :time_zone_name, default: -> { TIMEZONENAME_DEFAULT }
111
111
  # @param threshold [String] The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute.
112
112
  option :threshold, default: -> { nil }
113
- # @param precision [Symbol] The precision elapsed time should display. <%= one_of(Primer::Beta::RelativeTime::PRECISION_OPTIONS) %>
113
+ # @param precision [Symbol] (PRECISION_DEFAULT) The precision elapsed time should display. <%= one_of(Ariadne::UI::RelativeTime::Component::PRECISION_OPTIONS) %>
114
114
  option :precision, default: -> { PRECISION_DEFAULT }
115
- # @param format [Symbol] The format the display should take. <%= one_of(Primer::Beta::RelativeTime::FORMAT_OPTIONS) %>
115
+ # @param format [Symbol] (FORMAT_DEFAULT) The format the display should take. <%= one_of(Ariadne::UI::RelativeTime::Component::FORMAT_OPTIONS) %>
116
116
  option :format, default: -> { FORMAT_DEFAULT }
117
- # @param format_style [Symbol] The format the display should take. <%= one_of(Primer::Beta::RelativeTime::FORMAT_STYLE_OPTIONS) %>
117
+ # @param format_style [Symbol] (FORMAT_STYLE_DEFAULT) The format the display should take. <%= one_of(Ariadne::UI::RelativeTime::Component::FORMAT_STYLE_OPTIONS) %>
118
118
  option :format_style, default: -> { FORMAT_STYLE_DEFAULT }
119
119
  # @param lang [String] The language to use.
120
120
  option :lang, default: -> { nil }
@@ -144,7 +144,7 @@ module Ariadne
144
144
  if datetime.respond_to?(:iso8601)
145
145
  @datetime = datetime
146
146
  html_attrs[:datetime] = datetime.iso8601
147
- elsif datetime.present?
147
+ else
148
148
  @datetime = Time.iso8601(datetime)
149
149
  html_attrs[:datetime] = @datetime
150
150
  end
@@ -1,6 +1,6 @@
1
1
  import '@github/relative-time-element'
2
2
  import {controllerFactory} from '@utils/createController'
3
3
 
4
- export default class TimeAgoController extends controllerFactory<HTMLDetailsElement>()({
4
+ export default class RealativeTimeController extends controllerFactory<HTMLDetailsElement>()({
5
5
  targets: {},
6
6
  }) {}
@@ -1,5 +1,4 @@
1
1
  <span class="ariadne-inline-flex ariadne-items-center ariadne-gap-2">
2
- <span><%= text %></span>
3
2
  <kbd data-controller='<%= stimulus_name %>' <%= html_attributes %>>
4
3
  <% keys.each_with_index do |key, index| %>
5
4
  <% if special_keys.include? key.downcase %>
@@ -4,17 +4,21 @@
4
4
  module Ariadne
5
5
  module UI
6
6
  module Shortcut
7
+ # This component stylizes a keyboard shortcut.
7
8
  class Component < Ariadne::BaseComponent
9
+ DEFAULT_SIZE = :md
8
10
  SPECIAL_KEYS = ["alt", "shift", "ctrl"]
9
11
 
10
- option :text, default: proc { "" }
12
+ # @param keys [Array<String>] The keys to display as a shortcut.
11
13
  option :keys
12
- option :size, default: proc { :base }
14
+
15
+ # @param [Symbol] size (Ariadne::UI::Shortcut::DEFAULT_SIZE) The size of the shortcut. <%= one_of(Ariadne::SizeHelper::VALID_SIZES) %>
16
+ option :size, default: proc { DEFAULT_SIZE }
13
17
 
14
18
  def special_keys = SPECIAL_KEYS
15
19
 
16
20
  accepts_html_attributes do |html_attrs|
17
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(:key, size:), html_attrs[:class]].join(" "))
21
+ html_attrs[:class] = merge_tailwind_classes([style(:key, size:), html_attrs[:class]].join(" "))
18
22
  end
19
23
 
20
24
  style do
@@ -30,7 +34,21 @@ module Ariadne
30
34
 
31
35
  style :key do
32
36
  base do
33
- ["ariadne-font-mono"]
37
+ [
38
+ "ariadne-font-mono",
39
+ "ariadne-px-2",
40
+ "ariadne-py-1.5",
41
+ "ariadne-text-xs",
42
+ "ariadne-font-semibold",
43
+ "ariadne-text-gray-800",
44
+ "ariadne-bg-neutral-50",
45
+ "ariadne-border",
46
+ "ariadne-border-gray-200",
47
+ "ariadne-rounded-lg",
48
+ "ariadne-dark:bg-neutral-600",
49
+ "ariadne-dark:text-gray-100",
50
+ "ariadne-dark:border-gray-500",
51
+ ]
34
52
  end
35
53
 
36
54
  variants do
@@ -43,9 +61,17 @@ module Ariadne
43
61
  ["ariadne-text-sm", "ariadne-px-1.5", "ariadne-rounded"]
44
62
  end
45
63
 
46
- base do
64
+ md do
47
65
  ["ariadne-text-base", "ariadne-px-1.5", "ariadne-rounded-md"]
48
66
  end
67
+
68
+ lg do
69
+ ["ariadne-text-base", "ariadne-px-2", "ariadne-rounded-lg"]
70
+ end
71
+
72
+ xl do
73
+ ["ariadne-text-base", "ariadne-px-3", "ariadne-rounded-xl"]
74
+ end
49
75
  end
50
76
  end
51
77
  end
@@ -16,10 +16,10 @@ export default class extends controllerFactory()({
16
16
  }
17
17
 
18
18
  connect() {
19
+ this.replaceSymbol(this.shiftTargets, '⇧')
19
20
  if (isMac()) {
20
21
  this.replaceSymbol(this.ctrlTargets, '⌘')
21
22
  this.replaceSymbol(this.altTargets, '⌥')
22
- this.replaceSymbol(this.shiftTargets, '⇧')
23
23
  }
24
24
  }
25
25
  }
@@ -4,11 +4,10 @@
4
4
  module Ariadne
5
5
  module UI
6
6
  module Skeleton
7
+ # Use this to show a placeholder while content is loading.
7
8
  class Component < Ariadne::BaseComponent
8
- option :size, default: proc { :base }
9
-
10
9
  accepts_html_attributes do |html_attrs|
11
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(size:), html_attrs[:class]].join(" "))
10
+ html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
12
11
  end
13
12
 
14
13
  def before_render
@@ -32,11 +31,6 @@ module Ariadne
32
31
  end
33
32
 
34
33
  variants do
35
- size do
36
- base do
37
- []
38
- end
39
- end
40
34
  end
41
35
  end
42
36
  end
@@ -1,7 +1,7 @@
1
- <dl class="flex flex-wrap space-x-2 divide-x divide-slate-100 dark:divide-slate-800">
2
- <% stats.each_with_index do |stat, index| %>
1
+ <dl class="<%= html_attrs[:class]%>" <%= html_attributes %>>
2
+ <% stat_items.each_with_index do |stat_item, index| %>
3
3
  <span class="flex-1 <%= 'pl-2' if index > 0 %>">
4
- <%= render stat %>
4
+ <%= render stat_item %>
5
5
  </span>
6
6
  <% end %>
7
7
  </dl>
@@ -4,8 +4,32 @@
4
4
  module Ariadne
5
5
  module UI
6
6
  module StatsPanel
7
+ # Arranges a collection of stats in a horizontal grid.
7
8
  class Component < Ariadne::BaseComponent
8
- renders_many :stats, Item::Component
9
+ # Renders a stat item.
10
+ #
11
+ # @param options [Hash] Same arguments as <%= link_to_component(Ariadne::UI::StatsPanel::Item::Component) %>.
12
+ renders_many :stat_items, Item::Component
13
+
14
+ accepts_html_attributes do |html_attrs|
15
+ html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
16
+ end
17
+
18
+ style do
19
+ base do
20
+ [
21
+ "ariadne-flex",
22
+ "ariadne-flex-wrap",
23
+ "ariadne-space-x-2",
24
+ "ariadne-divide-x",
25
+ "ariadne-divide-slate-100",
26
+ "dark:ariadne-divide-slate-800",
27
+ ]
28
+ end
29
+
30
+ variants do
31
+ end
32
+ end
9
33
  end
10
34
  end
11
35
  end
@@ -1,4 +1,4 @@
1
- <span class="flex flex-col-reverse">
2
- <dt class="text-zinc-600 dark:text-zinc-400 text-xs"><%= label %></dt>
3
- <dd class="<%= style(theme: ) %>"><%= content %></dd>
1
+ <span class="ariadne-flex ariadne-flex-col-reverse">
2
+ <dt class="ariadne-text-zinc-600 dark:ariadne-text-zinc-400 ariadne-text-xs"><%= label %></dt>
3
+ <dd class="<%= html_attrs[:class] %>"><%= content %></dd>
4
4
  </span>
@@ -5,19 +5,19 @@ module Ariadne
5
5
  module UI
6
6
  module StatsPanel
7
7
  module Item
8
+ # Renders a stat item.
8
9
  class Component < Ariadne::BaseComponent
9
- option :theme, default: proc { :default }
10
+ # @param [String] label Indicates the text to display beneath the stat
10
11
  option :label
11
12
 
13
+ accepts_html_attributes do |html_attrs|
14
+ html_attrs[:class] = merge_tailwind_classes([style, html_attrs[:class]].join(" "))
15
+ end
16
+
12
17
  style do
13
18
  base { ["text-number-lg-smb"] }
14
19
 
15
20
  variants do
16
- theme do
17
- default { [] }
18
- success { ["ariadne-text-emerald-600", "dark:ariadne-text-emerald-400"] }
19
- danger { ["ariadne-text-red-600", "dark:ariadne-text-red-400"] }
20
- end
21
21
  end
22
22
  end
23
23
  end
@@ -9,7 +9,7 @@ module Ariadne
9
9
  attr_accessor :context
10
10
 
11
11
  accepts_html_attributes do |html_attrs|
12
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(:cell), html_attrs[:class]].join(" "))
12
+ html_attrs[:class] = merge_tailwind_classes([style(:cell), html_attrs[:class]].join(" "))
13
13
  end
14
14
 
15
15
  def tag_name
@@ -12,7 +12,7 @@ module Ariadne
12
12
  renders_many :cells, Ariadne::UI::Table::Cell::Component
13
13
 
14
14
  accepts_html_attributes do |html_attrs|
15
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(:row), html_attrs[:class]].join(" "))
15
+ html_attrs[:class] = merge_tailwind_classes([style(:row), html_attrs[:class]].join(" "))
16
16
  end
17
17
 
18
18
  style :row do
@@ -4,13 +4,15 @@
4
4
  module Ariadne
5
5
  module UI
6
6
  module Typography
7
+ VALID_TYPES = [:title, :heading, :subheading, :ann, :lede, :code].freeze
8
+
7
9
  class Component < Ariadne::BaseComponent
8
10
  option :tag, optional: true
9
11
  option :type
10
12
  option :size, optional: true
11
13
 
12
14
  accepts_html_attributes do |html_attrs|
13
- html_attrs[:class] = Ariadne::ViewComponents.tailwind_merger.merge([style(type:, size:), html_attrs[:class]].join(" "))
15
+ html_attrs[:class] = merge_tailwind_classes([style(type:, size:), html_attrs[:class]].join(" "))
14
16
  end
15
17
 
16
18
  def tag_name
@@ -1,5 +1,9 @@
1
1
  import {controllerFactory} from '@utils/createController'
2
- import {computePosition, arrow, offset, flip, shift} from '@floating-ui/dom'
2
+ import {computePosition, arrow, offset, flip} from '@floating-ui/dom'
3
+
4
+
5
+ const TRIANGLE_HEIGHT = 6
6
+ const DEFAULT_OFFSET = 4;
3
7
 
4
8
  export default class TooltipController extends controllerFactory<HTMLElement>()({
5
9
  targets: {
@@ -7,16 +11,17 @@ export default class TooltipController extends controllerFactory<HTMLElement>()(
7
11
  wrapper: HTMLDivElement,
8
12
  tooltip: HTMLDivElement,
9
13
  arrow: HTMLDivElement,
14
+ text: HTMLSpanElement,
10
15
  },
11
16
  }) {
12
17
  async update() {
13
18
  computePosition(this.activatorTarget, this.tooltipTarget, {
14
19
  placement: 'top',
15
- middleware: [offset(10), flip(), shift({padding: 5}), arrow({element: this.arrowTarget})],
20
+ middleware: [flip({ padding: 12 }), offset(TRIANGLE_HEIGHT + DEFAULT_OFFSET), arrow({element: this.arrowTarget})],
16
21
  // eslint-disable-next-line github/no-then
17
22
  }).then(({x, y, placement, middlewareData}) => {
18
23
  Object.assign(this.tooltipTarget.style, {
19
- left: `${x}px`,
24
+ left: `0px`,
20
25
  top: `${y}px`,
21
26
  })
22
27
 
@@ -1,4 +1,5 @@
1
1
  @import 'scrollbar.css';
2
+ @import 'theme.css';
2
3
 
3
4
  @tailwind base;
4
5
  @tailwind components;