ariadne_view_components 0.0.39 → 0.0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/lib/ariadne/view_components/upstream.rb +0 -1
  4. data/lib/ariadne/view_components/version.rb +1 -1
  5. metadata +2 -90
  6. data/app/assets/config/manifest.js +0 -2
  7. data/app/components/ariadne/ariadne-form.ts +0 -96
  8. data/app/components/ariadne/ariadne.ts +0 -21
  9. data/app/components/ariadne/avatar_component.rb +0 -81
  10. data/app/components/ariadne/avatar_stack_component/avatar_stack_component.html.erb +0 -12
  11. data/app/components/ariadne/avatar_stack_component.rb +0 -75
  12. data/app/components/ariadne/base_button.rb +0 -70
  13. data/app/components/ariadne/base_component.rb +0 -37
  14. data/app/components/ariadne/blankslate_component/blankslate_component.html.erb +0 -26
  15. data/app/components/ariadne/blankslate_component.rb +0 -148
  16. data/app/components/ariadne/body_component.rb +0 -30
  17. data/app/components/ariadne/button_component/button_component.html.erb +0 -4
  18. data/app/components/ariadne/button_component.rb +0 -165
  19. data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts +0 -19
  20. data/app/components/ariadne/clipboard_copy_component/clipboard_copy_component.html.erb +0 -9
  21. data/app/components/ariadne/clipboard_copy_component.rb +0 -90
  22. data/app/components/ariadne/comment_component/comment_component.html.erb +0 -37
  23. data/app/components/ariadne/comment_component.rb +0 -71
  24. data/app/components/ariadne/component.rb +0 -127
  25. data/app/components/ariadne/container_component/container_component.html.erb +0 -3
  26. data/app/components/ariadne/container_component.rb +0 -25
  27. data/app/components/ariadne/content.rb +0 -12
  28. data/app/components/ariadne/counter_component.rb +0 -100
  29. data/app/components/ariadne/details_component/details_component.html.erb +0 -4
  30. data/app/components/ariadne/details_component.rb +0 -81
  31. data/app/components/ariadne/dropdown/menu_component.html.erb +0 -20
  32. data/app/components/ariadne/dropdown/menu_component.rb +0 -101
  33. data/app/components/ariadne/dropdown/menu_component.ts +0 -1
  34. data/app/components/ariadne/dropdown_component/dropdown_component.html.erb +0 -8
  35. data/app/components/ariadne/dropdown_component.rb +0 -172
  36. data/app/components/ariadne/flash_component/flash_component.html.erb +0 -31
  37. data/app/components/ariadne/flash_component.rb +0 -128
  38. data/app/components/ariadne/flex_component/flex_component.html.erb +0 -5
  39. data/app/components/ariadne/flex_component.rb +0 -56
  40. data/app/components/ariadne/footer_component/footer_component.html.erb +0 -7
  41. data/app/components/ariadne/footer_component.rb +0 -23
  42. data/app/components/ariadne/grid_component/grid_component.html.erb +0 -26
  43. data/app/components/ariadne/grid_component.rb +0 -67
  44. data/app/components/ariadne/header_component/header_component.html.erb +0 -29
  45. data/app/components/ariadne/header_component.rb +0 -111
  46. data/app/components/ariadne/heading_component.rb +0 -49
  47. data/app/components/ariadne/heroicon_component/heroicon_component.html.erb +0 -4
  48. data/app/components/ariadne/heroicon_component.rb +0 -166
  49. data/app/components/ariadne/image_component.rb +0 -53
  50. data/app/components/ariadne/inline_flex_component/inline_flex_component.html.erb +0 -6
  51. data/app/components/ariadne/inline_flex_component.rb +0 -72
  52. data/app/components/ariadne/link_component.rb +0 -65
  53. data/app/components/ariadne/list_component/list_component.html.erb +0 -6
  54. data/app/components/ariadne/list_component.rb +0 -70
  55. data/app/components/ariadne/narrow_container_component/narrow_container_component.html.erb +0 -3
  56. data/app/components/ariadne/narrow_container_component.rb +0 -30
  57. data/app/components/ariadne/panel_bar_component/panel_bar_component.html.erb +0 -20
  58. data/app/components/ariadne/panel_bar_component.rb +0 -80
  59. data/app/components/ariadne/pill_component/pill_component.html.erb +0 -3
  60. data/app/components/ariadne/pill_component.rb +0 -44
  61. data/app/components/ariadne/rich_text_area_component/rich-text-area-component.ts +0 -47
  62. data/app/components/ariadne/rich_text_area_component/rich_text_area_component.html.erb +0 -6
  63. data/app/components/ariadne/rich_text_area_component.rb +0 -35
  64. data/app/components/ariadne/slideover_component/slideover-component.ts +0 -17
  65. data/app/components/ariadne/slideover_component/slideover_component.html.erb +0 -9
  66. data/app/components/ariadne/slideover_component.rb +0 -66
  67. data/app/components/ariadne/tab_component/tab_component.html.erb +0 -3
  68. data/app/components/ariadne/tab_component.rb +0 -98
  69. data/app/components/ariadne/tab_container_component/tab-container-component.ts +0 -24
  70. data/app/components/ariadne/tab_container_component.erb +0 -10
  71. data/app/components/ariadne/tab_container_component.rb +0 -68
  72. data/app/components/ariadne/tab_nav_component/tab-nav-component.ts +0 -34
  73. data/app/components/ariadne/tab_nav_component/tab_nav_component.html.erb +0 -7
  74. data/app/components/ariadne/tab_nav_component.rb +0 -72
  75. data/app/components/ariadne/table_nav_component/table_nav_component.html.erb +0 -52
  76. data/app/components/ariadne/table_nav_component.rb +0 -338
  77. data/app/components/ariadne/text.rb +0 -25
  78. data/app/components/ariadne/time_ago_component/time-ago-component.ts +0 -1
  79. data/app/components/ariadne/time_ago_component.rb +0 -56
  80. data/app/components/ariadne/timeline_component/timeline_component.html.erb +0 -19
  81. data/app/components/ariadne/timeline_component.rb +0 -34
  82. data/app/components/ariadne/tooltip_component/tooltip-component.ts +0 -57
  83. data/app/components/ariadne/tooltip_component/tooltip_component.html.erb +0 -4
  84. data/app/components/ariadne/tooltip_component.rb +0 -108
  85. data/app/lib/ariadne/action_view_extensions/form_helper.rb +0 -30
  86. data/app/lib/ariadne/audited/dsl.rb +0 -32
  87. data/app/lib/ariadne/class_name_helper.rb +0 -22
  88. data/app/lib/ariadne/fetch_or_fallback_helper.rb +0 -110
  89. data/app/lib/ariadne/form_builder.rb +0 -74
  90. data/app/lib/ariadne/icon_helper.rb +0 -51
  91. data/app/lib/ariadne/logger_helper.rb +0 -23
  92. data/app/lib/ariadne/status/dsl.rb +0 -41
  93. data/app/lib/ariadne/view_helper.rb +0 -22
@@ -1,6 +0,0 @@
1
- <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do %>
2
- <% if @has_form %>
3
- <input type="hidden" data-tiptap-value-container=true name="<%= @name %>" id="<%= @name %>">
4
- <% end %>
5
- <div class="tiptap-editor" name="rich-text-area" data-rich-text-area-component-target="editor"></div>
6
- <% end %>
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
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
7
- class RichTextAreaComponent < Ariadne::Component
8
- DEFAULT_TAG = :div
9
- DEFAULT_CLASSES = ""
10
-
11
- # @example Default
12
- #
13
- # <%= render(Ariadne::RichTextAreaComponent.new(name: "bodytext", sr_label: "Enter message contents")) { "Example" } %>
14
- #
15
- # @param name [Symbol] Identifies the form/param name for this rich text area.
16
- # @param sr_label [String] A label to introduce these tabs for screen readers.
17
- # @param has_form [Boolean] Indicates whether this component is wrapped in a form.
18
- # @param classes [String] <%= link_to_classes_docs %>
19
- # @param attributes [Hash] <%= link_to_attributes_docs %>
20
- def initialize(name:, sr_label:, has_form: true, classes: "", attributes: {})
21
- @tag = DEFAULT_TAG
22
- @name = name
23
- @sr_label = sr_label
24
- @has_form = has_form
25
-
26
- @classes = merge_class_names(
27
- DEFAULT_CLASSES,
28
- classes,
29
- )
30
- @attributes = attributes
31
- @attributes[:"data-controller"] = "rich-text-area-component"
32
- @attributes[:"data-has-form"] = true if @has_form
33
- end
34
- end
35
- end
@@ -1,17 +0,0 @@
1
- import {Controller} from '@hotwired/stimulus'
2
-
3
- export default class SlideoverComponent extends Controller {
4
- static targets = ['expandable', 'expandWrapper', 'slidePanel', 'buttonWrapper']
5
-
6
- declare readonly expandableTarget: HTMLDivElement
7
- declare readonly expandWrapperTarget: HTMLDivElement
8
- declare readonly slidePanelTargets: [HTMLDivElement]
9
- declare readonly buttonWrapperTarget: HTMLDivElement
10
-
11
- toggle() {
12
- this.expandableTarget.classList.toggle('ariadne-hidden')
13
- for (const slidePanel of this.slidePanelTargets) {
14
- slidePanel.classList.toggle('ariadne-hidden')
15
- }
16
- }
17
- }
@@ -1,9 +0,0 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |slideover| %>
2
- <div data-slideover-component-target="expandable" class="ariadne-hidden ariadne-px-3">
3
- <%= content %>
4
- </div>
5
- <div data-slideover-component-target="buttonWrapper" class="ariadne-relative ariadne-flex ariadne-justify-center">
6
- <%= open_button %>
7
- <%= close_button %>
8
- </div>
9
- <% end %>
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
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
7
- class SlideoverComponent < Ariadne::Component
8
- DEFAULT_TAG = :div
9
- TAG_OPTIONS = [DEFAULT_TAG].freeze
10
-
11
- DIRECTION_Y_DOWN = :yd
12
- DIRECTION_X_LEFT = :xl
13
- VALID_DIRECTIONS = [DIRECTION_Y_DOWN, DIRECTION_X_LEFT].freeze
14
-
15
- DEFAULT_CLASSES = "ariadne-flex ariadne-flex-col"
16
-
17
- DEFAULT_BUTTON_CLASSES = "ariadne-inline-flex ariadne-items-center ariadne-shadow-sm ariadne-px-4 ariadne-py-1.5 ariadne-pb-2 ariadne-text-sm ariadne-leading-5 ariadne-font-medium ariadne-rounded-full " + Ariadne::ButtonComponent::SCHEME_CLASS_MAPPINGS[:default]
18
- renders_one :open_button, lambda { |selected: false, classes: "", attributes: {}|
19
- actual_classes = merge_class_names(DEFAULT_BUTTON_CLASSES, classes, selected ? "" : BASE_HIDDEN_CLASS)
20
-
21
- attributes[:id] ||= "btnOpen"
22
- attributes[:"data-slideover-component-target"] ||= "slidePanel"
23
- attributes[:"data-action"] ||= "click->slideover-component#toggle"
24
- attributes[:type] ||= "submit"
25
-
26
- Ariadne::ButtonComponent.new(classes: actual_classes, attributes: attributes)
27
- }
28
-
29
- renders_one :close_button, lambda { |selected: false, classes: "", attributes: {}|
30
- actual_classes = merge_class_names(DEFAULT_BUTTON_CLASSES, classes, selected ? "" : BASE_HIDDEN_CLASS)
31
-
32
- attributes[:id] ||= "btnClose"
33
- attributes[:"data-slideover-component-target"] ||= "slidePanel"
34
- attributes[:"data-action"] ||= "click->slideover-component#toggle"
35
- attributes[:type] ||= "submit"
36
-
37
- Ariadne::ButtonComponent.new(classes: actual_classes, attributes: attributes)
38
- }
39
-
40
- # @example Default
41
- #
42
- # <%= render(Ariadne::SlideoverComponent.new(direction: Ariadne::SlideoverComponent::DIRECTION_Y_DOWN)) { "Example" } %>
43
- #
44
- # @param tag [Symbol, String] The rendered tag name.
45
- # @param direction [Symbol] <%= one_of(Ariadne::SlideoverComponent::VALID_DIRECTIONS) %>
46
- # @param open_text [String] The text to use to open the slideover.
47
- # @param close_text [String] The text to use to close the slideover.
48
- # @param classes [String] <%= link_to_classes_docs %>
49
- # @param attributes [Hash] <%= link_to_attributes_docs %>
50
- def initialize(tag: DEFAULT_TAG, direction:, open_text: "Open", close_text: "Close", classes: "", attributes: {})
51
- @tag = check_incoming_tag(DEFAULT_TAG, tag)
52
- @classes = merge_class_names(
53
- DEFAULT_CLASSES,
54
- classes,
55
- )
56
-
57
- @direction = fetch_or_raise(VALID_DIRECTIONS, direction)
58
-
59
- @open_text = open_text
60
- @close_text = close_text
61
- @attributes = attributes
62
- @attributes[:"data-controller"] = "slideover-component"
63
- @attributes[:"data-slideover-component-target"] = "expandWrapper"
64
- end
65
- end
66
- end
@@ -1,3 +0,0 @@
1
- <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do %>
2
- <%= text || content %>
3
- <% end %>
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # This component is part of navigation components such as `Ariadne::TabContainerComponent`.
5
- # and `Ariadne::TabNavComponent` and should not be used by itself.
6
- #
7
- # @accessibility
8
- # `TabComponent` renders the selected anchor tab with `aria-current="page"` by default.
9
- # When the selected tab does not correspond to the current page, such as in a nested inner tab, make sure to use aria-current="true"
10
- class TabComponent < Ariadne::Component
11
- DEFAULT_ARIA_CURRENT_FOR_ANCHOR = :page
12
- ARIA_CURRENT_OPTIONS_FOR_ANCHOR = [true, DEFAULT_ARIA_CURRENT_FOR_ANCHOR].freeze
13
-
14
- # Panel controlled by the Tab. This will not render anything in the tab itself.
15
- # It will provide a accessor for the Tab's parent to call and render the panel
16
- # content in the appropriate place.
17
- #
18
- # @param classes [String] <%= link_to_classes_docs %>
19
- # @param attributes [Hash] <%= link_to_attributes_docs %>
20
- renders_one :panel, lambda { |classes: "", attributes: {}|
21
- attributes[:id] = @panel_id
22
- tag = :div
23
- attributes[:role] ||= :tabpanel
24
- attributes[:hidden] = true unless @selected
25
-
26
- label_present = aria("label", attributes) || aria("labelledby", attributes)
27
- unless label_present
28
- if @id.present?
29
- attributes[:"aria-labelledby"] = @id
30
- else
31
- raise ArgumentError, "Panels must be labelled. Either set a unique `id` on the tab, or set an `aria-label` directly on the panel"
32
- end
33
- end
34
-
35
- Ariadne::BaseComponent.new(tag: tag, classes: classes, attributes: attributes)
36
- }
37
-
38
- # The tab's text.
39
- #
40
- # @param kwargs [Hash] The same arguments as <%= link_to_component(Ariadne::Text) %>.
41
- renders_one :text, Ariadne::Text
42
- # TODO: test what hapenns with really long inbox names
43
-
44
- attr_reader :selected, :id, :classes, :attributes
45
-
46
- DEFAULT_CLASSES = "ariadne-border-transparent ariadne-text-gray-500 hover:ariadne-text-gray-700 hover:ariadne-border-gray-300 ariadne-whitespace-nowrap ariadne-py-4 ariadne-px-1 ariadne-border-b-2 ariadne-font-medium ariadne-text-sm"
47
-
48
- # @example Default
49
- #
50
- # <%= render(Ariadne::TabComponent.new(id: "pub-comment")) do |tab| %>
51
- # <% tab.text { "Public comment" } %>
52
- # <% tab.panel { "Public comment panel" } %>
53
- # <% end %>
54
- # @param id [String] The unique ID of the tab.
55
- # @param selected [Boolean] Whether the tab is selected or not.
56
- # @param with_panel [Boolean] Whether the Tab has an associated panel.
57
- # @param href [String] The link to navigate to when the tab is clicked.
58
- # @param classes [String] <%= link_to_classes_docs %>
59
- # @param attributes [Hash] <%= link_to_attributes_docs %>
60
- def initialize(id: nil, selected: false, with_panel: false, href: nil, classes: "", attributes: {})
61
- @id = id
62
-
63
- @href = href
64
- @selected = selected
65
-
66
- @classes = merge_class_names(
67
- DEFAULT_CLASSES,
68
- classes,
69
- )
70
-
71
- @attributes = attributes
72
- @attributes[:id] ||= @id
73
-
74
- if with_panel # TODO: test
75
- if @id.blank?
76
- raise ArgumentError, "Tabs with panels must have a unique `id`"
77
- end
78
-
79
- @tag = :button
80
- @attributes[:type] = :button
81
- @attributes[:role] = :tab
82
- @panel_id = "panel-#{@id}"
83
- @attributes[:"aria-controls"] = @panel_id
84
- else
85
- @tag = :a
86
- end
87
-
88
- return unless @selected
89
-
90
- if @tag == :a
91
- aria_current = aria("current", attributes) || DEFAULT_ARIA_CURRENT_FOR_ANCHOR
92
- @attributes[:"aria-current"] = fetch_or_raise(ARIA_CURRENT_OPTIONS_FOR_ANCHOR, aria_current)
93
- else
94
- @attributes[:"aria-selected"] = true
95
- end
96
- end
97
- end
98
- end
@@ -1,24 +0,0 @@
1
- import '@github/tab-container-element'
2
-
3
- // keep in sync with tab_container_component.rb
4
- const DEFAULT_SELECTED_CLASSES: string[] = ['ariadne-border-slate-500', 'ariadne-text-slate-600']
5
- const DEFAULT_UNSELECTED_CLASSES: string[] = [
6
- 'ariadne-text-gray-500',
7
- 'hover:ariadne-text-gray-700',
8
- 'hover:ariadne-border-gray-300',
9
- ]
10
-
11
- for (const tabContainer of document.getElementsByTagName('tab-container')) {
12
- tabContainer.addEventListener('tab-container-change', function (event: Event) {
13
- const newPanel = (event as CustomEvent).detail.relatedTarget as HTMLElement
14
- const tabContainer = newPanel.closest('tab-container') as HTMLElement
15
- const tabList = tabContainer.firstElementChild as HTMLElement
16
- const currentTab = tabList.querySelector('[aria-selected="true"]') as HTMLElement
17
- const tabId = newPanel.getAttribute('id')?.split('-').slice(1).join('-')
18
- const newTab = tabList.querySelector(`#${tabId}`) as HTMLElement
19
- currentTab.classList.remove(...DEFAULT_SELECTED_CLASSES)
20
- currentTab.classList.add(...DEFAULT_UNSELECTED_CLASSES)
21
- newTab.classList.add(...DEFAULT_SELECTED_CLASSES)
22
- newTab.classList.remove(...DEFAULT_UNSELECTED_CLASSES)
23
- })
24
- }
@@ -1,10 +0,0 @@
1
- <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do |component| %>
2
- <div role="tablist">
3
- <% tabs.each do |tab| %>
4
- <%= tab %>
5
- <% end %>
6
- </div>
7
- <% tabs.each do |tab| %>
8
- <%= tab.panel %>
9
- <% end %>
10
- <% end %>
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # A container for a row of tags. Keyboard support is provided.
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.
7
- class TabContainerComponent < Ariadne::Component
8
- DEFAULT_TAG = :"tab-container"
9
-
10
- DEFAULT_CLASSES = ""
11
-
12
- DEFAULT_SELECTED_CLASSES = "ariadne-border-slate-500 ariadne-text-slate-600"
13
- DEFAULT_UNSELECTED_CLASSES = "ariadne-text-gray-500 hover:ariadne-text-gray-700 hover:ariadne-border-gray-300"
14
-
15
- # Tabs and panels to be rendered.
16
- #
17
- # @param id [String] The unique ID of the tab.
18
- # @param selected [Boolean] Whether the tab is selected.
19
- # @param classes [String] <%= link_to_classes_docs %>
20
- # @param attributes [Hash] <%= link_to_attributes_docs %>
21
- renders_many :tabs, lambda { |id: "", selected: false, classes: "", attributes: {}|
22
- actual_classes = merge_class_names(selected ? DEFAULT_SELECTED_CLASSES : DEFAULT_UNSELECTED_CLASSES, classes)
23
-
24
- Ariadne::TabComponent.new(
25
- id: id,
26
- selected: selected,
27
- with_panel: true,
28
-
29
- classes: actual_classes,
30
- attributes: attributes,
31
- )
32
- }
33
-
34
- # @example Default
35
- #
36
- # <%= render(Ariadne::TabContainerComponent.new(sr_label: "Comments")) do |tab_container| %>
37
- # <%= render(Ariadne::TabComponent.new(id: "pub-comment")) do |tab| %>
38
- # <% tab.with_text { "Tab 1" } %>
39
- # <% tab.with_panel { "Panel 1" } %>
40
- # <% end %>
41
- # <%= render(Ariadne::TabComponent.new(id: "pub-comment")) do |tab| %>
42
- # <% tab.with_text { "Tab 2" } %>
43
- # <% tab.with_panel { "Panel 2" } %>
44
- # <% end %>
45
- # <% end %>
46
- #
47
- # %>
48
- #
49
- # @param sr_label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the tabs.
50
- # @param classes [String] <%= link_to_classes_docs %>
51
- # @param attributes [Hash] <%= link_to_attributes_docs %>
52
- def initialize(sr_label:, classes: "", attributes: {})
53
- @tag = DEFAULT_TAG
54
- @classes = merge_class_names(
55
- DEFAULT_CLASSES,
56
- classes,
57
- )
58
-
59
- @attributes = attributes
60
- @attributes[:"aria-label"] = sr_label
61
- @attributes[:role] = :presentation
62
- end
63
-
64
- def render?
65
- tabs?
66
- end
67
- end
68
- end
@@ -1,34 +0,0 @@
1
- import {Controller} from '@hotwired/stimulus'
2
-
3
- export default class TabNavComponent extends Controller {
4
- static targets = ['tab']
5
-
6
- declare readonly tabTargets: [HTMLAnchorElement]
7
-
8
- // keep in synch with tab_nav_component
9
- SELECTED_CLASSES = ['ariadne-border-slate-500', 'ariadne-text-slate-600']
10
- UNSELECTED_CLASSES = ['ariadne-text-gray-500', 'hover:ariadne-text-gray-700', 'hover:ariadne-border-gray-300']
11
-
12
- connect() {
13
- for (const tab of this.tabTargets) {
14
- if (tab.hasAttribute('aria-current')) {
15
- tab.classList.add(...this.SELECTED_CLASSES)
16
- tab.classList.remove(...this.UNSELECTED_CLASSES)
17
- }
18
- }
19
- }
20
-
21
- toggle(event: Event) {
22
- for (const tab of this.tabTargets) {
23
- if (tab === event.target) {
24
- tab.setAttribute('aria-current', 'page')
25
- tab.classList.add(...this.SELECTED_CLASSES)
26
- tab.classList.remove(...this.UNSELECTED_CLASSES)
27
- } else if (tab.hasAttribute('aria-current')) {
28
- tab.removeAttribute('aria-current')
29
- tab.classList.add(...this.UNSELECTED_CLASSES)
30
- tab.classList.remove(...this.SELECTED_CLASSES)
31
- }
32
- }
33
- }
34
- }
@@ -1,7 +0,0 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |component| %>
2
- <ul class="ariadne-list-none">
3
- <% tabs.each do |tab| %>
4
- <li class="ariadne-inline-flex"><%= tab %></li>
5
- <% end %>
6
- </ul>
7
- <% end %>
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Use `TabNavComponent` to style navigation links, typically placed at the top
5
- # of the page.
6
- #
7
- # For panel navigation, use <%= link_to_component(Ariadne::TabContainerComponent) %> instead.
8
- #
9
- # @accessibility
10
- # - By default, `TabNavComponent` renders links within a `<nav>` element. `<nav>` has an
11
- # implicit landmark role of `navigation` which should be reserved for main links.
12
- # For all other set of links, set tag to `:div`.
13
- # - See <%= link_to_component(Ariadne::TabComponent) %> for additional
14
- # accessibility considerations.
15
- class TabNavComponent < Ariadne::Component
16
- DEFAULT_TAG = :nav
17
- TAG_OPTIONS = [DEFAULT_TAG, :div].freeze
18
-
19
- BODY_TAG_DEFAULT = :ul
20
-
21
- # keep this consistent with tab-container-component.ts
22
- SELECTED_CLASSES = "ariadne-border-slate-600 ariadne-text-slate-700"
23
- UNSELECTED_CLASSES = "ariadne-text-slate-500 hover:ariadne-text-slate-700 hover:ariadne-border-slate-700"
24
-
25
- DEFAULT_CLASSES = ""
26
-
27
- # Tabs to be rendered. Use the tabs to list page links.
28
- #
29
- # @param selected [Boolean] Whether the tab is selected.
30
- # @param classes [String] <%= link_to_classes_docs %>
31
- # @param attributes [Hash] <%= link_to_attributes_docs %>
32
- renders_many :tabs, lambda { |selected: false, href: nil, classes: "", attributes: {}|
33
- attributes[:href] = href
34
- attributes[:"data-tab-nav-component-target"] = "tab"
35
- attributes[:"data-action"] = "click->tab-nav-component#toggle"
36
-
37
- actual_classes = merge_class_names(selected ? SELECTED_CLASSES : UNSELECTED_CLASSES, classes)
38
- Ariadne::TabComponent.new(
39
- selected: selected,
40
-
41
- classes: actual_classes,
42
- attributes: attributes,
43
- )
44
- }
45
-
46
- # @example Default with `<nav>`
47
- # @description
48
- # `<nav>` is a landmark and should be reserved for main navigation links. See <%= link_to_accessibility %>.
49
- # @code
50
- # <%= render(Ariadne::TabNavComponent.new(label: "Nav")) do |c| %>
51
- # <% c.with_tab(selected: true, href: "#") { "Tab 1" } %>
52
- # <% c.with_tab(href: "#") { "Tab 2" } %>
53
- # <% c.with_tab(href: "#") { "Tab 3" } %>
54
- # <% end %>
55
- #
56
- # @param label [String] Sets an `aria-label` that helps assistive technology users understand the purpose of the links, and distinguish it from similar elements.
57
- # @param tag [Symbol, String] The rendered tag name.
58
- # @param classes [String] <%= link_to_classes_docs %>
59
- # @param attributes [Hash] <%= link_to_attributes_docs %>
60
- def initialize(label:, tag: DEFAULT_TAG, classes: "", attributes: {})
61
- @tag = check_incoming_tag(DEFAULT_TAG, tag)
62
- @classes = merge_class_names(
63
- DEFAULT_CLASSES,
64
- classes,
65
- )
66
-
67
- @attributes = attributes
68
- @attributes[:"aria-label"] = label
69
- @attributes[:"data-controller"] = "tab-nav-component"
70
- end
71
- end
72
- end
@@ -1,52 +0,0 @@
1
- <div class="ariadne-inline-block ariadne-min-w-full ariadne-align-middle md:ariadne-px-6 lg:ariadne-px-8">
2
- <div class="ariadne-overflow-hidden ariadne-shadow ariadne-ring-1 ariadne-ring-black ariadne-ring-opacity-5 md:ariadne-rounded-lg">
3
- <%= render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) do |table| %>
4
- <% if has_header_row? %>
5
- <thead>
6
- <%= render(Ariadne::BaseComponent.new(tag: :tr, classes: header_row.classes, attributes: header_row.attributes)) do %>
7
- <%= header_row.selection_cell %>
8
- <%= header_row.main_cell %>
9
- <% header_row.action_cells.each_with_index do |action_cell, idx| %>
10
- <% if idx.zero? %>
11
- <%= action_cell %>
12
- <% elsif idx == header_row.action_cells.size - 1 %>
13
- <%= action_cell %>
14
- <% else %>
15
- <%= action_cell %>
16
- <% end %>
17
- <% end %>
18
- <% end %>
19
- </thead>
20
- <% end %>
21
- <tbody>
22
- <% rows.each do |row| %>
23
- <%= render(Ariadne::BaseComponent.new(tag: :tr, classes: row.classes, attributes: row.attributes)) do %>
24
- <%= row.selection_cell %>
25
- <%= row.main_cell %>
26
- <% row.metadata_cells.each_with_index do |metadata_cell, idx| %>
27
- <% if idx.zero? %>
28
- <%= metadata_cell %>
29
- <% elsif idx == row.metadata_cells.size - 1 %>
30
- <%= metadata_cell %>
31
- <% else %>
32
- <%= metadata_cell %>
33
- <% end %>
34
- <% end %>
35
- <% end %>
36
- <% end %>
37
- </tbody>
38
- <% end %>
39
- </div>
40
- <% if has_footer? %>
41
- <%= render(Ariadne::BaseComponent.new(tag: :div, classes: footer.classes, attributes: footer.attributes)) do %>
42
- <%= footer.records_info %>
43
- <%= render(Ariadne::BaseComponent.new(tag: :nav, classes: footer.pagination_bar.classes, attributes: footer.pagination_bar.attributes)) do %>
44
- <%= footer.pagination_bar.prev_page %>
45
- <% footer.pagination_bar.items.each do |item| %>
46
- <%= item %>
47
- <% end %>
48
- <%= footer.pagination_bar.next_page %>
49
- <% end %>
50
- <% end %>
51
- <% end %>
52
- </div>