sdr_view_components 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sdr_view_components/version.rb +1 -1
  3. data/spec/components/previews/sdr_view_components/elements/alert_component_preview.rb +71 -0
  4. data/spec/components/previews/sdr_view_components/elements/banner_component_preview.rb +58 -0
  5. data/spec/components/previews/sdr_view_components/elements/breadcrumb_nav_component_preview.rb +52 -0
  6. data/spec/components/previews/sdr_view_components/elements/button_component_preview.rb +71 -0
  7. data/spec/components/previews/sdr_view_components/elements/button_form_component_preview.rb +97 -0
  8. data/spec/components/previews/sdr_view_components/elements/button_link_component_preview.rb +81 -0
  9. data/spec/components/previews/sdr_view_components/elements/card_component_preview.rb +41 -0
  10. data/spec/components/previews/sdr_view_components/elements/heading_component_preview.rb +51 -0
  11. data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview/default.html.erb +5 -0
  12. data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview.rb +9 -0
  13. data/spec/components/previews/sdr_view_components/elements/icon_button_component_preview.rb +17 -0
  14. data/spec/components/previews/sdr_view_components/elements/icon_button_link_component_preview.rb +15 -0
  15. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/default.html.erb +9 -0
  16. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/with_header_and_footer.html.erb +19 -0
  17. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/without_size.html.erb +9 -0
  18. data/spec/components/previews/sdr_view_components/elements/modal_component_preview.rb +15 -0
  19. data/spec/components/previews/sdr_view_components/elements/progress_bar_component_preview.rb +97 -0
  20. data/spec/components/previews/sdr_view_components/elements/spinner_component_preview.rb +83 -0
  21. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/default_variant.html.erb +12 -0
  22. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/underline_variant.html.erb +12 -0
  23. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/with_header.html.erb +16 -0
  24. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview.rb +16 -0
  25. data/spec/components/previews/sdr_view_components/elements/toast_component_preview.rb +29 -0
  26. data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview/default.html.erb +13 -0
  27. data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview.rb +9 -0
  28. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/checked.html.erb +7 -0
  29. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/default.html.erb +6 -0
  30. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/disabled.html.erb +7 -0
  31. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview.rb +17 -0
  32. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/default.html.erb +6 -0
  33. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_accept.html.erb +7 -0
  34. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_multiple.html.erb +7 -0
  35. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_required.html.erb +7 -0
  36. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview.rb +25 -0
  37. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/checked.html.erb +8 -0
  38. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/default.html.erb +7 -0
  39. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/disabled.html.erb +8 -0
  40. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview.rb +17 -0
  41. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/default.html.erb +6 -0
  42. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_placeholder.html.erb +7 -0
  43. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_required.html.erb +7 -0
  44. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_rows.html.erb +7 -0
  45. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview.rb +19 -0
  46. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/default.html.erb +6 -0
  47. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/disabled.html.erb +8 -0
  48. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/required.html.erb +7 -0
  49. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/with_placeholder.html.erb +7 -0
  50. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview.rb +19 -0
  51. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/checked.html.erb +9 -0
  52. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/default.html.erb +8 -0
  53. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/disabled.html.erb +9 -0
  54. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_additional_container_content.html.erb +12 -0
  55. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_help_text.html.erb +10 -0
  56. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_label.html.erb +9 -0
  57. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_validation_error.html.erb +9 -0
  58. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview.rb +33 -0
  59. data/spec/components/previews/sdr_view_components/forms/file_component_preview/default.html.erb +8 -0
  60. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_additional_container_content.html.erb +14 -0
  61. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text.html.erb +9 -0
  62. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text_below.html.erb +10 -0
  63. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_label.html.erb +9 -0
  64. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_multiple.html.erb +9 -0
  65. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_validation_error.html.erb +9 -0
  66. data/spec/components/previews/sdr_view_components/forms/file_component_preview.rb +32 -0
  67. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_block_content.html.erb +3 -0
  68. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_text.html.erb +4 -0
  69. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview.rb +13 -0
  70. data/spec/components/previews/sdr_view_components/forms/label_component_preview/default.html.erb +7 -0
  71. data/spec/components/previews/sdr_view_components/forms/label_component_preview/hidden_label.html.erb +8 -0
  72. data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_caption.html.erb +8 -0
  73. data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_tooltip.html.erb +17 -0
  74. data/spec/components/previews/sdr_view_components/forms/label_component_preview.rb +17 -0
  75. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/default.html.erb +9 -0
  76. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_additional_container_content.html.erb +14 -0
  77. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text.html.erb +10 -0
  78. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text_below.html.erb +11 -0
  79. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_label.html.erb +10 -0
  80. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_validation_error.html.erb +11 -0
  81. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview.rb +30 -0
  82. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/danger.html.erb +6 -0
  83. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/default.html.erb +5 -0
  84. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/info.html.erb +6 -0
  85. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/primary.html.erb +6 -0
  86. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/secondary.html.erb +6 -0
  87. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/success.html.erb +6 -0
  88. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/warning.html.erb +6 -0
  89. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_block_content_and_value.html.erb +7 -0
  90. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_form_id.html.erb +8 -0
  91. data/spec/components/previews/sdr_view_components/forms/submit_component_preview.rb +29 -0
  92. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/default.html.erb +8 -0
  93. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_additional_container_content.html.erb +12 -0
  94. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text.html.erb +9 -0
  95. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text_below.html.erb +10 -0
  96. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_hidden_label.html.erb +9 -0
  97. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_mark_required.html.erb +9 -0
  98. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_validation_error.html.erb +9 -0
  99. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview.rb +32 -0
  100. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/default.html.erb +8 -0
  101. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/disabled.html.erb +9 -0
  102. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/label_hidden.html.erb +9 -0
  103. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/marked_required.html.erb +9 -0
  104. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/required.html.erb +9 -0
  105. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_additional_container_content.html.erb +12 -0
  106. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text.html.erb +9 -0
  107. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text_below.html.erb +10 -0
  108. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_placeholder.html.erb +9 -0
  109. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_validation_error.html.erb +9 -0
  110. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview.rb +40 -0
  111. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/default.html.erb +11 -0
  112. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/with_validation_error.html.erb +12 -0
  113. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview.rb +20 -0
  114. data/spec/components/previews/sdr_view_components/structure/footer_component_preview.rb +11 -0
  115. data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant.html.erb +15 -0
  116. data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant_with_background_color.html.erb +15 -0
  117. data/spec/components/previews/sdr_view_components/structure/header_component_preview/light_variant.html.erb +15 -0
  118. data/spec/components/previews/sdr_view_components/structure/header_component_preview/no_rosette.html.erb +15 -0
  119. data/spec/components/previews/sdr_view_components/structure/header_component_preview/white_variant.html.erb +15 -0
  120. data/spec/components/previews/sdr_view_components/structure/header_component_preview.rb +16 -0
  121. data/spec/components/previews/sdr_view_components/tables/cell_component_preview/default.html.erb +9 -0
  122. data/spec/components/previews/sdr_view_components/tables/cell_component_preview/with_colspan.html.erb +17 -0
  123. data/spec/components/previews/sdr_view_components/tables/cell_component_preview.rb +11 -0
  124. data/spec/components/previews/sdr_view_components/tables/header_component_preview/default.html.erb +7 -0
  125. data/spec/components/previews/sdr_view_components/tables/header_component_preview/with_tooltip.html.erb +19 -0
  126. data/spec/components/previews/sdr_view_components/tables/header_component_preview.rb +11 -0
  127. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_item_values.html.erb +7 -0
  128. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_items.html.erb +11 -0
  129. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview.rb +27 -0
  130. data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview/default.html.erb +26 -0
  131. data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview.rb +9 -0
  132. data/spec/components/previews/sdr_view_components/tables/row_component_preview/label_only.html.erb +5 -0
  133. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_cells.html.erb +13 -0
  134. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_first_value_and_values.html.erb +8 -0
  135. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_label_content.html.erb +11 -0
  136. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_tooltip.html.erb +18 -0
  137. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_value.html.erb +8 -0
  138. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_values.html.erb +8 -0
  139. data/spec/components/previews/sdr_view_components/tables/row_component_preview.rb +21 -0
  140. data/spec/components/previews/sdr_view_components/tables/table_component_preview.rb +81 -0
  141. metadata +139 -1
@@ -0,0 +1,10 @@
1
+ <% model = SdrViewComponents::Forms::TextFieldComponentPreview::TextFieldPreviewModel.new(title: 'Project overview') %>
2
+
3
+ <%= form_with(model: model, url: '/example') do |form| %>
4
+ <%= render SdrViewComponents::Forms::TextFieldComponent.new(
5
+ form: form,
6
+ field_name: :title,
7
+ variant: :help_text_below,
8
+ help_text: 'Help text appears below the field when using the help_text_below variant.'
9
+ ) %>
10
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% model = SdrViewComponents::Forms::TextFieldComponentPreview::TextFieldPreviewModel.new(title: nil) %>
2
+
3
+ <%= form_with(model: model, url: '/example') do |form| %>
4
+ <%= render SdrViewComponents::Forms::TextFieldComponent.new(
5
+ form: form,
6
+ field_name: :title,
7
+ input_placeholder: 'Enter a descriptive title'
8
+ ) %>
9
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% model = SdrViewComponents::Forms::TextFieldComponentPreview::TextFieldPreviewModel.new(title: nil) %>
2
+ <% model.valid? %>
3
+
4
+ <%= form_with(model: model, url: '/example') do |form| %>
5
+ <%= render SdrViewComponents::Forms::TextFieldComponent.new(
6
+ form: form,
7
+ field_name: :title
8
+ ) %>
9
+ <% end %>
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Forms
5
+ class TextFieldComponentPreview < ViewComponent::Preview
6
+ def default; end
7
+
8
+ def label_hidden; end
9
+
10
+ # @!group Help text
11
+ def with_help_text; end
12
+
13
+ def with_help_text_below; end
14
+ # @!endgroup
15
+
16
+ # @!group Input Options
17
+ def with_placeholder; end
18
+
19
+ def disabled; end
20
+
21
+ def required; end
22
+
23
+ def marked_required; end
24
+ # @!endgroup
25
+
26
+ def with_additional_container_content; end
27
+
28
+ def with_validation_error; end
29
+
30
+ class TextFieldPreviewModel
31
+ include ActiveModel::Model
32
+ include ActiveModel::Attributes
33
+
34
+ attribute :title, :string, default: nil
35
+
36
+ validates :title, presence: true
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ <% model = SdrViewComponents::Forms::ToggleComponentPreview::TogglePreviewModel.new(audience: 'collections') %>
2
+
3
+ <%= form_with(model: model, url: '/example') do |form| %>
4
+ <%= render SdrViewComponents::Forms::ToggleComponent.new(
5
+ form: form,
6
+ field_name: :audience
7
+ ) do |component| %>
8
+ <% component.with_left_toggle_option(form:, field_name: :audience, label: 'Collections', value: 'collections') %>
9
+ <% component.with_right_toggle_option(form:, field_name: :audience, label: 'Items', value: 'items') %>
10
+ <% end %>
11
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% model = SdrViewComponents::Forms::ToggleComponentPreview::TogglePreviewModel.new(audience: nil) %>
2
+ <% model.valid? %>
3
+
4
+ <%= form_with(model: model, url: '/example') do |form| %>
5
+ <%= render SdrViewComponents::Forms::ToggleComponent.new(
6
+ form: form,
7
+ field_name: :audience
8
+ ) do |component| %>
9
+ <% component.with_left_toggle_option(form:, field_name: :audience, label: 'Collections', value: 'collections') %>
10
+ <% component.with_right_toggle_option(form:, field_name: :audience, label: 'Items', value: 'items') %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Forms
5
+ class ToggleComponentPreview < ViewComponent::Preview
6
+ def default; end
7
+
8
+ def with_validation_error; end
9
+
10
+ class TogglePreviewModel
11
+ include ActiveModel::Model
12
+ include ActiveModel::Attributes
13
+
14
+ attribute :audience, :string, default: 'collections'
15
+
16
+ validates :audience, presence: true
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Structure
5
+ class FooterComponentPreview < ViewComponent::Preview
6
+ def default
7
+ render SdrViewComponents::Structure::FooterComponent.new
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ <%= render SdrViewComponents::Structure::HeaderComponent.new(title: 'Test Header', subtitle: 'Test Subtitle', variant: :dark) do |header| %>
2
+ <% header.with_primary_navigation_link do %>
3
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Home', path: '#') %>
4
+ <% end %>
5
+ <% header.with_primary_navigation_link do %>
6
+ <%= render SdrViewComponents::Elements::Navigation::DropdownMenuComponent.new(text: 'Logged in: amcollie-preview-dropdown') do |dropdown| %>
7
+ <% dropdown.with_item do %>
8
+ <%= link_to 'Logout', '/Shibboleth.sso/Logout', class: 'dropdown-item' %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% header.with_secondary_navigation_link do %>
13
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Option', path: '/item1') %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render SdrViewComponents::Structure::HeaderComponent.new(title: 'Test Header', subtitle: 'Test Subtitle', variant: :dark, background_color: '1, 104, 149') do |header| %>
2
+ <% header.with_primary_navigation_link do %>
3
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Home', path: '#') %>
4
+ <% end %>
5
+ <% header.with_primary_navigation_link do %>
6
+ <%= render SdrViewComponents::Elements::Navigation::DropdownMenuComponent.new(text: 'Logged in: amcollie-preview-dropdown') do |dropdown| %>
7
+ <% dropdown.with_item do %>
8
+ <%= link_to 'Logout', '/Shibboleth.sso/Logout', class: 'dropdown-item' %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% header.with_secondary_navigation_link do %>
13
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Option', path: '/item1') %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render SdrViewComponents::Structure::HeaderComponent.new(title: 'Test Header', subtitle: 'Test Subtitle') do |header| %>
2
+ <% header.with_primary_navigation_link do %>
3
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Home', path: '#') %>
4
+ <% end %>
5
+ <% header.with_primary_navigation_link do %>
6
+ <%= render SdrViewComponents::Elements::Navigation::DropdownMenuComponent.new(text: 'Logged in: amcollie-preview-dropdown') do |dropdown| %>
7
+ <% dropdown.with_item do %>
8
+ <%= link_to 'Logout', '/Shibboleth.sso/Logout', class: 'dropdown-item' %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% header.with_secondary_navigation_link do %>
13
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Option', path: '/item1') %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render SdrViewComponents::Structure::HeaderComponent.new(title: 'Test Header', subtitle: 'Test Subtitle', rosette: false) do |header| %>
2
+ <% header.with_primary_navigation_link do %>
3
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Home', path: '#') %>
4
+ <% end %>
5
+ <% header.with_primary_navigation_link do %>
6
+ <%= render SdrViewComponents::Elements::Navigation::DropdownMenuComponent.new(text: 'Logged in: amcollie-preview-dropdown') do |dropdown| %>
7
+ <% dropdown.with_item do %>
8
+ <%= link_to 'Logout', '/Shibboleth.sso/Logout', class: 'dropdown-item' %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% header.with_secondary_navigation_link do %>
13
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Option', path: '/item1') %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <%= render SdrViewComponents::Structure::HeaderComponent.new(title: 'Test Header', subtitle: 'Test Subtitle', variant: :white) do |header| %>
2
+ <% header.with_primary_navigation_link do %>
3
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Home', path: '#') %>
4
+ <% end %>
5
+ <% header.with_primary_navigation_link do %>
6
+ <%= render SdrViewComponents::Elements::Navigation::DropdownMenuComponent.new(text: 'Logged in: amcollie-preview-dropdown') do |dropdown| %>
7
+ <% dropdown.with_item do %>
8
+ <%= link_to 'Logout', '/Shibboleth.sso/Logout', class: 'dropdown-item' %>
9
+ <% end %>
10
+ <% end %>
11
+ <% end %>
12
+ <% header.with_secondary_navigation_link do %>
13
+ <%= render SdrViewComponents::Elements::Navigation::NavItemComponent.new(text: 'Option', path: '/item1') %>
14
+ <% end %>
15
+ <% end %>
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Structure
5
+ class HeaderComponentPreview < ViewComponent::Preview
6
+ def light_variant; end
7
+
8
+ def white_variant; end
9
+
10
+ def dark_variant; end
11
+ def dark_variant_with_background_color; end
12
+
13
+ def no_rosette; end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <tr>
4
+ <%= render SdrViewComponents::Tables::CellComponent.new do %>
5
+ Status
6
+ <% end %>
7
+ </tr>
8
+ </tbody>
9
+ </table>
@@ -0,0 +1,17 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <tr>
4
+ <%= render SdrViewComponents::Tables::CellComponent.new(colspan: 2) do %>
5
+ Quarterly total
6
+ <% end %>
7
+ </tr>
8
+ <tr>
9
+ <%= render SdrViewComponents::Tables::CellComponent.new do %>
10
+ Revenue
11
+ <% end %>
12
+ <%= render SdrViewComponents::Tables::CellComponent.new do %>
13
+ $125,000
14
+ <% end %>
15
+ </tr>
16
+ </tbody>
17
+ </table>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Tables
5
+ class CellComponentPreview < ViewComponent::Preview
6
+ def default; end
7
+
8
+ def with_colspan; end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ <table class="table">
2
+ <thead>
3
+ <tr>
4
+ <%= render SdrViewComponents::Tables::HeaderComponent.new(label: 'Repository') %>
5
+ </tr>
6
+ </thead>
7
+ </table>
@@ -0,0 +1,19 @@
1
+ <table class="table">
2
+ <thead>
3
+ <tr>
4
+ <%= render SdrViewComponents::Tables::HeaderComponent.new(
5
+ label: 'Access',
6
+ tooltip: 'Explains who can view or manage this item.'
7
+ ) %>
8
+ </tr>
9
+ </thead>
10
+ </table>
11
+
12
+ <script>
13
+ window.addEventListener('load', () => {
14
+ const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
15
+ ;[...tooltipTriggerList].forEach((tooltipTriggerEl) => {
16
+ window.bootstrap.Tooltip.getOrCreateInstance(tooltipTriggerEl)
17
+ })
18
+ })
19
+ </script>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Tables
5
+ class HeaderComponentPreview < ViewComponent::Preview
6
+ def default; end
7
+
8
+ def with_tooltip; end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <tr>
4
+ <%= render SdrViewComponents::Tables::ListCellComponent.new(item_values: item_values) %>
5
+ </tr>
6
+ </tbody>
7
+ </table>
@@ -0,0 +1,11 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <tr>
4
+ <%= render SdrViewComponents::Tables::ListCellComponent.new do |component| %>
5
+ <% items.each do |item| %>
6
+ <% component.with_item { item } %>
7
+ <% end %>
8
+ <% end %>
9
+ </tr>
10
+ </tbody>
11
+ </table>
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Tables
5
+ class ListCellComponentPreview < ViewComponent::Preview
6
+ # @!group Item sources
7
+
8
+ def with_item_values
9
+ render_with_template(locals: {
10
+ item_values: ['Published', 'Preserved', 'Available in SearchWorks']
11
+ })
12
+ end
13
+
14
+ def with_items
15
+ render_with_template(locals: {
16
+ items: [
17
+ 'Created by Digital Production Group',
18
+ 'Reviewed by Metadata Services',
19
+ 'Updated last week'
20
+ ]
21
+ })
22
+ end
23
+
24
+ # @!endgroup
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ <%= render(SdrViewComponents::Tables::RawTableComponent.new(label: 'Custom Row Content')) do |component| %>
2
+ <% component.with_header(label: 'Item') %>
3
+ <% component.with_header(label: 'Status') %>
4
+ <% component.with_header(label: 'Description') %>
5
+ <% component.with_row do %>
6
+ <tr>
7
+ <td>Item 1</td>
8
+ <td><strong>Complete</strong></td>
9
+ <td>Custom HTML rendering</td>
10
+ </tr>
11
+ <% end %>
12
+ <% component.with_row do %>
13
+ <tr>
14
+ <td>Item 2</td>
15
+ <td><em>In Progress</em></td>
16
+ <td><code>RawTableComponent</code> demo</td>
17
+ </tr>
18
+ <% end %>
19
+ <% component.with_row do %>
20
+ <tr>
21
+ <td>Item 3</td>
22
+ <td><u>Pending</u></td>
23
+ <td>Arbitrary HTML content</td>
24
+ </tr>
25
+ <% end %>
26
+ <% end %>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Tables
5
+ class RawTableComponentPreview < ViewComponent::Preview
6
+ def default; end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <%= render SdrViewComponents::Tables::RowComponent.new(label: 'Deposit status') %>
4
+ </tbody>
5
+ </table>
@@ -0,0 +1,13 @@
1
+ <% row = SdrViewComponents::Tables::RowComponent.new(label: 'Content files') %>
2
+ <% row.with_cell do %>
3
+ image-0001.tif
4
+ <% end %>
5
+ <% row.with_cell do %>
6
+ image-0002.tif
7
+ <% end %>
8
+
9
+ <table class="table">
10
+ <tbody>
11
+ <%= render row %>
12
+ </tbody>
13
+ </table>
@@ -0,0 +1,8 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <%= render SdrViewComponents::Tables::RowComponent.new(
4
+ first_value: 'File set',
5
+ values: ['Preserved', 'Published']
6
+ ) %>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,11 @@
1
+ <% row = SdrViewComponents::Tables::RowComponent.new(value: 'Submitted') %>
2
+ <% row.with_label_content do %>
3
+ <strong>Deposit status</strong><br>
4
+ <small>Current workflow step</small>
5
+ <% end %>
6
+
7
+ <table class="table">
8
+ <tbody>
9
+ <%= render row %>
10
+ </tbody>
11
+ </table>
@@ -0,0 +1,18 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <%= render SdrViewComponents::Tables::RowComponent.new(
4
+ label: 'Embargo',
5
+ value: 'Ends 2027-01-15',
6
+ tooltip: 'Date when the item becomes visible to the public.'
7
+ ) %>
8
+ </tbody>
9
+ </table>
10
+
11
+ <script>
12
+ window.addEventListener('load', () => {
13
+ const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
14
+ ;[...tooltipTriggerList].forEach((tooltipTriggerEl) => {
15
+ window.bootstrap.Tooltip.getOrCreateInstance(tooltipTriggerEl)
16
+ })
17
+ })
18
+ </script>
@@ -0,0 +1,8 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <%= render SdrViewComponents::Tables::RowComponent.new(
4
+ label: 'Collection',
5
+ value: 'Manuscript Division'
6
+ ) %>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,8 @@
1
+ <table class="table">
2
+ <tbody>
3
+ <%= render SdrViewComponents::Tables::RowComponent.new(
4
+ label: 'Access',
5
+ values: ['Stanford users', 'World']
6
+ ) %>
7
+ </tbody>
8
+ </table>
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Tables
5
+ class RowComponentPreview < ViewComponent::Preview
6
+ # @!group Values
7
+ def with_values; end
8
+ def with_value; end
9
+ def with_cells; end
10
+ def with_first_value_and_values; end
11
+ # @!endgroup
12
+
13
+ # @!group Labels
14
+ def label_only; end
15
+ def with_label_content; end
16
+ # @!endgroup
17
+
18
+ def with_tooltip; end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Tables
5
+ class TableComponentPreview < ViewComponent::Preview
6
+ # @!group Variants
7
+
8
+ def h3_variant
9
+ render(SdrViewComponents::Tables::TableComponent.new(label: 'Sample Data')) do |component|
10
+ component.with_row(label: 'Item 1', values: ['Value A', 'Value B', 'Value C'])
11
+ component.with_row(label: 'Item 2', values: ['Value D', 'Value E', 'Value F'])
12
+ component.with_row(label: 'Item 3', values: ['Value G', 'Value H', 'Value I'])
13
+ end
14
+ end
15
+
16
+ def data_variant
17
+ render(SdrViewComponents::Tables::TableComponent.new(label: 'Data Records', variant: :data)) do |component|
18
+ component.with_row(label: 'Record 1', values: %w[Alpha Beta Gamma])
19
+ component.with_row(label: 'Record 2', values: %w[Delta Epsilon Zeta])
20
+ component.with_row(label: 'Record 3', values: %w[Eta Theta Iota])
21
+ end
22
+ end
23
+
24
+ # @!endgroup
25
+
26
+ # @!group Headers and Caption
27
+
28
+ def with_headers
29
+ render(SdrViewComponents::Tables::TableComponent.new(label: 'Headers Example')) do |component|
30
+ component.with_header(label: 'Column 1')
31
+ component.with_header(label: 'Column 2')
32
+ component.with_header(label: 'Column 3')
33
+ component.with_row(label: 'Row 1', values: ['Data 1', 'Data 2', 'Data 3'])
34
+ component.with_row(label: 'Row 2', values: ['Data 4', 'Data 5', 'Data 6'])
35
+ end
36
+ end
37
+
38
+ def with_caption
39
+ render(SdrViewComponents::Tables::TableComponent.new) do |component|
40
+ component.with_caption { 'Table Caption: Financial Summary' }
41
+ component.with_header(label: 'Month')
42
+ component.with_header(label: 'Revenue')
43
+ component.with_header(label: 'Expenses')
44
+ component.with_row(label: 'January', values: ['$50,000', '$35,000'])
45
+ component.with_row(label: 'February', values: ['$55,000', '$38,000'])
46
+ end
47
+ end
48
+
49
+ def show_label_false
50
+ render(SdrViewComponents::Tables::TableComponent.new(label: 'This label is hidden',
51
+ show_label: false)) do |component|
52
+ component.with_row(label: 'Data Row', values: ['Value 1', 'Value 2', 'Value 3'])
53
+ end
54
+ end
55
+
56
+ # @!endgroup
57
+
58
+ def empty_message
59
+ render(SdrViewComponents::Tables::TableComponent.new(
60
+ label: 'No Data Available',
61
+ empty_message: 'No records found. Please try again later.'
62
+ ))
63
+ end
64
+
65
+ def responsive # rubocop:disable Metrics/MethodLength
66
+ render(SdrViewComponents::Tables::TableComponent.new(
67
+ label: 'Responsive Table',
68
+ responsive: true
69
+ )) do |component|
70
+ component.with_header(label: 'Row')
71
+ component.with_header(label: 'Column 1')
72
+ component.with_header(label: 'Column 2')
73
+ component.with_header(label: 'Column 3')
74
+ component.with_header(label: 'Column 4')
75
+ component.with_row(label: 'Row 1', values: ['Data 1', 'Data 2', 'Data 3', 'Data 4'])
76
+ component.with_row(label: 'Row 2', values: ['Data 5', 'Data 6', 'Data 7', 'Data 8'])
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end