sdr_view_components 0.1.14 → 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 (174) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -38
  3. data/app/assets/sdr_view_components.css +110 -0
  4. data/app/components/sdr_view_components/elements/heading_component.rb +3 -1
  5. data/app/components/sdr_view_components/elements/icon_button_component.rb +10 -0
  6. data/app/components/sdr_view_components/elements/spinner_component.html.erb +2 -2
  7. data/app/components/sdr_view_components/elements/spinner_component.rb +5 -4
  8. data/app/components/sdr_view_components/elements/tabs/pane_component.html.erb +3 -0
  9. data/app/components/sdr_view_components/elements/tabs/pane_component.rb +27 -0
  10. data/app/components/sdr_view_components/elements/tabs/tab_component.html.erb +3 -0
  11. data/app/components/sdr_view_components/elements/tabs/tab_component.rb +42 -0
  12. data/app/components/sdr_view_components/elements/tabs/tab_list_component.html.erb +9 -0
  13. data/app/components/sdr_view_components/elements/tabs/tab_list_component.rb +33 -0
  14. data/app/components/sdr_view_components/elements/toast_component.rb +1 -1
  15. data/app/components/sdr_view_components/tables/base_table_component.html.erb +32 -0
  16. data/app/components/sdr_view_components/tables/base_table_component.rb +69 -0
  17. data/app/components/sdr_view_components/tables/cell_component.html.erb +3 -0
  18. data/app/components/sdr_view_components/tables/cell_component.rb +21 -0
  19. data/app/components/sdr_view_components/tables/header_component.html.erb +4 -0
  20. data/app/components/sdr_view_components/tables/header_component.rb +22 -0
  21. data/app/components/sdr_view_components/tables/list_cell_component.html.erb +5 -0
  22. data/app/components/sdr_view_components/tables/list_cell_component.rb +22 -0
  23. data/app/components/sdr_view_components/tables/raw_table_component.rb +10 -0
  24. data/app/components/sdr_view_components/tables/row_component.html.erb +24 -0
  25. data/app/components/sdr_view_components/tables/row_component.rb +32 -0
  26. data/app/components/sdr_view_components/tables/table_component.rb +10 -0
  27. data/app/views/layouts/lookbook.html.erb +46 -0
  28. data/lib/sdr_view_components/configuration.rb +22 -0
  29. data/lib/sdr_view_components/engine.rb +17 -7
  30. data/lib/sdr_view_components/error.rb +7 -0
  31. data/lib/sdr_view_components/version.rb +1 -1
  32. data/lib/sdr_view_components.rb +2 -0
  33. data/spec/components/previews/sdr_view_components/elements/alert_component_preview.rb +71 -0
  34. data/spec/components/previews/sdr_view_components/elements/banner_component_preview.rb +58 -0
  35. data/spec/components/previews/sdr_view_components/elements/breadcrumb_nav_component_preview.rb +52 -0
  36. data/spec/components/previews/sdr_view_components/elements/button_component_preview.rb +71 -0
  37. data/spec/components/previews/sdr_view_components/elements/button_form_component_preview.rb +97 -0
  38. data/spec/components/previews/sdr_view_components/elements/button_link_component_preview.rb +81 -0
  39. data/spec/components/previews/sdr_view_components/elements/card_component_preview.rb +41 -0
  40. data/spec/components/previews/sdr_view_components/elements/heading_component_preview.rb +51 -0
  41. data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview/default.html.erb +5 -0
  42. data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview.rb +9 -0
  43. data/spec/components/previews/sdr_view_components/elements/icon_button_component_preview.rb +17 -0
  44. data/spec/components/previews/sdr_view_components/elements/icon_button_link_component_preview.rb +15 -0
  45. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/default.html.erb +9 -0
  46. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/with_header_and_footer.html.erb +19 -0
  47. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/without_size.html.erb +9 -0
  48. data/spec/components/previews/sdr_view_components/elements/modal_component_preview.rb +15 -0
  49. data/spec/components/previews/sdr_view_components/elements/progress_bar_component_preview.rb +97 -0
  50. data/spec/components/previews/sdr_view_components/elements/spinner_component_preview.rb +83 -0
  51. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/default_variant.html.erb +12 -0
  52. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/underline_variant.html.erb +12 -0
  53. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/with_header.html.erb +16 -0
  54. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview.rb +16 -0
  55. data/spec/components/previews/sdr_view_components/elements/toast_component_preview.rb +29 -0
  56. data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview/default.html.erb +13 -0
  57. data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview.rb +9 -0
  58. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/checked.html.erb +7 -0
  59. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/default.html.erb +6 -0
  60. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/disabled.html.erb +7 -0
  61. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview.rb +17 -0
  62. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/default.html.erb +6 -0
  63. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_accept.html.erb +7 -0
  64. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_multiple.html.erb +7 -0
  65. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_required.html.erb +7 -0
  66. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview.rb +25 -0
  67. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/checked.html.erb +8 -0
  68. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/default.html.erb +7 -0
  69. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/disabled.html.erb +8 -0
  70. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview.rb +17 -0
  71. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/default.html.erb +6 -0
  72. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_placeholder.html.erb +7 -0
  73. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_required.html.erb +7 -0
  74. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_rows.html.erb +7 -0
  75. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview.rb +19 -0
  76. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/default.html.erb +6 -0
  77. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/disabled.html.erb +8 -0
  78. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/required.html.erb +7 -0
  79. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/with_placeholder.html.erb +7 -0
  80. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview.rb +19 -0
  81. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/checked.html.erb +9 -0
  82. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/default.html.erb +8 -0
  83. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/disabled.html.erb +9 -0
  84. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_additional_container_content.html.erb +12 -0
  85. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_help_text.html.erb +10 -0
  86. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_label.html.erb +9 -0
  87. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_validation_error.html.erb +9 -0
  88. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview.rb +33 -0
  89. data/spec/components/previews/sdr_view_components/forms/file_component_preview/default.html.erb +8 -0
  90. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_additional_container_content.html.erb +14 -0
  91. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text.html.erb +9 -0
  92. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text_below.html.erb +10 -0
  93. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_label.html.erb +9 -0
  94. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_multiple.html.erb +9 -0
  95. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_validation_error.html.erb +9 -0
  96. data/spec/components/previews/sdr_view_components/forms/file_component_preview.rb +32 -0
  97. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_block_content.html.erb +3 -0
  98. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_text.html.erb +4 -0
  99. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview.rb +13 -0
  100. data/spec/components/previews/sdr_view_components/forms/label_component_preview/default.html.erb +7 -0
  101. data/spec/components/previews/sdr_view_components/forms/label_component_preview/hidden_label.html.erb +8 -0
  102. data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_caption.html.erb +8 -0
  103. data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_tooltip.html.erb +17 -0
  104. data/spec/components/previews/sdr_view_components/forms/label_component_preview.rb +17 -0
  105. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/default.html.erb +9 -0
  106. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_additional_container_content.html.erb +14 -0
  107. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text.html.erb +10 -0
  108. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text_below.html.erb +11 -0
  109. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_label.html.erb +10 -0
  110. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_validation_error.html.erb +11 -0
  111. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview.rb +30 -0
  112. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/danger.html.erb +6 -0
  113. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/default.html.erb +5 -0
  114. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/info.html.erb +6 -0
  115. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/primary.html.erb +6 -0
  116. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/secondary.html.erb +6 -0
  117. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/success.html.erb +6 -0
  118. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/warning.html.erb +6 -0
  119. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_block_content_and_value.html.erb +7 -0
  120. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_form_id.html.erb +8 -0
  121. data/spec/components/previews/sdr_view_components/forms/submit_component_preview.rb +29 -0
  122. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/default.html.erb +8 -0
  123. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_additional_container_content.html.erb +12 -0
  124. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text.html.erb +9 -0
  125. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text_below.html.erb +10 -0
  126. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_hidden_label.html.erb +9 -0
  127. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_mark_required.html.erb +9 -0
  128. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_validation_error.html.erb +9 -0
  129. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview.rb +32 -0
  130. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/default.html.erb +8 -0
  131. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/disabled.html.erb +9 -0
  132. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/label_hidden.html.erb +9 -0
  133. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/marked_required.html.erb +9 -0
  134. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/required.html.erb +9 -0
  135. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_additional_container_content.html.erb +12 -0
  136. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text.html.erb +9 -0
  137. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text_below.html.erb +10 -0
  138. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_placeholder.html.erb +9 -0
  139. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_validation_error.html.erb +9 -0
  140. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview.rb +40 -0
  141. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/default.html.erb +11 -0
  142. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/with_validation_error.html.erb +12 -0
  143. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview.rb +20 -0
  144. data/spec/components/previews/sdr_view_components/structure/footer_component_preview.rb +11 -0
  145. data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant.html.erb +15 -0
  146. data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant_with_background_color.html.erb +15 -0
  147. data/spec/components/previews/sdr_view_components/structure/header_component_preview/light_variant.html.erb +15 -0
  148. data/spec/components/previews/sdr_view_components/structure/header_component_preview/no_rosette.html.erb +15 -0
  149. data/spec/components/previews/sdr_view_components/structure/header_component_preview/white_variant.html.erb +15 -0
  150. data/spec/components/previews/sdr_view_components/structure/header_component_preview.rb +16 -0
  151. data/spec/components/previews/sdr_view_components/tables/cell_component_preview/default.html.erb +9 -0
  152. data/spec/components/previews/sdr_view_components/tables/cell_component_preview/with_colspan.html.erb +17 -0
  153. data/spec/components/previews/sdr_view_components/tables/cell_component_preview.rb +11 -0
  154. data/spec/components/previews/sdr_view_components/tables/header_component_preview/default.html.erb +7 -0
  155. data/spec/components/previews/sdr_view_components/tables/header_component_preview/with_tooltip.html.erb +19 -0
  156. data/spec/components/previews/sdr_view_components/tables/header_component_preview.rb +11 -0
  157. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_item_values.html.erb +7 -0
  158. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_items.html.erb +11 -0
  159. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview.rb +27 -0
  160. data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview/default.html.erb +26 -0
  161. data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview.rb +9 -0
  162. data/spec/components/previews/sdr_view_components/tables/row_component_preview/label_only.html.erb +5 -0
  163. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_cells.html.erb +13 -0
  164. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_first_value_and_values.html.erb +8 -0
  165. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_label_content.html.erb +11 -0
  166. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_tooltip.html.erb +18 -0
  167. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_value.html.erb +8 -0
  168. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_values.html.erb +8 -0
  169. data/spec/components/previews/sdr_view_components/tables/row_component_preview.rb +21 -0
  170. data/spec/components/previews/sdr_view_components/tables/table_component_preview.rb +81 -0
  171. metadata +163 -6
  172. data/app/assets/stylesheets/styles.scss +0 -118
  173. data/app/components/component_support/file_hierarchy.rb +0 -22
  174. data/app/components/sdr_view_components/forms/button_component.rb +0 -42
@@ -0,0 +1,10 @@
1
+ <% model = SdrViewComponents::Forms::TextAreaComponentPreview::TextAreaPreviewModel.new(description: nil) %>
2
+
3
+ <%= form_with(model: model, url: '/example') do |form| %>
4
+ <%= render SdrViewComponents::Forms::TextAreaComponent.new(
5
+ form: form,
6
+ field_name: :description,
7
+ variant: :help_text_below,
8
+ help_text: 'This help text appears after the textarea.'
9
+ ) %>
10
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% model = SdrViewComponents::Forms::TextAreaComponentPreview::TextAreaPreviewModel.new(description: nil) %>
2
+
3
+ <%= form_with(model: model, url: '/example') do |form| %>
4
+ <%= render SdrViewComponents::Forms::TextAreaComponent.new(
5
+ form: form,
6
+ field_name: :description,
7
+ label_hidden: true
8
+ ) %>
9
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% model = SdrViewComponents::Forms::TextAreaComponentPreview::TextAreaPreviewModel.new(description: nil) %>
2
+
3
+ <%= form_with(model: model, url: '/example') do |form| %>
4
+ <%= render SdrViewComponents::Forms::TextAreaComponent.new(
5
+ form: form,
6
+ field_name: :description,
7
+ mark_required: true
8
+ ) %>
9
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <% model = SdrViewComponents::Forms::TextAreaComponentPreview::TextAreaPreviewModel.new(description: nil) %>
2
+ <% model.valid? %>
3
+
4
+ <%= form_with(model: model, url: '/example') do |form| %>
5
+ <%= render SdrViewComponents::Forms::TextAreaComponent.new(
6
+ form: form,
7
+ field_name: :description
8
+ ) %>
9
+ <% end %>
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Forms
5
+ class TextAreaComponentPreview < ViewComponent::Preview
6
+ def default; end
7
+
8
+ # @!group Help text
9
+ def with_help_text; end
10
+
11
+ def with_help_text_below; end
12
+ # @!endgroup
13
+
14
+ def with_hidden_label; end
15
+
16
+ def with_mark_required; end
17
+
18
+ def with_additional_container_content; end
19
+
20
+ def with_validation_error; end
21
+
22
+ class TextAreaPreviewModel
23
+ include ActiveModel::Model
24
+ include ActiveModel::Attributes
25
+
26
+ attribute :description, :string, default: nil
27
+
28
+ validates :description, presence: true
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,8 @@
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
+ ) %>
8
+ <% end %>
@@ -0,0 +1,9 @@
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
+ input_disabled: true
8
+ ) %>
9
+ <% end %>
@@ -0,0 +1,9 @@
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
+ label_hidden: true
8
+ ) %>
9
+ <% 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
+ mark_required: true
8
+ ) %>
9
+ <% 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_required: true
8
+ ) %>
9
+ <% end %>
@@ -0,0 +1,12 @@
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
+ ) do |component| %>
8
+ <% component.with_additional_container_content do %>
9
+ <span class="text-info">Suggested: keep titles under 80 characters.</span>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,9 @@
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
+ help_text: 'Use a concise title that will make sense to end users.'
8
+ ) %>
9
+ <% end %>
@@ -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>