ariadne_view_components 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/ariadne-form-with.d.ts +20 -0
  3. data/app/assets/javascripts/ariadne-form.d.ts +22 -0
  4. data/app/assets/javascripts/ariadne.d.ts +1 -1
  5. data/app/assets/javascripts/ariadne_view_components.js +7 -1
  6. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  7. data/app/assets/javascripts/comment-component.d.ts +13 -0
  8. data/app/assets/javascripts/rich-text-area-component.d.ts +4 -0
  9. data/app/{components/ariadne/time_ago_component.d.ts → assets/javascripts/time-ago-component.d.ts} +0 -0
  10. data/app/assets/stylesheets/application.ariadne_view_components.css +1 -0
  11. data/app/assets/stylesheets/prosemirror.css +323 -0
  12. data/app/components/ariadne/ariadne-form.ts +96 -0
  13. data/app/components/ariadne/ariadne.ts +8 -1
  14. data/app/components/ariadne/base_button.rb +6 -7
  15. data/app/components/ariadne/base_component.rb +13 -131
  16. data/app/components/ariadne/blankslate_component.html.erb +5 -5
  17. data/app/components/ariadne/blankslate_component.rb +4 -9
  18. data/app/components/ariadne/body_component.rb +1 -1
  19. data/app/components/ariadne/button_component.rb +7 -6
  20. data/app/components/ariadne/clipboard_copy_component.html.erb +3 -2
  21. data/app/components/ariadne/comment-component.ts +55 -0
  22. data/app/components/ariadne/comment_component.html.erb +17 -20
  23. data/app/components/ariadne/comment_component.rb +29 -17
  24. data/app/components/ariadne/component.rb +4 -4
  25. data/app/components/ariadne/container_component.rb +1 -1
  26. data/app/components/ariadne/counter_component.rb +4 -4
  27. data/app/components/ariadne/flash_component.html.erb +12 -12
  28. data/app/components/ariadne/flash_component.rb +16 -16
  29. data/app/components/ariadne/flex_component.rb +5 -7
  30. data/app/components/ariadne/footer_component.html.erb +1 -1
  31. data/app/components/ariadne/footer_component.rb +1 -1
  32. data/app/components/ariadne/grid_component.html.erb +4 -4
  33. data/app/components/ariadne/grid_component.rb +9 -9
  34. data/app/components/ariadne/header_component.html.erb +7 -7
  35. data/app/components/ariadne/header_component.rb +8 -8
  36. data/app/components/ariadne/heading_component.rb +3 -3
  37. data/app/components/ariadne/heroicon_component.rb +4 -4
  38. data/app/components/ariadne/inline_flex_component.rb +7 -7
  39. data/app/components/ariadne/link_component.rb +2 -2
  40. data/app/components/ariadne/list_component.rb +6 -5
  41. data/app/components/ariadne/narrow_container_component.html.erb +3 -0
  42. data/app/components/ariadne/narrow_container_component.rb +30 -0
  43. data/app/components/ariadne/panel_bar_component.html.erb +20 -0
  44. data/app/components/ariadne/panel_bar_component.rb +79 -0
  45. data/app/components/ariadne/pill_component.rb +2 -2
  46. data/app/components/ariadne/rich-text-area-component.ts +32 -0
  47. data/app/components/ariadne/rich_text_area_component.html.erb +6 -0
  48. data/app/components/ariadne/rich_text_area_component.rb +35 -0
  49. data/app/components/ariadne/slideover-component.ts +3 -3
  50. data/app/components/ariadne/slideover_component.html.erb +3 -3
  51. data/app/components/ariadne/slideover_component.rb +1 -1
  52. data/app/components/ariadne/tab_bar_component.html.erb +3 -0
  53. data/app/components/ariadne/tab_bar_component.rb +45 -0
  54. data/app/components/ariadne/tab_component.html.erb +7 -0
  55. data/app/components/ariadne/tab_component.rb +43 -0
  56. data/app/components/ariadne/{time_ago_component.ts → time-ago-component.ts} +0 -0
  57. data/app/components/ariadne/time_ago_component.rb +2 -2
  58. data/app/components/ariadne/timeline_component.html.erb +6 -6
  59. data/app/components/ariadne/tooltip-component.ts +3 -3
  60. data/app/components/ariadne/tooltip_component.html.erb +1 -1
  61. data/app/components/ariadne/tooltip_component.rb +1 -1
  62. data/app/lib/ariadne/action_view_extensions/form_helper.rb +4 -1
  63. data/app/lib/ariadne/fetch_or_fallback_helper.rb +3 -1
  64. data/app/lib/ariadne/form_builder.rb +10 -10
  65. data/app/lib/ariadne/icon_helper.rb +1 -1
  66. data/lib/ariadne/view_components/engine.rb +169 -3
  67. data/lib/ariadne/view_components/version.rb +1 -1
  68. data/lib/ariadne/view_components.rb +0 -1
  69. data/lib/rubocop/config/default.yml +0 -6
  70. data/lib/rubocop/cop/ariadne/no_tag_memoize.rb +1 -0
  71. data/lib/tasks/docs.rake +6 -1
  72. data/static/arguments.yml +99 -4
  73. data/static/audited_at.json +8 -2
  74. data/static/classes.yml +195 -181
  75. data/static/constants.json +112 -72
  76. data/static/statuses.json +8 -2
  77. metadata +42 -32
  78. data/app/assets/builds/ariadne_view_components.css +0 -1874
  79. data/app/components/ariadne/ariadne.d.ts +0 -1
  80. data/app/components/ariadne/ariadne.js +0 -9
  81. data/app/components/ariadne/clipboard-copy-component.d.ts +0 -4
  82. data/app/components/ariadne/clipboard-copy-component.js +0 -18
  83. data/app/components/ariadne/clipboard_copy_component.d.ts +0 -4
  84. data/app/components/ariadne/clipboard_copy_component.js +0 -18
  85. data/app/components/ariadne/slideover-component.d.ts +0 -9
  86. data/app/components/ariadne/slideover-component.js +0 -20
  87. data/app/components/ariadne/slideover_component.d.ts +0 -9
  88. data/app/components/ariadne/slideover_component.js +0 -19
  89. data/app/components/ariadne/time_ago_component.js +0 -1
  90. data/app/components/ariadne/tooltip-component.d.ts +0 -24
  91. data/app/components/ariadne/tooltip-component.js +0 -42
  92. data/lib/ariadne/classify/utilities.rb +0 -199
  93. data/lib/ariadne/classify/utilities.yml +0 -1817
  94. data/lib/ariadne/classify/validation.rb +0 -18
  95. data/lib/ariadne/classify.rb +0 -124
  96. data/lib/rubocop/cop/ariadne/ariadne_heroicon.rb +0 -252
  97. data/lib/rubocop/cop/ariadne/component_name_migration.rb +0 -35
  98. data/lib/rubocop/cop/ariadne/system_argument_instead_of_class.rb +0 -57
  99. data/lib/tasks/utilities.rake +0 -121
@@ -12,14 +12,14 @@ module Ariadne
12
12
  DEFAULT_TAG = :div
13
13
  TAG_OPTIONS = [DEFAULT_TAG].freeze
14
14
 
15
- DEFAULT_CLASSES = "max-w-7xl mx-auto text-center py-12 px-4 sm:px-6 lg:py-16 lg:px-8"
15
+ DEFAULT_CLASSES = "ariadne-text-center"
16
16
 
17
17
  # Optional visual that renders an <%= link_to_component(Ariadne::HeroiconComponent) %>.
18
18
  #
19
19
  # @param tag [Symbol, String] The rendered tag name
20
20
  # @param icon [String] Name of <%= link_to_heroicons %> to use.
21
21
  # @param size [Symbol] <%= one_of(Ariadne::HeroiconComponent::SIZE_MAPPINGS, sort: false) %>
22
- # @param variant [String] <%= one_of(HeroiconsHelper::Icon::VARIANTS, sort: false) %>
22
+ # @param variant [String] <%= one_of(HeroiconsHelper::Icon::VALID_VARIANTS, sort: false) %>
23
23
  # @param classes [String] <%= link_to_classes_docs %>
24
24
  # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::HeroiconComponent) %>.
25
25
  renders_one :icon, lambda { |tag: :svg, icon:, size: Ariadne::HeroiconComponent::SIZE_DEFAULT, variant: HeroiconsHelper::Icon::VARIANT_SOLID, classes: "", attributes: {}|
@@ -113,10 +113,10 @@ module Ariadne
113
113
  #
114
114
  # @example Icon
115
115
  # @description
116
- # Add an `icon` to give additional context. Refer to the [Octicons](https://primer.style/octicons/) documentation to choose an icon.
116
+ # Add an `icon` to give additional context. Refer to the [Heroicons](https://heroicons.com) documentation to choose an icon.
117
117
  # @code
118
118
  # <%= render Ariadne::BlankslateComponent.new do |c| %>
119
- # <% c.icon(icon: :globe) %>
119
+ # <% c.icon(icon: :"globe-europe-africa") %>
120
120
  # <% c.heading(tag: :h2).with_content("heading") %>
121
121
  # <% c.description { "Description"} %>
122
122
  # <% end %>
@@ -142,10 +142,5 @@ module Ariadne
142
142
  def render?
143
143
  heading.present?
144
144
  end
145
-
146
- def wrapper
147
- yield
148
- nil # returning `yield` causes a double render
149
- end
150
145
  end
151
146
  end
@@ -5,7 +5,7 @@ module Ariadne
5
5
  # Add additional usage considerations or best practices that may aid the user to use the component correctly.
6
6
  # @accessibility Add any accessibility considerations
7
7
  class BodyComponent < Ariadne::Component
8
- DEFAULT_CLASSES = "flex flex-col min-h-screen"
8
+ DEFAULT_CLASSES = "ariadne-flex ariadne-flex-col ariadne-min-h-screen"
9
9
 
10
10
  # @example Default
11
11
  #
@@ -9,11 +9,12 @@ module Ariadne
9
9
  LINK_SCHEME = :link
10
10
 
11
11
  SCHEME_CLASS_MAPPINGS = {
12
- default: "text-purple-800 bg-purple-50 hover:bg-purple-100 border-purple-300 focus:ring-offset-purple-50 focus:ring-purple-600",
13
- info: "text-blue-800 bg-blue-50 hover:bg-blue-100 border-blue-300 focus:ring-offset-blue-50 focus:ring-blue-600",
14
- success: "text-green-800 bg-green-50 hover:bg-green-100 border-green-300 focus:ring-offset-green-50 focus:ring-green-600",
15
- warning: "text-yellow-800 bg-yellow-50 hover:bg-yellow-100 border-yellow-300 focus:ring-offset-yellow-50 focus:ring-yellow-600",
16
- danger: "text-red-800 bg-red-50 hover:bg-red-100 border-red-300 focus:ring-offset-red-50 focus:ring-red-600",
12
+ none: "",
13
+ default: "ariadne-text-purple-800 ariadne-bg-purple-50 hover:ariadne-bg-purple-100 ariadne-border-purple-300 focus:ariadne-ring-offset-purple-50 focus:ariadne-ring-purple-600",
14
+ info: "ariadne-text-blue-800 ariadne-bg-blue-50 hover:ariadne-bg-blue-100 ariadne-border-blue-300 focus:ariadne-ring-offset-blue-50 focus:ariadne-ring-blue-600",
15
+ success: "ariadne-text-green-800 ariadne-bg-green-50 hover:ariadne-bg-green-100 ariadne-border-green-300 focus:ariadne-ring-offset-green-50 focus:ariadne-ring-green-600",
16
+ warning: "ariadne-text-yellow-800 ariadne-bg-yellow-50 hover:ariadne-bg-yellow-100 ariadne-border-yellow-300 focus:ariadne-ring-offset-yellow-50 focus:ariadne-ring-yellow-600",
17
+ danger: "ariadne-text-red-800 ariadne-bg-red-50 hover:ariadne-bg-red-100 ariadne-border-red-300 focus:ariadne-ring-offset-red-50 focus:ariadne-ring-red-600",
17
18
  }.freeze
18
19
  VALID_SCHEMES = SCHEME_CLASS_MAPPINGS.keys.freeze
19
20
 
@@ -26,7 +27,7 @@ module Ariadne
26
27
  # @param tag [Symbol, String] The rendered tag name
27
28
  # @param classes [String] <%= link_to_classes_docs %>
28
29
  # @param icon [String] Name of <%= link_to_heroicons %> to use.
29
- # @param variant [String] <%= one_of(HeroiconsHelper::Icon::VARIANTS, sort: false) %>
30
+ # @param variant [String] <%= one_of(HeroiconsHelper::Icon::VALID_VARIANTS, sort: false) %>
30
31
  # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::HeroiconComponent) %>.
31
32
  renders_one :icon, lambda { |tag: :svg, icon:, variant:, classes: "", attributes: {}|
32
33
  @icon = icon
@@ -2,7 +2,8 @@
2
2
  <% if content.present? %>
3
3
  <%= content.to_s + tooltip.to_s %>
4
4
  <% else %>
5
- <%= render Ariadne::HeroiconComponent.new(icon: :duplicate, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE) %>
6
- <%= render Ariadne::HeroiconComponent.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, attributes: { color: :success, style: "display: none;" }) %>
5
+ <%= render Ariadne::HeroiconComponent.new(icon: :"document-duplicate", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE) %>
6
+ <!-- TODO: fix, check should replace on click -->
7
+ <%= render Ariadne::HeroiconComponent.new(icon: :check, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, classes: "ariadne-text-green-600", attributes: { style: "display: none;" }) %>
7
8
  <% end %>
8
9
  <% end %>
@@ -0,0 +1,55 @@
1
+ import {Controller} from '@hotwired/stimulus'
2
+
3
+ export default class CommentComponent extends Controller {
4
+ static targets = ['tab', 'tabBarComponent']
5
+
6
+ declare readonly commentComponentTarget: HTMLDivElement
7
+ declare readonly tabBarComponentTarget: HTMLElement // technically a `nav but typescript can't find it?
8
+ declare readonly tabTargets: [HTMLButtonElement]
9
+
10
+ SELECTED_TAB_CLASSES = ['ariadne-border-indigo-500', 'ariadne-text-indigo-600']
11
+ PUBLIC_BACKGROUND_COLOR = 'ariadne-bg-white'
12
+ INTERNAL_BACKGROUND_COLOR = 'ariadne-bg-internal-message'
13
+
14
+ connect() {
15
+ for (const tab of this.tabTargets) {
16
+ if (tab.hasAttribute('selected')) {
17
+ tab.classList.add(...this.SELECTED_TAB_CLASSES)
18
+ }
19
+ }
20
+ }
21
+
22
+ toggleTab() {
23
+ for (const tab of this.tabTargets) {
24
+ if (tab.hasAttribute('selected')) {
25
+ tab.removeAttribute('selected')
26
+ tab.classList.remove(...this.SELECTED_TAB_CLASSES)
27
+ this.toggleBackgrounds(tab)
28
+ } else {
29
+ tab.setAttribute('selected', 'true')
30
+ tab.classList.add(...this.SELECTED_TAB_CLASSES)
31
+ this.toggleBackgrounds(tab)
32
+ if (tab.hasAttribute('data-public')) {
33
+ document.getElementById('message_public')?.setAttribute('value', 'true')
34
+ } else {
35
+ document.getElementById('message_public')?.setAttribute('value', 'false')
36
+ }
37
+ }
38
+ }
39
+ }
40
+ toggleBackgrounds(tab: HTMLButtonElement) {
41
+ if (tab.hasAttribute('selected')) {
42
+ if (tab.hasAttribute('data-public')) {
43
+ // this.commentComponentTarget.classList.add(this.PUBLIC_BACKGROUND_COLOR)
44
+ // this.commentComponentTarget.classList.remove(this.INTERNAL_BACKGROUND_COLOR)
45
+ this.tabBarComponentTarget.classList.add(this.PUBLIC_BACKGROUND_COLOR)
46
+ this.tabBarComponentTarget.classList.remove(this.INTERNAL_BACKGROUND_COLOR)
47
+ } else {
48
+ // this.commentComponentTarget.classList.remove(this.PUBLIC_BACKGROUND_COLOR)
49
+ // this.commentComponentTarget.classList.add(this.INTERNAL_BACKGROUND_COLOR)
50
+ this.tabBarComponentTarget.classList.remove(this.PUBLIC_BACKGROUND_COLOR)
51
+ this.tabBarComponentTarget.classList.add(this.INTERNAL_BACKGROUND_COLOR)
52
+ }
53
+ }
54
+ }
55
+ }
@@ -1,25 +1,22 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |comment| %>
2
- <div>
3
- <div class="flex items-center" aria-orientation="horizontal" role="tablist">
4
- <% tabs.each do |tab| %>
5
- <%= tab %>
6
- <% end %>
1
+ <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do %>
2
+ <div class="ariadne-bg-white" data-comment-component-target="commentComponent">
3
+ <div class="ariadne-hidden sm:ariadne-block">
4
+ <div class="ariadne-border-b ariadne-border-gray-200">
5
+ <%= render(Ariadne::TabBarComponent.new(sr_label: @sr_label, attributes: { :"data-comment-component-target" => "tabBarComponent" })) do |tab_bar| %>
6
+ <%= public_tab %>
7
+ <%= internal_tab %>
8
+ <% end %>
9
+ </div>
7
10
  </div>
8
- <div class="mt-2">
9
- <div id="tabs-1-panel-1" class="p-0.5 -m-0.5 rounded-lg" aria-labelledby="tabs-1-tab-1" role="tabpanel" tabindex="0">
10
- <label for="comment" class="sr-only">Comment</label>
11
- <div>
12
- <textarea rows="5" name="comment" id="comment" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" placeholder="Add your comment..."></textarea>
13
- </div>
11
+ <%= ariadne_form_with(url: @url, method: @method, classes: @classes, attributes: @attributes) do |comment_box| %>
12
+ <div class="ariadne-overflow-hidden ariadne-border-x ariadne-border-b ariadne-border-gray-300 ariadne-shadow-sm focus-within:ariadne-border-indigo-500 focus-within:ariadne-ring-1 focus-within:ariadne-ring-indigo-500">
13
+ <%= hidden_field_tag 'message_public', true %>
14
+ <%= render(Ariadne::RichTextAreaComponent.new(name: :bodytext, sr_label: "Select reply type", attributes: { required: true})) %>
15
+ <% comment_box.submit { @submit } %>
14
16
  </div>
15
- <div id="tabs-1-panel-2" class="p-0.5 -m-0.5 rounded-lg" aria-labelledby="tabs-1-tab-2" role="tabpanel" tabindex="0">
16
- <div class="border-b">
17
- <div class="mx-px mt-px px-3 pt-2 pb-12 text-sm leading-5 text-gray-800">Preview content will render here.</div>
18
- </div>
17
+ <div class="ariadne-mt-2 ariadne-flex ariadne-justify-end">
18
+ <%= submit %>
19
19
  </div>
20
- </div>
21
- </div>
22
- <div class="mt-2 flex justify-end">
23
- <%= submit %>
20
+ <% end %>
24
21
  </div>
25
22
  <% end %>
@@ -1,45 +1,57 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ariadne
4
- # Defines a submittble form for adding comments to a conversation.
4
+ # Defines a submittable form for adding comments to a conversation.
5
+ # @accessibility This component requires you to pass in a `sr_label`
6
+ # attribute, which will be used to label the tabs for screen readers.
5
7
  class CommentComponent < Ariadne::Component
6
- DEFAULT_TAG = :form
8
+ DEFAULT_TAG = :div
7
9
  TAG_OPTIONS = [DEFAULT_TAG].freeze
8
10
 
9
- DEFAULT_CLASSES = ""
11
+ DEFAULT_CLASSES = "ariadne-bg-white ariadne-border-gray-300 ariadne-border ariadne-shadow ariadne-py-5 ariadne-px-5 ariadne-rounded-md "
10
12
 
11
- DEFAULT_TAB_CLASSES = "text-gray-500 hover:text-gray-900 bg-white hover:bg-gray-100 px-3 py-1.5 border border-transparent text-sm font-medium rounded-md"
12
- renders_many :tabs, lambda { |classes: "", attributes: {}|
13
- actual_classes = class_names(DEFAULT_TAB_CLASSES, classes)
13
+ renders_one :public_tab, lambda { |selected: false, text:, classes: "", attributes: {}|
14
+ attributes[:"data-comment-component-target"] ||= "tab"
15
+ attributes[:"data-action"] ||= "click->comment-component#toggleTab"
16
+ attributes[:"data-public"] = true
14
17
  @tab_idx += 1
15
- attributes[:id] = "comment-tabs-tab-#{@tab_idx}"
16
- attributes[:"aria-controls"] = "comment-tabs-panel-#{@tab_idx}"
17
- attributes[:role] = "tab"
18
- attributes[:type] = "button"
18
+ render(Ariadne::TabComponent.new(selected: selected, classes: classes, attributes: attributes)) { text }
19
+ }
19
20
 
20
- Ariadne::BaseComponent.new(tag: :button, classes: actual_classes, attributes: attributes)
21
+ renders_one :internal_tab, lambda { |selected: false, text:, classes: "", attributes: {}|
22
+ attributes[:"data-comment-component-target"] ||= "tab"
23
+ attributes[:"data-action"] ||= "click->comment-component#toggleTab"
24
+ @tab_idx += 1
25
+ render(Ariadne::TabComponent.new(selected: selected, classes: classes, attributes: attributes)) { text }
21
26
  }
22
27
 
23
28
  renders_one :submit, lambda { |classes: "", attributes: {}|
24
- Ariadne::ButtonComponent.new(type: Ariadne::BaseButton::TYPE_SUBMIT, classes: classes, attributes: attributes)
29
+ Ariadne::ButtonComponent.new(type: Ariadne::BaseButton::TYPE_SUBMIT, scheme: Ariadne::ButtonComponent::DEFAULT_SCHEME, classes: classes, attributes: attributes)
25
30
  }
26
31
 
27
32
  # @example Default
28
33
  #
29
- # <%= render(Ariadne::CommentComponent.new(action: "#")) { "Example" } %>
34
+ # <%= render(Ariadne::CommentComponent.new(url: "/messages", method: :post, sr_label: "Select delivery time")) { "Example" } %>
30
35
  #
31
- # @param action [String] The action to take when the form is submitted.
36
+ # @param url [String] The URL to take action against.
37
+ # @param method [String] The method to use when submitting the form.
38
+ # @param sr_label [String] A label to introduce these tabs for screen readers.
32
39
  # @param classes [String] <%= link_to_classes_docs %>
33
40
  # @param attributes [Hash] <%= link_to_attributes_docs %>
34
- def initialize(action:, classes: "", attributes: {})
41
+ def initialize(url:, method:, sr_label:, classes: "", attributes: {})
35
42
  @tag = DEFAULT_TAG
36
43
  @classes = class_names(
37
44
  DEFAULT_CLASSES,
38
45
  classes
39
46
  )
47
+ @url = url
48
+ @method = method
49
+ @sr_label = sr_label
40
50
 
41
- @tab_idx = 0
42
- @attributes = attributes.merge(action: action)
51
+ @tab_idx = -1
52
+ @attributes = attributes
53
+ @attributes[:"data-controller"] = "comment-component"
54
+ attributes[:"data-comment-component-target"] = "commentComponent"
43
55
  end
44
56
  end
45
57
  end
@@ -18,10 +18,10 @@ module Ariadne
18
18
  include LoggerHelper
19
19
  include Ariadne::ActionViewExtensions::FormHelper
20
20
 
21
- BASE_HTML_CLASSES = "h-full scroll-smooth bg-white antialiased"
22
- BASE_BODY_CLASSES = "flex h-full flex-col"
23
- BASE_WRAPPER_CLASSES = "flex flex-col h-screen justify-between"
24
- BASE_MAIN_CLASSES = "flex-auto"
21
+ BASE_HTML_CLASSES = "ariadne-h-full scroll-smooth ariadne-bg-white ariadne-antialiased"
22
+ BASE_BODY_CLASSES = "ariadne-flex ariadne-h-full ariadne-flex-col"
23
+ BASE_WRAPPER_CLASSES = "ariadne-flex ariadne-flex-col ariadne-h-screen ariadne-justify-between"
24
+ BASE_MAIN_CLASSES = "ariadne-flex-auto"
25
25
 
26
26
  INVALID_ARIA_LABEL_TAGS = [:div, :span, :p].freeze
27
27
 
@@ -3,7 +3,7 @@
3
3
  module Ariadne
4
4
  # The container wraps the majority, if not all, of the content on a page.
5
5
  class ContainerComponent < Ariadne::Component
6
- DEFAULT_CLASSES = "px-4 sm:px-6 lg:px-8"
6
+ DEFAULT_CLASSES = "ariadne-px-4 sm:ariadne-px-6 lg:ariadne-px-8"
7
7
 
8
8
  # @example Default
9
9
  # <%= render(Ariadne::ContainerComponent.new) do |container| %>
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ariadne
4
- # Use `Counter` to add a count to navigational elements and buttons.
4
+ # Use `CounterComponent` to add a count to navigational elements and buttons.
5
5
  #
6
6
  # @accessibility
7
- # Always use `Counter` with adjacent text that provides supplementary information regarding what the count is for. For instance, `Counter`
7
+ # Always use `CounterComponent` with adjacent text that provides supplementary information regarding what the count is for. For instance, `Counter`
8
8
  # should be accompanied with text such as `issues` or `pull requests`.
9
9
  #
10
10
  class CounterComponent < Ariadne::Component
11
- DEFAULT_CLASSES = "inline-flex items-center p-1 border border-transparent rounded-full shadow-sm text-white bg-gray-600 hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500"
12
- #
11
+ DEFAULT_CLASSES = "ariadne-inline-flex ariadne-items-center ariadne-p-1 ariadne-border ariadne-border-transparent ariadne-rounded-full ariadne-shadow-sm focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2"
12
+
13
13
  # @example Default
14
14
  # <%= render(Ariadne::CounterComponent.new(count: 25)) %>
15
15
  #
@@ -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: {}|
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ariadne
4
- # Add a general description of component here
5
- # Add additional usage considerations or best practices that may aid the user to use the component correctly.
6
- # @accessibility Add any accessibility considerations
4
+ # Adds a flex container to the page.
7
5
  class FlexComponent < Ariadne::Component
8
6
  DEFAULT_TAG = :div
9
7
  TAG_OPTIONS = [DEFAULT_TAG].freeze
@@ -26,13 +24,13 @@ module Ariadne
26
24
 
27
25
  flex_class = case @type
28
26
  when :row
29
- "flex-row"
27
+ "ariadne-flex-row"
30
28
  when :column
31
- "flex-col"
29
+ "ariadne-flex-col"
32
30
  when :row_reverse
33
- "flex-row-reverse"
31
+ "ariadne-flex-row-reverse"
34
32
  when :column_reverse
35
- "flex-col-reverse"
33
+ "ariadne-flex-col-reverse"
36
34
  end
37
35
 
38
36
  @classes = class_names(
@@ -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,15 +1,15 @@
1
1
  <%= render Ariadne::BaseComponent.new(tag: :ul, classes: @classes, attributes: @attributes) do |grid| %>
2
2
  <% items.each do |item| %>
3
- <li class="<%= item.classes %> <%= 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
6
  <%= item.entry %>
7
7
  <% end %>
8
8
  <% if item.actions.any? %>
9
9
  <div>
10
- <div class="-mt-px flex divide-x">
10
+ <div class="ariadne--mt-px ariadne-flex ariadne-divide-x">
11
11
  <% item.actions.each_with_index do |action, idx| %>
12
- <div class="<%= idx.zero? ? '' : '-ml-px ' %>w-0 flex-1 flex">
12
+ <div class="<%= idx.zero? ? '' : 'ariadne--ml-px ' %>w-0 ariadne-flex-1 ariadne-flex">
13
13
  <%= action %>
14
14
  </div>
15
15
  <% end %>
@@ -17,7 +17,7 @@
17
17
  </div>
18
18
  <% end %>
19
19
  <% else %>
20
- <div class="flex-1 flex flex-col p-8">
20
+ <div class="ariadne-flex-1 ariadne-flex ariadne-flex-col ariadne-p-8">
21
21
  <%= item.entry %>
22
22
  </div>
23
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 lg:grid-cols-3"
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 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,17 +28,17 @@ 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
- DEFAULT_ITEM_CLASSES = "flex flex-col text-center rounded-lg shadow my-4 text-black-700 border-black"
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"
33
33
 
34
- DEFAULT_ENTRY_CLASSES = "group flex-1 flex flex-col p-8 hover:bg-button-hover-color hover:text-gray-500 rounded-lg"
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
35
  renders_one :entry, lambda { |classes: "", &block|
36
36
  view_context.capture do
37
37
  render(Ariadne::BaseComponent.new(tag: :div, classes: classes)) { block&.call }
38
38
  end
39
39
  }
40
40
 
41
- DEFAULT_ACTION_LINK_CLASSES = "text-button-text-color relative -mr-px w-0 flex-1 inline-flex items-center justify-center py-4 text-sm font-medium border border-transparent rounded-bl-lg rounded-lg"
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
42
  renders_many :actions, lambda { |href:, icon:, label:, size: Ariadne::HeroiconComponent::SIZE_DEFAULT, variant: HeroiconsHelper::Icon::VARIANT_SOLID, classes: "", attributes: {}, text_classes: ""|
43
43
  actual_classes = class_names(DEFAULT_ACTION_LINK_CLASSES, classes)
44
44
  render(Ariadne::LinkComponent.new(href: href, classes: actual_classes, attributes: attributes)) do
@@ -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-5 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",
25
- h3: "text-2xl font-extrabold",
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" } %>