ariadne_view_components 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/ariadne-form-with.d.ts +20 -0
  4. data/app/assets/javascripts/ariadne-form.d.ts +22 -0
  5. data/app/assets/javascripts/ariadne.d.ts +1 -0
  6. data/app/assets/javascripts/ariadne_view_components.js +7 -1
  7. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  8. data/app/assets/javascripts/clipboard-copy-component.d.ts +4 -0
  9. data/app/assets/javascripts/comment-component.d.ts +13 -0
  10. data/app/assets/javascripts/rich-text-area-component.d.ts +4 -0
  11. data/app/assets/javascripts/slideover-component.d.ts +9 -0
  12. data/app/assets/javascripts/time-ago-component.d.ts +1 -0
  13. data/app/assets/javascripts/time_ago_component.d.ts +1 -0
  14. data/app/assets/javascripts/tooltip-component.d.ts +24 -0
  15. data/app/assets/stylesheets/application.ariadne_view_components.css +6 -3
  16. data/app/assets/stylesheets/prosemirror.css +323 -0
  17. data/app/assets/stylesheets/tooltip-component.css +37 -0
  18. data/app/components/ariadne/ariadne-form.ts +96 -0
  19. data/app/components/ariadne/ariadne.ts +11 -1
  20. data/app/components/ariadne/base_button.rb +12 -12
  21. data/app/components/ariadne/base_component.rb +13 -131
  22. data/app/components/ariadne/blankslate_component.html.erb +5 -5
  23. data/app/components/ariadne/blankslate_component.rb +5 -10
  24. data/app/components/ariadne/body_component.rb +30 -0
  25. data/app/components/ariadne/button_component.rb +12 -16
  26. data/app/components/ariadne/clipboard_copy_component.html.erb +5 -4
  27. data/app/components/ariadne/clipboard_copy_component.rb +41 -3
  28. data/app/components/ariadne/comment-component.ts +55 -0
  29. data/app/components/ariadne/comment_component.html.erb +22 -0
  30. data/app/components/ariadne/comment_component.rb +57 -0
  31. data/app/components/ariadne/component.rb +4 -3
  32. data/app/components/ariadne/container_component.rb +1 -1
  33. data/app/components/ariadne/counter_component.rb +4 -4
  34. data/app/components/ariadne/flash_component.html.erb +12 -12
  35. data/app/components/ariadne/flash_component.rb +17 -17
  36. data/app/components/ariadne/flex_component.rb +49 -0
  37. data/app/components/ariadne/footer_component.html.erb +1 -1
  38. data/app/components/ariadne/footer_component.rb +1 -1
  39. data/app/components/ariadne/grid_component.html.erb +13 -4
  40. data/app/components/ariadne/grid_component.rb +22 -11
  41. data/app/components/ariadne/header_component.html.erb +7 -7
  42. data/app/components/ariadne/header_component.rb +8 -8
  43. data/app/components/ariadne/heading_component.rb +3 -3
  44. data/app/components/ariadne/heroicon_component.html.erb +4 -6
  45. data/app/components/ariadne/heroicon_component.rb +21 -10
  46. data/app/components/ariadne/inline_flex_component.rb +14 -12
  47. data/app/components/ariadne/link_component.rb +13 -8
  48. data/app/components/ariadne/list_component.html.erb +5 -7
  49. data/app/components/ariadne/list_component.rb +9 -38
  50. data/app/components/ariadne/main_component.rb +32 -0
  51. data/app/components/ariadne/narrow_container_component.html.erb +3 -0
  52. data/app/components/ariadne/narrow_container_component.rb +30 -0
  53. data/app/components/ariadne/panel_bar_component.html.erb +20 -0
  54. data/app/components/ariadne/panel_bar_component.rb +79 -0
  55. data/app/components/ariadne/pill_component.rb +2 -2
  56. data/app/components/ariadne/rich-text-area-component.ts +32 -0
  57. data/app/components/ariadne/rich_text_area_component.html.erb +6 -0
  58. data/app/components/ariadne/rich_text_area_component.rb +35 -0
  59. data/app/components/ariadne/slideover-component.ts +3 -3
  60. data/app/components/ariadne/slideover_component.html.erb +3 -6
  61. data/app/components/ariadne/slideover_component.rb +19 -15
  62. data/app/components/ariadne/tab_bar_component.html.erb +3 -0
  63. data/app/components/ariadne/tab_bar_component.rb +45 -0
  64. data/app/components/ariadne/tab_component.html.erb +7 -0
  65. data/app/components/ariadne/tab_component.rb +43 -0
  66. data/app/components/ariadne/{time_ago_component.ts → time-ago-component.ts} +0 -0
  67. data/app/components/ariadne/time_ago_component.rb +2 -2
  68. data/app/components/ariadne/timeline_component.html.erb +6 -6
  69. data/app/components/ariadne/tooltip-component.ts +57 -0
  70. data/app/components/ariadne/tooltip_component.html.erb +4 -0
  71. data/app/components/ariadne/tooltip_component.rb +34 -31
  72. data/app/lib/ariadne/action_view_extensions/form_helper.rb +4 -1
  73. data/app/lib/ariadne/fetch_or_fallback_helper.rb +3 -1
  74. data/app/lib/ariadne/form_builder.rb +22 -22
  75. data/app/lib/ariadne/icon_helper.rb +1 -1
  76. data/lib/ariadne/view_components/engine.rb +171 -3
  77. data/lib/ariadne/view_components/version.rb +1 -1
  78. data/lib/ariadne/view_components.rb +31 -30
  79. data/lib/rubocop/config/default.yml +0 -6
  80. data/lib/rubocop/cop/ariadne/no_tag_memoize.rb +1 -0
  81. data/lib/tasks/docs.rake +9 -0
  82. data/static/arguments.yml +186 -15
  83. data/static/audited_at.json +12 -2
  84. data/static/classes.yml +200 -154
  85. data/static/constants.json +168 -146
  86. data/static/statuses.json +12 -2
  87. metadata +65 -13
  88. data/lib/ariadne/classify/utilities.rb +0 -199
  89. data/lib/ariadne/classify/utilities.yml +0 -1817
  90. data/lib/ariadne/classify/validation.rb +0 -18
  91. data/lib/ariadne/classify.rb +0 -218
  92. data/lib/rubocop/cop/ariadne/ariadne_heroicon.rb +0 -252
  93. data/lib/rubocop/cop/ariadne/component_name_migration.rb +0 -35
  94. data/lib/rubocop/cop/ariadne/system_argument_instead_of_class.rb +0 -57
  95. data/lib/tasks/utilities.rake +0 -121
@@ -1,27 +1,27 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do %>
2
- <div class="rounded-md p-4 <%= BG_SCHEME_CLASS_MAPPINGS[@scheme] %>">
3
- <div class="flex">
4
- <div class="flex-shrink-0">
2
+ <div class="ariadne-rounded-md ariadne-p-4 <%= BG_SCHEME_CLASS_MAPPINGS[@scheme] %>">
3
+ <div class="ariadne-flex">
4
+ <div class="ariadne-flex-shrink-0">
5
5
  <%= icon %>
6
6
  </div>
7
- <div class="ml-3">
8
- <div class="mt-2 text-sm <%= CONTENT_SCHEME_CLASS_MAPPINGS[@scheme] %>">
7
+ <div class="ariadne-ml-3">
8
+ <div class="ariadne-mt-2 ariadne-text-sm <%= CONTENT_SCHEME_CLASS_MAPPINGS[@scheme] %>">
9
9
  <p><%= content %></p>
10
10
  </div>
11
11
  <% if has_action? %>
12
- <div class="mt-4 pt-5">
13
- <div class="-mx-2 -my-1.5 flex">
12
+ <div class="ariadne-mt-4 ariadne-pt-5">
13
+ <div class="ariadne--mx-2 ariadne--my-1.5 ariadne-flex">
14
14
  <%= action %>
15
15
  </div>
16
16
  </div>
17
17
  <% end %>
18
18
  </div>
19
19
  <% if dismissible? %>
20
- <div class="pl-3">
21
- <div class="-mx-1.5 -my-1.5">
22
- <button type="button" class="inline-flex rounded-md p-1.5 focus:outline-none focus:ring-2 focus:ring-offset-2 <%= dismissible_classes %>">
23
- <span class="sr-only">Dismiss</span>
24
- <%= ariadne_heroicon icon: :x, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE %>
20
+ <div class="ariadne-pl-3">
21
+ <div class="ariadne--mx-1.5 ariadne--my-1.5">
22
+ <button type="button" class="ariadne-inline-flex ariadne-rounded-md ariadne-p-1.5 focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2 <%= dismissible_classes %>">
23
+ <span class="ariadne-sr-only">Dismiss</span>
24
+ <%= ariadne_heroicon icon: :"x-mark", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE %>
25
25
  </button>
26
26
  </div>
27
27
  </div>
@@ -8,29 +8,29 @@ module Ariadne
8
8
  DEFAULT_SCHEME = :default
9
9
 
10
10
  DISMISSIBLE_SCHEME_CLASS_MAPPINGS = {
11
- default: "text-blue-500 bg-blue-50 hover:bg-blue-100 focus:ring-offset-blue-50 focus:ring-blue-600",
12
- info: "text-blue-500 bg-blue-50 hover:bg-blue-100 focus:ring-offset-blue-50 focus:ring-blue-600",
13
- success: "text-green-500 bg-green-50 hover:bg-green-100 focus:ring-offset-green-50 focus:ring-green-600",
14
- warning: "text-yellow-500 bg-yellow-50 hover:bg-yellow-100 focus:ring-offset-yellow-50 focus:ring-yellow-600",
15
- danger: "text-red-500 bg-red-50 hover:bg-red-100 focus:ring-offset-red-50 focus:ring-red-600",
11
+ default: "ariadne-text-blue-500 ariadne-bg-blue-50 hover:ariadne-bg-blue-100 focus:ariadne-ring-offset-blue-50 focus:ariadne-ring-blue-600",
12
+ info: "ariadne-text-blue-500 ariadne-bg-blue-50 hover:ariadne-bg-blue-100 focus:ariadne-ring-offset-blue-50 focus:ariadne-ring-blue-600",
13
+ success: "ariadne-text-green-500 ariadne-bg-green-50 hover:ariadne-bg-green-100 focus:ariadne-ring-offset-green-50 focus:ariadne-ring-green-600",
14
+ warning: "ariadne-text-yellow-500 ariadne-bg-yellow-50 hover:ariadne-bg-yellow-100 focus:ariadne-ring-offset-yellow-50 focus:ariadne-ring-yellow-600",
15
+ danger: "ariadne-text-red-500 ariadne-bg-red-50 hover:ariadne-bg-red-100 focus:ariadne-ring-offset-red-50 focus:ariadne-ring-red-600",
16
16
  }.freeze
17
17
  VALID_DISMISSIBLE_SCHEMES = DISMISSIBLE_SCHEME_CLASS_MAPPINGS.keys.freeze
18
18
 
19
19
  BG_SCHEME_CLASS_MAPPINGS = {
20
- default: "bg-blue-50",
21
- info: "bg-blue-50",
22
- success: "bg-green-50",
23
- warning: "bg-yellow-50",
24
- danger: "bg-red-50",
20
+ default: "ariadne-bg-blue-50",
21
+ info: "ariadne-bg-blue-50",
22
+ success: "ariadne-bg-green-50",
23
+ warning: "ariadne-bg-yellow-50",
24
+ danger: "ariadne-bg-red-50",
25
25
  }.freeze
26
26
  VALID_BG_SCHEMES = BG_SCHEME_CLASS_MAPPINGS.keys.freeze
27
27
 
28
28
  CONTENT_SCHEME_CLASS_MAPPINGS = {
29
- default: "text-blue-700",
30
- info: "text-blue-700",
31
- success: "text-green-700",
32
- warning: "text-yellow-700",
33
- danger: "text-red-700",
29
+ default: "ariadne-text-blue-700",
30
+ info: "ariadne-text-blue-700",
31
+ success: "ariadne-text-green-700",
32
+ warning: "ariadne-text-yellow-700",
33
+ danger: "ariadne-text-red-700",
34
34
  }.freeze
35
35
  VALID_CONTENT_SCHEMES = CONTENT_SCHEME_CLASS_MAPPINGS.keys.freeze
36
36
 
@@ -42,7 +42,7 @@ module Ariadne
42
42
  #
43
43
  # @option params [Symbol] :icon The rendered tag name
44
44
  # @option params [Symbol] :icon Name of <%= link_to_heroicons %> to use.
45
- # @option params [Symbol] :variant <%= one_of(HeroiconsHelper::Icon::VARIANTS, sort: false) %>
45
+ # @option params [Symbol] :variant <%= one_of(HeroiconsHelper::Icon::VALID_VARIANTS, sort: false) %>
46
46
  # @option params [String] :classes <%= link_to_classes_docs %>
47
47
  # @option params [Hash] :attributes Same arguments as <%= link_to_component(Ariadne::HeroiconComponent) %>.
48
48
  renders_one :icon, lambda { |tag: :svg, icon:, variant:, classes: "", attributes: {}|
@@ -84,7 +84,7 @@ module Ariadne
84
84
  # @example With actions
85
85
  # <%= render(Ariadne::FlashComponent.new) do |component| %>
86
86
  # <% component.action do %>
87
- # <%= render(Ariadne::ButtonComponent.new(size: :s)) { "Take action" } %>
87
+ # <%= render(Ariadne::ButtonComponent.new(size: :sm)) { "Take action" } %>
88
88
  # <% end %>
89
89
  # This is a flash message with actions!
90
90
  # <% end %>
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ariadne
4
+ # Adds a flex container to the page.
5
+ class FlexComponent < Ariadne::Component
6
+ DEFAULT_TAG = :div
7
+ TAG_OPTIONS = [DEFAULT_TAG].freeze
8
+
9
+ DEFAULT_CLASSES = "flex"
10
+
11
+ VALID_TYPES = [:row, :column, :row_reverse, :column_reverse].freeze
12
+
13
+ # @example Default
14
+ #
15
+ # <%= render(Ariadne::FlexComponent.new(type: :column)) { "Example" } %>
16
+ #
17
+ # @param tag [Symbol, String] The rendered tag name.
18
+ # @param type [Symbol] <%= one_of(Ariadne::FlexComponent::VALID_TYPES) %>
19
+ # @param classes [String] <%= link_to_classes_docs %>
20
+ # @param attributes [Hash] <%= link_to_attributes_docs %>
21
+ def initialize(tag: DEFAULT_TAG, type:, classes: "", attributes: {})
22
+ @tag = check_incoming_tag(DEFAULT_TAG, tag)
23
+ @type = fetch_or_raise(VALID_TYPES, type)
24
+
25
+ flex_class = case @type
26
+ when :row
27
+ "ariadne-flex-row"
28
+ when :column
29
+ "ariadne-flex-col"
30
+ when :row_reverse
31
+ "ariadne-flex-row-reverse"
32
+ when :column_reverse
33
+ "ariadne-flex-col-reverse"
34
+ end
35
+
36
+ @classes = class_names(
37
+ DEFAULT_CLASSES,
38
+ classes,
39
+ flex_class
40
+ )
41
+
42
+ @attributes = attributes
43
+ end
44
+
45
+ def call
46
+ render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content }
47
+ end
48
+ end
49
+ end
@@ -1,6 +1,6 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: :footer, classes: @classes, attributes: @attributes) do |footer| %>
2
2
  <%= render Ariadne::ContainerComponent.new do |container| %>
3
- <p class="mt-6 text-sm text-slate-500 sm:mt-0">
3
+ <p class="ariadne-mt-6 ariadne-text-sm text-slate-500 sm:ariadne-mt-0">
4
4
  <%= content %>
5
5
  </p>
6
6
  <% end %>
@@ -3,7 +3,7 @@
3
3
  module Ariadne
4
4
  # Adds a footer to the bottom of every page.
5
5
  class FooterComponent < Ariadne::Component
6
- DEFAULT_CLASSES = "py-5"
6
+ DEFAULT_CLASSES = "ariadne-py-5"
7
7
 
8
8
  # @example Default
9
9
  #
@@ -1,14 +1,23 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: :ul, classes: @classes, attributes: @attributes) do |grid| %>
2
2
  <% items.each do |item| %>
3
- <li class="col-span-1 flex flex-col text-center rounded-lg shadow divide-y divide-gray-200 my-4 py-4 px-4 text-black-700 border-black <%= item.has_href? ? Ariadne::GridComponent::DEFAULT_LINK_COLOR_CLASSES : "bg-white" %>">
3
+ <li class="<%= item.classes %> <%= item.has_href? ? Ariadne::GridComponent::DEFAULT_LINK_COLOR_CLASSES : "ariadne-bg-white" %>">
4
4
  <% if item.has_href? %>
5
5
  <%= render Ariadne::LinkComponent.new(href: item.href) do %>
6
- <div class="flex-1 flex flex-col p-8">
7
- <%= item.entry %>
6
+ <%= item.entry %>
7
+ <% end %>
8
+ <% if item.actions.any? %>
9
+ <div>
10
+ <div class="ariadne--mt-px ariadne-flex ariadne-divide-x">
11
+ <% item.actions.each_with_index do |action, idx| %>
12
+ <div class="<%= idx.zero? ? '' : 'ariadne--ml-px ' %>w-0 ariadne-flex-1 ariadne-flex">
13
+ <%= action %>
14
+ </div>
15
+ <% end %>
16
+ </div>
8
17
  </div>
9
18
  <% end %>
10
19
  <% else %>
11
- <div class="flex-1 flex flex-col p-8">
20
+ <div class="ariadne-flex-1 ariadne-flex ariadne-flex-col ariadne-p-8">
12
21
  <%= item.entry %>
13
22
  </div>
14
23
  <% end %>
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ariadne
4
- # Arranges items as a grid.
4
+ # Arranges items as a ariadne-grid.
5
5
  class GridComponent < Ariadne::Component
6
- DEFAULT_CLASSES = "grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4"
6
+ DEFAULT_CLASSES = "ariadne-grid ariadne-gap-6 sm:ariadne-grid-cols-2 lg:ariadne-grid-cols-3"
7
7
 
8
- DEFAULT_LINK_COLOR_CLASSES = "text-button-text-color bg-button-bg-color hover:bg-button-hover-color focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500"
8
+ DEFAULT_LINK_COLOR_CLASSES = "ariadne-text-button-text-color ariadne-bg-button-bg-color focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2 focus:ariadne-ring-purple-500"
9
9
 
10
- # The items to show in the grid.
11
- renders_many :items, "Item"
10
+ # The items to show in the ariadne-grid.
11
+ renders_many :items, "GridItem"
12
12
 
13
13
  # @example Default
14
14
  #
@@ -28,18 +28,29 @@ module Ariadne
28
28
 
29
29
  # This component is part of `GridComponent` and should not be
30
30
  # used as a standalone component.
31
- class Item < Ariadne::Component
32
- renders_one :entry, lambda { |static_content = nil, &block|
33
- next static_content if static_content.present?
31
+ class GridItem < Ariadne::Component
32
+ DEFAULT_ITEM_CLASSES = "ariadne-flex ariadne-flex-col ariadne-text-center ariadne-rounded-lg ariadne-shadow ariadne-my-4 text-black-700 ariadne-border-black"
34
33
 
35
- view_context.capture { block&.call }
34
+ DEFAULT_ENTRY_CLASSES = "group ariadne-flex-1 ariadne-flex ariadne-flex-col ariadne-p-8 hover:ariadne-bg-button-hover-color hover:ariadne-text-gray-500 ariadne-rounded-lg"
35
+ renders_one :entry, lambda { |classes: "", &block|
36
+ view_context.capture do
37
+ render(Ariadne::BaseComponent.new(tag: :div, classes: classes)) { block&.call }
38
+ end
36
39
  }
37
40
 
38
- attr_reader :href
41
+ DEFAULT_ACTION_LINK_CLASSES = "text-button-text-color ariadne-relative ariadne--mr-px ariadne-w-0 ariadne-flex-1 ariadne-inline-flex ariadne-items-center ariadne-justify-center ariadne-py-4 ariadne-text-sm ariadne-font-medium ariadne-border ariadne-border-transparent ariadne-rounded-bl-lg ariadne-rounded-lg"
42
+ renders_many :actions, lambda { |href:, icon:, label:, size: Ariadne::HeroiconComponent::SIZE_DEFAULT, variant: HeroiconsHelper::Icon::VARIANT_SOLID, classes: "", attributes: {}, text_classes: ""|
43
+ actual_classes = class_names(DEFAULT_ACTION_LINK_CLASSES, classes)
44
+ render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) do
45
+ render(Ariadne::HeroiconComponent.new(icon: icon, size: size, variant: variant, text_classes: text_classes)) { label }
46
+ end
47
+ }
48
+
49
+ attr_reader :href, :classes, :attributes
39
50
 
40
51
  def initialize(href: nil, classes: "", attributes: {})
41
52
  @href = href
42
- @classes = classes
53
+ @classes = class_names(DEFAULT_ITEM_CLASSES, classes)
43
54
  @attributes = attributes
44
55
  end
45
56
 
@@ -1,23 +1,23 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: :header, classes: @classes, attributes: @attributes) do |header| %>
2
2
  <%= render Ariadne::ContainerComponent.new do |container| %>
3
- <nav class="relative z-50 flex justify-between">
4
- <div class="flex items-center md:gap-x-12">
3
+ <nav class="ariadne-relative ariadne-z-50 ariadne-flex ariadne-justify-between">
4
+ <div class="ariadne-flex ariadne-items-center md:ariadne-gap-x-12">
5
5
  <% if has_logo? %>
6
- <%= render Ariadne::LinkComponent.new(href: @href) do %>
6
+ <%= render Ariadne::LinkComponent.new(href: @href, classes: "ariadne-text-billy-purple") do %>
7
7
  <% if has_image_logo? %>
8
- <span class="sr-only"><%= content %></span>
8
+ <span class="ariadne-sr-only"><%= content %></span>
9
9
  <% end %>
10
10
  <%= logo %>
11
11
  <% end %>
12
12
  <% end %>
13
- <div class="md:flex md:gap-x-6">
13
+ <div class="md:ariadne-flex md:ariadne-gap-x-6">
14
14
  <% navigation_links.each do |link| %>
15
15
  <%= link %>
16
16
  <% end %>
17
17
  </div>
18
18
  </div>
19
- <div class="flex items-center gap-x-5 md:gap-x-8">
20
- <div class="md:block">
19
+ <div class="ariadne-flex ariadne-items-center ariadne-gap-x-5 md:ariadne-gap-x-8">
20
+ <div class="md:ariadne-block">
21
21
  <% action_links.each do |link| %>
22
22
  <%= link %>
23
23
  <% end %>
@@ -3,12 +3,12 @@
3
3
  module Ariadne
4
4
  # Represents the top navigation bar on every page.
5
5
  class HeaderComponent < Ariadne::Component
6
- DEFAULT_CLASSES = "sticky top-0 z-50 px-4 py-2 bg-white shadow-sm shadow-slate-900/5 transition duration-500"
7
- # flex flex-wrap items-center justify-between bg-white dark:shadow-none dark:bg-transparent
8
- LINK_CLASSES = "rounded-lg py-1 px-2 text-slate-700 hover:bg-slate-100 hover:text-slate-900"
6
+ DEFAULT_CLASSES = "ariadne-sticky ariadne-top-0 ariadne-z-50 ariadne-px-4 ariadne-py-5 ariadne-bg-white ariadne-shadow-sm shadow-slate-900/5 ariadne-transition ariadne-duration-500"
7
+ # ariadne-flex ariadne-flex-wrap ariadne-items-center ariadne-justify-between ariadne-bg-white dark:ariadne-shadow-none dark:ariadne-bg-transparent
8
+ LINK_CLASSES = "ariadne-rounded-lg ariadne-py-1 ariadne-px-2 text-slate-700 hover:bg-slate-100 hover:text-slate-900"
9
9
 
10
- DEFAULT_TEXT_LOGO_CLASSES = "flex items-center font-bold text-xl"
11
- DEFAULT_IMAGE_LOGO_CLASSES = "h-10 w-auto"
10
+ DEFAULT_TEXT_LOGO_CLASSES = "ariadne-flex ariadne-items-center ariadne-font-bold ariadne-text-xl"
11
+ DEFAULT_IMAGE_LOGO_CLASSES = "ariadne-h-10 ariadne-w-auto"
12
12
 
13
13
  # Leading visuals at the far left of the header. You can pass either
14
14
  # `src` or `as_text` but not both.
@@ -37,7 +37,7 @@ module Ariadne
37
37
  # @param href [String] The link destination.
38
38
  # @param classes [String] <%= link_to_classes_docs %>
39
39
  # @param attributes [Hash] <%= link_to_attributes_docs %>
40
- DEFAULT_NAV_LINK_CLASSES = "inline-block rounded-lg py-1 px-2 text-sm text-slate-700 hover:bg-slate-100 hover:text-slate-900"
40
+ DEFAULT_NAV_LINK_CLASSES = "ariadne-inline-block ariadne-rounded-lg ariadne-py-1 ariadne-px-2 ariadne-text-sm text-slate-700 hover:bg-slate-100 hover:text-slate-900"
41
41
  renders_many :navigation_links, lambda { |tag: Ariadne::LinkComponent::DEFAULT_TAG, href:, classes: "", attributes: {}|
42
42
  actual_classes = class_names(DEFAULT_NAV_LINK_CLASSES, classes)
43
43
  Ariadne::LinkComponent.new(tag: tag, href: href, classes: actual_classes, attributes: attributes)
@@ -60,13 +60,13 @@ module Ariadne
60
60
  # @param href [String] The link destination.
61
61
  # @param classes [String] <%= link_to_classes_docs %>
62
62
  # @param attributes [Hash] <%= link_to_attributes_docs %>
63
- DEFAULT_SIGNUP_LINK_CLASSES = "group inline-flex items-center justify-center rounded-full py-2 px-4 text-sm font-semibold focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2"
63
+ DEFAULT_SIGNUP_LINK_CLASSES = "group ariadne-inline-flex ariadne-items-center ariadne-justify-center ariadne-rounded-full ariadne-py-2 ariadne-px-4 ariadne-text-sm ariadne-font-semibold focus:ariadne-outline-none focus-visible:outline-2 focus-visible:outline-offset-2"
64
64
  renders_one :signup_link, lambda { |tag: Ariadne::LinkComponent::DEFAULT_TAG, href:, classes: "", attributes: {}|
65
65
  actual_classes = class_names(DEFAULT_SIGNUP_LINK_CLASSES, classes)
66
66
  Ariadne::LinkComponent.new(tag: tag, href: href, classes: actual_classes, attributes: attributes)
67
67
  }
68
68
 
69
- DEFAULT_PROFILE_LINK_CLASSES = "group inline-flex items-center justify-center rounded-full py-2 px-4 text-sm font-semibold focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2"
69
+ DEFAULT_PROFILE_LINK_CLASSES = "group ariadne-inline-flex ariadne-items-center ariadne-justify-center ariadne-rounded-full ariadne-py-2 ariadne-px-4 ariadne-text-sm ariadne-font-semibold focus:ariadne-outline-none focus-visible:outline-2 focus-visible:outline-offset-2"
70
70
  renders_one :profile_link, lambda { |tag: Ariadne::LinkComponent::DEFAULT_TAG, href:, classes: "", attributes: {}|
71
71
  actual_classes = class_names(DEFAULT_PROFILE_LINK_CLASSES, classes)
72
72
  Ariadne::LinkComponent.new(tag: tag, href: href, classes: actual_classes, attributes: attributes)
@@ -20,9 +20,9 @@ module Ariadne
20
20
  TAG_OPTIONS = [:h1, :h2, :h3, :h4, :h5, :h6].freeze
21
21
 
22
22
  TAG_TO_CLASSES = {
23
- h1: "font-bold leading-7 sm:text-3xl",
24
- h2: "text-3xl font-extrabold text-gray-900",
25
- h3: "text-2xl font-extrabold text-gray-900",
23
+ h1: "ariadne-font-bold ariadne-leading-7 sm:ariadne-text-3xl",
24
+ h2: "ariadne-text-3xl ariadne-font-extrabold",
25
+ h3: "ariadne-text-2xl ariadne-font-extrabold",
26
26
  }
27
27
  # @example Default
28
28
  # <%= render(Ariadne::HeadingComponent.new(tag: :h1)) { "H1 Text" } %>
@@ -1,6 +1,4 @@
1
- <span class="inline-flex items-baseline">
2
- <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do %>
3
- <%= @icon.path.html_safe %>
4
- <% end %>
5
- <%= render(Ariadne::BaseComponent.new(tag: :span, classes: @text_classes, attributes: @attributes)) { content } if content.present? %>
6
- </span>
1
+ <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do %>
2
+ <%= @icon.path.html_safe %>
3
+ <% end %>
4
+ <%= render(Ariadne::BaseComponent.new(tag: :span, classes: @text_classes, attributes: @text_attributes)) { content } if content.present? %>
@@ -6,15 +6,19 @@ module Ariadne
6
6
  # `Heroicon` renders an <%= link_to_heroicons %> with <%= link_to_attributes_docs %>.
7
7
  # `Heroicon` can also be rendered with the `heroicon` helper.
8
8
  class HeroiconComponent < Ariadne::Component
9
+ DEFAULT_TEXT_CLASSES = "ariadne-pl-2"
10
+
9
11
  include IconHelper
10
12
  include HeroiconsHelper
11
13
 
12
- SIZE_DEFAULT = :s
13
- SIZE_MEDIUM = :m
14
+ SIZE_DEFAULT = :sm
15
+ SIZE_MEDIUM = :md
16
+ SIZE_LARGE = :lg
14
17
 
15
18
  SIZE_MAPPINGS = {
16
19
  SIZE_DEFAULT => 16,
17
20
  SIZE_MEDIUM => 24,
21
+ SIZE_LARGE => 128,
18
22
  }.freeze
19
23
  SIZE_OPTIONS = SIZE_MAPPINGS.keys
20
24
 
@@ -53,7 +57,7 @@ module Ariadne
53
57
  variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, },
54
58
  { name: "trash",
55
59
  variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, },
56
- { name: "x",
60
+ { name: "x-mark",
57
61
  variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, },
58
62
  ].freeze
59
63
 
@@ -62,7 +66,7 @@ module Ariadne
62
66
  # <%= render(Ariadne::HeroiconComponent.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_SOLID)) %>
63
67
  #
64
68
  # @example Medium
65
- # <%= render(Ariadne::HeroiconComponent.new(icon: :"user-group", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, size: :m)) %>
69
+ # <%= render(Ariadne::HeroiconComponent.new(icon: :"user-group", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, size: :md)) %>
66
70
  #
67
71
  # @example Helper
68
72
  # <%= ariadne_heroicon(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE) %>
@@ -70,10 +74,12 @@ module Ariadne
70
74
  # @param tag [Symbol, String] The rendered tag name
71
75
  # @param classes [String] <%= link_to_classes_docs %>
72
76
  # @param icon [Symbol, String] Name of <%= link_to_heroicons %> to use.
73
- # @param variant [String] <%= one_of(HeroiconsHelper::Icon::VARIANTS, sort: false) %>
77
+ # @param variant [String] <%= one_of(HeroiconsHelper::Icon::VALID_VARIANTS, sort: false) %>
74
78
  # @param size [Symbol] <%= one_of(Ariadne::HeroiconComponent::SIZE_MAPPINGS, sort: false) %>
75
79
  # @param attributes [Hash] <%= link_to_attributes_docs %>
76
- def initialize(tag: :svg, icon:, variant:, size: SIZE_DEFAULT, classes: "", attributes: {})
80
+ # @param text_classes [String] <%= link_to_classes_docs %>
81
+ # @param text_attributes [Hash] <%= link_to_attributes_docs %>
82
+ def initialize(tag: :svg, icon:, variant:, size: SIZE_DEFAULT, classes: "", attributes: {}, text_classes: "", text_attributes: {})
77
83
  @tag = check_incoming_tag(:svg, tag)
78
84
 
79
85
  check_icon_presence!(icon, variant)
@@ -100,18 +106,23 @@ module Ariadne
100
106
  width: @attributes[:width],
101
107
  }
102
108
 
103
- @icon = heroicon(icon, variant: variant, **attributes) # rubocop:disable Ariadne/AriadneHeroicon
109
+ @icon = heroicon(icon, variant: variant, **attributes)
104
110
 
105
111
  @classes = class_names(
106
112
  @icon.attributes[:class],
107
113
  classes
108
114
  )
109
115
  @attributes.merge!(@icon.attributes.except(:class, :"aria-hidden"))
116
+
117
+ @text_classes = class_names(DEFAULT_TEXT_CLASSES, text_classes)
118
+ @text_attributes = text_attributes
110
119
  end
111
120
 
112
- def self._after_compile
113
- HeroiconsHelper::Cache.preload!(PRELOADED_ICONS) do |found, icon|
114
- HeroiconComponent.new(icon: icon[:name], variant: icon[:variant]) unless found
121
+ class << self
122
+ def _after_compile
123
+ HeroiconsHelper::Cache.preload!(PRELOADED_ICONS) do |found, icon|
124
+ HeroiconComponent.new(icon: icon[:name], variant: icon[:variant]) unless found
125
+ end
115
126
  end
116
127
  end
117
128
  end
@@ -9,34 +9,36 @@ module Ariadne
9
9
  # present a static list of SVG images (and can be embedded in buttons or shown alone).
10
10
  class InlineFlexComponent < Ariadne::Component
11
11
  DEFAULT_TAG = :span
12
- DEFAULT_CLASSES = "inline-flex items-baseline"
12
+ DEFAULT_CLASSES = "ariadne-inline-flex ariadne-items-baseline"
13
13
 
14
14
  STATE_OPTIONS = [:closed, :open].freeze
15
15
 
16
16
  STATE_OPEN_SVG = <<~MSG
17
- <svg viewBox="0 0 24 24" width="12" height="12" class="stroke-state-open" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
17
+ <svg viewBox="0 0 24 24" width="12" height="12" class="ariadne-stroke-state-open" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
18
18
  <circle cx="12" cy="12" r="10"></circle>
19
19
  </svg>
20
20
  MSG
21
21
  STATE_CLOSED_SVG = <<~MSG
22
- <svg viewBox="0 0 24 24" width="12" height="12" class="stroke-state-closed fill-state-closed " stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
22
+ <svg viewBox="0 0 24 24" width="12" height="12" class="ariadne-stroke-state-closed fill-state-closed " stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
23
23
  <circle cx="12" cy="12" r="10"></circle>
24
24
  </svg>
25
25
  MSG
26
26
 
27
- renders_one :icon, lambda { |icon, tag: :svg, variant:, size: Ariadne::HeroiconComponent::SIZE_DEFAULT, classes: "", attributes: {}|
28
- Ariadne::HeroiconComponent.new(tag: tag, icon: icon, variant: variant, size: size, classes: classes, attributes: attributes)
27
+ DEFAULT_TEXT_OPEN_CLASSES = "ariadne-text-state-open"
28
+ DEFAULT_TEXT_CLOSED_CLASSES = "ariadne-text-state-closed"
29
+ DEFAULT_TEXT_CLASSES = "ariadne-pl-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-900"
30
+ renders_one :icon, lambda { |tag: :svg, icon:, variant:, size: Ariadne::HeroiconComponent::SIZE_DEFAULT, classes: "", attributes: {}, text_classes: "", text_attributes: {}|
31
+ actual_text_classes = class_names(DEFAULT_TEXT_CLASSES, text_classes)
32
+ Ariadne::HeroiconComponent.new(tag: tag, icon: icon, variant: variant, size: size, classes: classes, attributes: attributes, text_classes: actual_text_classes, text_attributes: text_attributes) { content }
29
33
  }
30
34
 
31
- renders_one :item, lambda { |tag: :span, classes: "", attributes: {}|
32
- Ariadne::BaseComponent.new(tag: tag, classes: classes, attributes: attributes) { content }
35
+ renders_one :item, lambda { |classes: "", attributes: {}|
36
+ Ariadne::BaseComponent.new(tag: :span, classes: classes, attributes: attributes) { content }
33
37
  }
34
38
 
35
- DEFAULT_TEXT_OPEN_CLASSES = "text-state-open"
36
- DEFAULT_TEXT_CLOSED_CLASSES = "text-state-closed"
37
- DEFAULT_TEXT_CLASSES = "pl-2 text-sm font-medium text-gray-900 text-sm"
39
+ DEFAULT_LABEL_CLASSES = "ariadne-pl-2 ariadne-text-sm ariadne-font-medium ariadne-text-gray-900"
38
40
  renders_one :text, lambda { |classes: "", attributes: {}|
39
- actual_classes = class_names(DEFAULT_TEXT_CLASSES, classes)
41
+ actual_classes = class_names(DEFAULT_LABEL_CLASSES, classes)
40
42
  Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes) { content }
41
43
  }
42
44
 
@@ -47,7 +49,7 @@ module Ariadne
47
49
  # <% end %>
48
50
  #
49
51
  # <%= render(Ariadne::InlineFlexComponent.new) do |c| %>
50
- # <% c.icon(:check, size: :s, variant: HeroiconsHelper::Icon::VARIANT_SOLID) %>
52
+ # <% c.icon(icon: :check, size: :sm, variant: HeroiconsHelper::Icon::VARIANT_SOLID) %>
51
53
  # <% c.text { "Closed" } %>
52
54
  # <% end %>
53
55
  #
@@ -6,19 +6,22 @@ module Ariadne
6
6
  DEFAULT_TAG = :a
7
7
  TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
8
8
 
9
- # `Tooltip` that appears on mouse hover or keyboard focus over the link. Use tooltips sparingly and as a last resort.
9
+ DEFAULT_CLASSES = "ariadne-cursor-pointer"
10
+ DEFAULT_ACTIONABLE_CLASSES = " ariadne-cursor-pointer ariadne-underline ariadne-decoration-double ariadne-font-semibold hover:ariadne-text-button-text-color focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2 focus:ariadne-ring-purple-500"
11
+
12
+ # `Tooltip` that appears on mouse hover or keyboard focus over the button. Use tooltips sparingly and as a last resort.
13
+ # **Important:** This tooltip defaults to `type: :description`. In a few scenarios, `type: :label` may be more appropriate.
10
14
  # Consult the <%= link_to_component(Ariadne::TooltipComponent) %> documentation for more information.
11
15
  #
12
16
  # @param tag [Symbol, String] The rendered tag name
13
17
  # @param text [String] The text content of the tooltip. This should be brief and no longer than a sentence.
18
+ # @param direction [Symbol] <%= one_of(Ariadne::TooltipComponent::VALID_PLACEMENTS) %>
14
19
  # @param classes [String] <%= link_to_classes_docs %>
15
- # @param attributes [Hash] <%= link_to_attributes_docs %>
16
- renders_one :tooltip, lambda { |tag: :"tool-tip", text:, classes: "", attributes: {}|
20
+ # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::TooltipComponent) %>.
21
+ renders_one :tooltip, lambda { |tag: Ariadne::TooltipComponent::DEFAULT_TAG, text:, direction: Ariadne::TooltipComponent::DEFAULT_PLACEMENT, type: Ariadne::TooltipComponent::TYPE_DEFAULT, classes: "", attributes: {}|
17
22
  raise ArgumentError, "Links with a tooltip must have a unique `id` set on the `LinkComponent`." if @id.blank?
18
23
 
19
- actual_classes = class_names(classes)
20
-
21
- Ariadne::TooltipComponent.new(tag: tag, text: text, classes: actual_classes, attributes: attributes)
24
+ Ariadne::TooltipComponent.new(tag: tag, for_id: @id, text: text, direction: direction, type: type, classes: classes, attributes: attributes)
22
25
  }
23
26
 
24
27
  # @example Default
@@ -38,9 +41,10 @@ module Ariadne
38
41
  #
39
42
  # @param tag [String] <%= one_of(Ariadne::LinkComponent::TAG_OPTIONS) %>
40
43
  # @param href [String] URL to be used for the link.
44
+ # @param actionable [Boolean] If true, adds additional classes to the link to make it more aware.
41
45
  # @param classes [String] <%= link_to_classes_docs %>
42
46
  # @param attributes [Hash] <%= link_to_attributes_docs %>
43
- def initialize(tag: DEFAULT_TAG, href:, classes: "", attributes: {})
47
+ def initialize(tag: DEFAULT_TAG, href:, actionable: false, classes: "", attributes: {})
44
48
  @tag = check_incoming_tag(DEFAULT_TAG, tag)
45
49
 
46
50
  @attributes = attributes
@@ -48,7 +52,8 @@ module Ariadne
48
52
 
49
53
  @id = @attributes[:id]
50
54
 
51
- @classes = classes
55
+ @classes = class_names(DEFAULT_CLASSES, classes)
56
+ @classes << DEFAULT_ACTIONABLE_CLASSES if actionable
52
57
  end
53
58
 
54
59
  def call
@@ -1,17 +1,15 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |list| %>
2
2
  <% items.each do |item| %>
3
3
  <% if item.linked? %>
4
- <li data-highlight-target="highlightable" class="relative <%= selected? ? 'bg-button-bg-color' : 'hover:bg-button-hover-color' %> focus:ring-2 focus:ring-offset-2 focus:ring-purple-500">
5
- <%= render(item.link) do %>
6
- <%= item.header %>
4
+ <%= render Ariadne::BaseComponent.new(tag: :li, classes: item.classes, attributes: item.attributes) do %>
5
+ <%= render Ariadne::LinkComponent.new(href: item.link[:href], classes: item.link[:classes], attributes: item.link[:attributes]) do %>
7
6
  <%= item.entry %>
8
7
  <% end %>
9
- </li>
8
+ <% end %>
10
9
  <% else %>
11
- <li data-highlight-target="highlightable" class="relative <%= selected? ? 'bg-button-bg-color' : 'hover:bg-button-hover-color' %> focus:ring-2 focus:ring-offset-2 focus:ring-purple-500">
12
- <%= item.header %>
10
+ <%= render Ariadne::BaseComponent.new(tag: :li, classes: item.classes, attributes: item.attributes) do %>
13
11
  <%= item.entry %>
14
- </li>
12
+ <% end %>
15
13
  <% end %>
16
14
  <% end %>
17
15
  <% end %>