sdr_view_components 0.2.0 → 0.3.0

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 (161) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +31 -5
  3. data/app/assets/sdr_view_components.css +9 -1
  4. data/app/components/sdr_view_components/elements/toast_component.html.erb +4 -8
  5. data/app/components/sdr_view_components/forms/basic_select_field_component.rb +24 -0
  6. data/app/components/sdr_view_components/forms/select_field_component.rb +20 -0
  7. data/app/components/sdr_view_components/forms/toggle_component.html.erb +1 -1
  8. data/app/components/sdr_view_components/forms/toggle_option_component.html.erb +1 -1
  9. data/app/components/sdr_view_components/tables/row_component.html.erb +1 -1
  10. data/app/views/layouts/lookbook.html.erb +1 -2
  11. data/lib/sdr_view_components/version.rb +1 -1
  12. data/spec/components/previews/sdr_view_components/elements/alert_component_preview.rb +71 -0
  13. data/spec/components/previews/sdr_view_components/elements/banner_component_preview.rb +58 -0
  14. data/spec/components/previews/sdr_view_components/elements/breadcrumb_nav_component_preview.rb +52 -0
  15. data/spec/components/previews/sdr_view_components/elements/button_component_preview.rb +71 -0
  16. data/spec/components/previews/sdr_view_components/elements/button_form_component_preview.rb +97 -0
  17. data/spec/components/previews/sdr_view_components/elements/button_link_component_preview.rb +81 -0
  18. data/spec/components/previews/sdr_view_components/elements/card_component_preview.rb +41 -0
  19. data/spec/components/previews/sdr_view_components/elements/heading_component_preview.rb +51 -0
  20. data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview/default.html.erb +5 -0
  21. data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview.rb +9 -0
  22. data/spec/components/previews/sdr_view_components/elements/icon_button_component_preview.rb +17 -0
  23. data/spec/components/previews/sdr_view_components/elements/icon_button_link_component_preview.rb +15 -0
  24. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/default.html.erb +9 -0
  25. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/with_header_and_footer.html.erb +19 -0
  26. data/spec/components/previews/sdr_view_components/elements/modal_component_preview/without_size.html.erb +9 -0
  27. data/spec/components/previews/sdr_view_components/elements/modal_component_preview.rb +15 -0
  28. data/spec/components/previews/sdr_view_components/elements/progress_bar_component_preview.rb +97 -0
  29. data/spec/components/previews/sdr_view_components/elements/spinner_component_preview.rb +83 -0
  30. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/default_variant.html.erb +12 -0
  31. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/underline_variant.html.erb +12 -0
  32. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/with_header.html.erb +16 -0
  33. data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview.rb +16 -0
  34. data/spec/components/previews/sdr_view_components/elements/toast_component_preview.rb +29 -0
  35. data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview/default.html.erb +13 -0
  36. data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview.rb +9 -0
  37. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/checked.html.erb +7 -0
  38. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/default.html.erb +6 -0
  39. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/disabled.html.erb +7 -0
  40. data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview.rb +17 -0
  41. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/default.html.erb +6 -0
  42. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_accept.html.erb +7 -0
  43. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_multiple.html.erb +7 -0
  44. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_required.html.erb +7 -0
  45. data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview.rb +25 -0
  46. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/checked.html.erb +8 -0
  47. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/default.html.erb +7 -0
  48. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/disabled.html.erb +8 -0
  49. data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview.rb +17 -0
  50. data/spec/components/previews/sdr_view_components/forms/basic/basic_select_field_component_preview/default.html.erb +11 -0
  51. data/spec/components/previews/sdr_view_components/forms/basic/basic_select_field_component_preview/with_prompt.html.erb +12 -0
  52. data/spec/components/previews/sdr_view_components/forms/basic/basic_select_field_component_preview.rb +13 -0
  53. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/default.html.erb +6 -0
  54. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_placeholder.html.erb +7 -0
  55. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_required.html.erb +7 -0
  56. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_rows.html.erb +7 -0
  57. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview.rb +19 -0
  58. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/default.html.erb +6 -0
  59. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/disabled.html.erb +8 -0
  60. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/required.html.erb +7 -0
  61. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/with_placeholder.html.erb +7 -0
  62. data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview.rb +19 -0
  63. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/checked.html.erb +9 -0
  64. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/default.html.erb +8 -0
  65. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/disabled.html.erb +9 -0
  66. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_additional_container_content.html.erb +12 -0
  67. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_help_text.html.erb +10 -0
  68. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_label.html.erb +9 -0
  69. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_validation_error.html.erb +8 -0
  70. data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview.rb +33 -0
  71. data/spec/components/previews/sdr_view_components/forms/file_component_preview/default.html.erb +8 -0
  72. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_additional_container_content.html.erb +14 -0
  73. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text.html.erb +9 -0
  74. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text_below.html.erb +10 -0
  75. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_label.html.erb +9 -0
  76. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_multiple.html.erb +9 -0
  77. data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_validation_error.html.erb +8 -0
  78. data/spec/components/previews/sdr_view_components/forms/file_component_preview.rb +32 -0
  79. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_block_content.html.erb +3 -0
  80. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_text.html.erb +4 -0
  81. data/spec/components/previews/sdr_view_components/forms/help_text_component_preview.rb +13 -0
  82. data/spec/components/previews/sdr_view_components/forms/label_component_preview/default.html.erb +7 -0
  83. data/spec/components/previews/sdr_view_components/forms/label_component_preview/hidden_label.html.erb +8 -0
  84. data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_caption.html.erb +8 -0
  85. data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_tooltip.html.erb +17 -0
  86. data/spec/components/previews/sdr_view_components/forms/label_component_preview.rb +17 -0
  87. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/default.html.erb +9 -0
  88. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_additional_container_content.html.erb +14 -0
  89. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_disabled_label.html.erb +11 -0
  90. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text.html.erb +10 -0
  91. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text_below.html.erb +11 -0
  92. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_label.html.erb +10 -0
  93. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_validation_error.html.erb +10 -0
  94. data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview.rb +34 -0
  95. data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/default.html.erb +13 -0
  96. data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_additional_container_content.html.erb +19 -0
  97. data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_help_text.html.erb +14 -0
  98. data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_help_text_below.html.erb +15 -0
  99. data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_prompt.html.erb +14 -0
  100. data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_validation_error.html.erb +15 -0
  101. data/spec/components/previews/sdr_view_components/forms/select_field_component_preview.rb +30 -0
  102. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/danger.html.erb +6 -0
  103. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/default.html.erb +5 -0
  104. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/info.html.erb +6 -0
  105. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/primary.html.erb +6 -0
  106. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/secondary.html.erb +6 -0
  107. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/success.html.erb +6 -0
  108. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/warning.html.erb +6 -0
  109. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_block_content_and_value.html.erb +7 -0
  110. data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_form_id.html.erb +8 -0
  111. data/spec/components/previews/sdr_view_components/forms/submit_component_preview.rb +29 -0
  112. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/default.html.erb +8 -0
  113. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_additional_container_content.html.erb +12 -0
  114. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text.html.erb +9 -0
  115. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text_below.html.erb +10 -0
  116. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_hidden_label.html.erb +9 -0
  117. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_mark_required.html.erb +9 -0
  118. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_validation_error.html.erb +8 -0
  119. data/spec/components/previews/sdr_view_components/forms/text_area_component_preview.rb +32 -0
  120. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/default.html.erb +8 -0
  121. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/disabled.html.erb +9 -0
  122. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/label_hidden.html.erb +9 -0
  123. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/marked_required.html.erb +9 -0
  124. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/required.html.erb +9 -0
  125. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_additional_container_content.html.erb +12 -0
  126. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text.html.erb +9 -0
  127. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text_below.html.erb +10 -0
  128. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_placeholder.html.erb +9 -0
  129. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_validation_error.html.erb +8 -0
  130. data/spec/components/previews/sdr_view_components/forms/text_field_component_preview.rb +40 -0
  131. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/default.html.erb +11 -0
  132. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/with_validation_error.html.erb +11 -0
  133. data/spec/components/previews/sdr_view_components/forms/toggle_component_preview.rb +20 -0
  134. data/spec/components/previews/sdr_view_components/structure/footer_component_preview.rb +11 -0
  135. data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant.html.erb +15 -0
  136. data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant_with_background_color.html.erb +15 -0
  137. data/spec/components/previews/sdr_view_components/structure/header_component_preview/light_variant.html.erb +15 -0
  138. data/spec/components/previews/sdr_view_components/structure/header_component_preview/no_rosette.html.erb +15 -0
  139. data/spec/components/previews/sdr_view_components/structure/header_component_preview/white_variant.html.erb +15 -0
  140. data/spec/components/previews/sdr_view_components/structure/header_component_preview.rb +16 -0
  141. data/spec/components/previews/sdr_view_components/tables/cell_component_preview/default.html.erb +9 -0
  142. data/spec/components/previews/sdr_view_components/tables/cell_component_preview/with_colspan.html.erb +17 -0
  143. data/spec/components/previews/sdr_view_components/tables/cell_component_preview.rb +11 -0
  144. data/spec/components/previews/sdr_view_components/tables/header_component_preview/default.html.erb +7 -0
  145. data/spec/components/previews/sdr_view_components/tables/header_component_preview/with_tooltip.html.erb +19 -0
  146. data/spec/components/previews/sdr_view_components/tables/header_component_preview.rb +11 -0
  147. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_item_values.html.erb +7 -0
  148. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_items.html.erb +11 -0
  149. data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview.rb +27 -0
  150. data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview/default.html.erb +26 -0
  151. data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview.rb +9 -0
  152. data/spec/components/previews/sdr_view_components/tables/row_component_preview/label_only.html.erb +5 -0
  153. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_cells.html.erb +13 -0
  154. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_first_value_and_values.html.erb +8 -0
  155. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_label_content.html.erb +11 -0
  156. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_tooltip.html.erb +18 -0
  157. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_value.html.erb +8 -0
  158. data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_values.html.erb +8 -0
  159. data/spec/components/previews/sdr_view_components/tables/row_component_preview.rb +21 -0
  160. data/spec/components/previews/sdr_view_components/tables/table_component_preview.rb +81 -0
  161. metadata +152 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbfc52ae67fecdff708f4696aaa7092396da6dff749264858c11dbbfbe8a4382
4
- data.tar.gz: 32a60c51ecd3fdb27a1ef011ad8fbaee64053f956e66d0d3d42c51fd36801f78
3
+ metadata.gz: 69a8ea2f413d71c60cab404598d4e5f0b65c4c0bf7b4aa332e657ea4ea3fae61
4
+ data.tar.gz: db647210ffedcfbec61c8a16602b3a0b25de94faf04c595c5b00dfdafdbd9321
5
5
  SHA512:
6
- metadata.gz: 0f7f24fc7019c867299b390b5ae6dff1a93fc7b41f66a5075f473b5ebd69061d7cd4f44f92480b6e3337f26ac2683b5b48260580bbc11aa72b9007a910884c11
7
- data.tar.gz: bbca5c2fc24924a8df4e40a706140b568502bf4816b3e2a43840614d201c28d849d1e2374febb56d9b4656f4ae6a0d8cd28e13750fcc5c94da0685dc78305161
6
+ metadata.gz: 1bd2d7d88d402446d0d033ba6d189eb7b211efe4357110244b908a4f603a4824e104af724d518d2e8a4b86d243e5a06e37971cdd4b526e2279e54de45e1bb8f9
7
+ data.tar.gz: 7bd1f0afcc43c17014331278c1e9515c4f4fd2c857ad5f02f5944327ab30074e2885fd8b7017188dd46f8f8b2b0300225e918d53666d1d0e109717bf11c77c55
data/Rakefile CHANGED
@@ -6,10 +6,36 @@ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
6
6
  load 'rails/tasks/engine.rake'
7
7
 
8
8
  require 'bundler/gem_tasks'
9
- require 'rspec/core/rake_task'
10
- require 'rubocop/rake_task'
11
9
 
12
- RuboCop::RakeTask.new
13
- RSpec::Core::RakeTask.new(:spec)
10
+ begin
11
+ require 'rubocop/rake_task'
12
+ RuboCop::RakeTask.new
14
13
 
15
- task default: %i[rubocop spec]
14
+ desc 'Run erblint against ERB files'
15
+ task erblint: :environment do
16
+ puts 'Running ERB linter...'
17
+ sh('bin/erb_lint --lint-all --format compact')
18
+ end
19
+
20
+ desc 'Run linter against style files'
21
+ task stylelint: :environment do
22
+ puts 'Running style linter...'
23
+ sh('yarn run stylelint')
24
+ end
25
+
26
+ desc 'Run herb against ERB files'
27
+ task herb: :environment do
28
+ puts 'Running ERB linter...'
29
+ sh('bin/herb analyze app --no-timing --non-interactive')
30
+ end
31
+
32
+ desc 'Run all configured linters'
33
+ task lint: %i[rubocop erblint herb]
34
+
35
+ # clear the default task injected by rspec
36
+ task(:default).clear
37
+
38
+ task default: %i[lint spec] # rubocop:disable Rake/DuplicateTask
39
+ rescue LoadError
40
+ # should only be here when gem group development and test aren't installed
41
+ end
@@ -67,7 +67,7 @@
67
67
  }
68
68
 
69
69
  .nav-underline .nav-link:not(.active) {
70
- color: rgba(var(--bs-link-color-rgb), var(--bs-link-opacity, 1));
70
+ color: rgb(var(--bs-link-color-rgb), var(--bs-link-opacity, 1));
71
71
  }
72
72
 
73
73
  .nav-underline .nav-link.active {
@@ -108,3 +108,11 @@ table.table-data th {
108
108
  width: fit-content;
109
109
  white-space: nowrap;
110
110
  }
111
+
112
+ /* Radio buttons */
113
+
114
+ /* Inputs / labels are rendered in the opposite order than BS styles expect. */
115
+ .form-check-label:has(+ .form-check-input:disabled), .form-check-label:has(+ .form-check-input[disabled]) {
116
+ cursor: default;
117
+ opacity: .5;
118
+ }
@@ -2,13 +2,11 @@
2
2
  class="toast align-items-center show"
3
3
  role="alert"
4
4
  aria-live="assertive"
5
- aria-atomic="true"
6
- >
5
+ aria-atomic="true">
7
6
  <%= tag.div class: toast_body_classes do %>
8
7
  <div class="d-flex">
9
8
  <div
10
- class="bi bi-exclamation-circle-fill fs-3 me-3 align-self-center d-flex justify-content-center"
11
- ></div>
9
+ class="bi bi-exclamation-circle-fill fs-3 me-3 align-self-center d-flex justify-content-center"></div>
12
10
  <div>
13
11
  <div class="fw-semibold"><%= title %> </div>
14
12
  <% if text.present? %>
@@ -19,8 +17,7 @@
19
17
  <% if close_text.present? %>
20
18
  <button
21
19
  type="button"
22
- class="btn btn-text text-uppercase text-white"
23
- >
20
+ class="btn btn-text text-uppercase text-white">
24
21
  <%= close_text %>
25
22
  </button>
26
23
  <% end %>
@@ -28,8 +25,7 @@
28
25
  type="button"
29
26
  class="btn btn-close btn-close-white"
30
27
  aria-label="Close"
31
- data-bs-dismiss="toast"
32
- ></button>
28
+ data-bs-dismiss="toast"></button>
33
29
  </div>
34
30
  </div>
35
31
  <% end %>
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Forms
5
+ # Component for form select field
6
+ class BasicSelectFieldComponent < BasicComponent
7
+ def initialize(form:, field_name:, options:, prompt: false, classes: [], **args) # rubocop:disable Metrics/ParameterLists
8
+ @options = options
9
+ @prompt = prompt
10
+ super(form:, field_name:, classes:, **args)
11
+ end
12
+
13
+ attr_reader :options, :prompt
14
+
15
+ def call
16
+ form.select field_name, options, { prompt: }, { class: classes, **args }
17
+ end
18
+
19
+ def classes
20
+ merge_classes('form-select', @classes)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Forms
5
+ # Component for form select fields
6
+ class SelectFieldComponent < FieldComponent
7
+ def initialize(options:, prompt: false, **)
8
+ @options = options
9
+ @prompt = prompt
10
+ super(**)
11
+ end
12
+
13
+ attr_reader :options, :prompt
14
+
15
+ def input_component
16
+ SdrViewComponents::Forms::BasicSelectFieldComponent.new(form:, field_name:, options:, prompt:, **input_args)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,4 +1,4 @@
1
- <%= tag.div **container_args do %>
1
+ <%= tag.div(**container_args) do %>
2
2
  <div class="d-flex"> <%# Aligns label and tooltip %>
3
3
  <%= render SdrViewComponents::Forms::LabelComponent.new(form:, field_name:, **label_args) %>
4
4
  </div>
@@ -1,2 +1,2 @@
1
1
  <%= form.radio_button field_name, value, type: 'radio', class: 'btn-check', data: %>
2
- <%= form.label field_name, label, value:, class: label_classes %>
2
+ <%= form.label(field_name, label, value:, class: label_classes) %>
@@ -1,4 +1,4 @@
1
- <%= tag.tr **row_options do %>
1
+ <%= tag.tr(**row_options) do %>
2
2
  <% if label.present? || label_content.present? %>
3
3
  <th class="col-3" scope="row">
4
4
  <%= label || label_content %>
@@ -27,8 +27,7 @@
27
27
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
28
28
  <link
29
29
  rel="stylesheet"
30
- href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css"
31
- >
30
+ href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
32
31
  <%= tag.link rel: 'icon', href: "#{SdrViewComponents.configuration.component_library_url}/styles/icon.png", type: 'image/png' %>
33
32
  <%= tag.link rel: 'icon', href: "#{SdrViewComponents.configuration.component_library_url}/styles/icon.svg", type: 'image/svg+xml' %>
34
33
  <%= tag.link rel: 'apple-touch-icon', href: "#{SdrViewComponents.configuration.component_library_url}/styles/icon.png" %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrViewComponents
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Elements
5
+ class AlertComponentPreview < ViewComponent::Preview
6
+ # @!group Variants
7
+ def default
8
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Information', variant: :info) do
9
+ 'This is an informational alert.'
10
+ end
11
+ end
12
+
13
+ def danger
14
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Error', variant: :danger) do
15
+ 'This is a danger alert.'
16
+ end
17
+ end
18
+
19
+ def success
20
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Success', variant: :success) do
21
+ 'This is a success alert.'
22
+ end
23
+ end
24
+
25
+ def note
26
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Note', variant: :note) do
27
+ 'This is a note alert.'
28
+ end
29
+ end
30
+
31
+ def warning
32
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Warning', variant: :warning) do
33
+ 'This is a warning alert.'
34
+ end
35
+ end
36
+
37
+ def input
38
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Input Required', variant: :input) do
39
+ 'This is an input validation alert.'
40
+ end
41
+ end
42
+ # @!endgroup
43
+
44
+ def with_title_only
45
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Alert Title Only') do
46
+ 'Content goes here.'
47
+ end
48
+ end
49
+
50
+ def dismissible_alert
51
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Dismissible Alert', dismissible: true) do
52
+ 'Click the X button to dismiss this alert.'
53
+ end
54
+ end
55
+
56
+ # @!group Content Options
57
+ def with_text_property
58
+ render SdrViewComponents::Elements::AlertComponent
59
+ .new(title: 'Using Text Property',
60
+ text: 'This alert uses the text parameter instead of block content.')
61
+ end
62
+
63
+ def with_block_content
64
+ render SdrViewComponents::Elements::AlertComponent.new(title: 'Using Block Content') do
65
+ 'This alert uses block content, which can include HTML or other components.'
66
+ end
67
+ end
68
+ # @!endgroup
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Elements
5
+ class BannerComponentPreview < ViewComponent::Preview
6
+ # @!group Variants
7
+ def default
8
+ render SdrViewComponents::Elements::BannerComponent.new do |component|
9
+ component.with_header { 'Welcome to the Banner Component' }
10
+ end
11
+ end
12
+
13
+ def note
14
+ render SdrViewComponents::Elements::BannerComponent.new(variant: :note) do |component|
15
+ component.with_header { 'Note: Important Information' }
16
+ end
17
+ end
18
+
19
+ def success
20
+ render SdrViewComponents::Elements::BannerComponent.new(variant: :success) do |component|
21
+ component.with_header { 'Success: Action Completed' }
22
+ end
23
+ end
24
+
25
+ def warning
26
+ render SdrViewComponents::Elements::BannerComponent.new(variant: :warning) do |component|
27
+ component.with_header { 'Warning: Please Review' }
28
+ end
29
+ end
30
+
31
+ def info
32
+ render SdrViewComponents::Elements::BannerComponent.new(variant: :info) do |component|
33
+ component.with_header { 'Information: For Your Reference' }
34
+ end
35
+ end
36
+
37
+ def danger
38
+ render SdrViewComponents::Elements::BannerComponent.new(variant: :danger) do |component|
39
+ component.with_header { 'Danger: Critical Alert' }
40
+ end
41
+ end
42
+ # @!endgroup
43
+
44
+ def with_title
45
+ render SdrViewComponents::Elements::BannerComponent.new(title: 'Subtitle or Additional Title') do |component|
46
+ component.with_header { 'Main Header' }
47
+ end
48
+ end
49
+
50
+ def with_header_and_body
51
+ render SdrViewComponents::Elements::BannerComponent.new do |component|
52
+ component.with_header { 'Banner Header' }
53
+ component.with_body { 'This is the body content of the banner, providing additional context or details.' }
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Elements
5
+ class BreadcrumbNavComponentPreview < ViewComponent::Preview
6
+ # @!group Breadcrumb Types
7
+ def default_breadcrumbs
8
+ render SdrViewComponents::Elements::BreadcrumbNavComponent.new do |component|
9
+ component.with_breadcrumb(text: 'Home', link: '/')
10
+ component.with_breadcrumb(text: 'Collections', link: '/collections')
11
+ component.with_breadcrumb(text: 'Current Page', active: true)
12
+ end
13
+ end
14
+
15
+ def title_breadcrumbs
16
+ render SdrViewComponents::Elements::BreadcrumbNavComponent.new do |component|
17
+ component.with_title_breadcrumb(text: 'Home', link: '/')
18
+ component.with_title_breadcrumb(text: 'A Very Long Title That Will Be Truncated', link: '/titles')
19
+ component.with_title_breadcrumb(text: 'Current Title Item', active: true)
20
+ end
21
+ end
22
+
23
+ def collection_breadcrumbs
24
+ render SdrViewComponents::Elements::BreadcrumbNavComponent.new do |component|
25
+ component.with_collection_breadcrumb(text: 'Home', link: '/')
26
+ component.with_collection_breadcrumb(text: 'Collection Name Truncated', link: '/collections')
27
+ component.with_collection_breadcrumb(text: 'Item', active: true)
28
+ end
29
+ end
30
+ # @!endgroup
31
+
32
+ # @!group With Links and Active State
33
+ def with_all_links
34
+ render SdrViewComponents::Elements::BreadcrumbNavComponent.new do |component|
35
+ component.with_breadcrumb(text: 'Home', link: '/')
36
+ component.with_breadcrumb(text: 'Section', link: '/section')
37
+ component.with_breadcrumb(text: 'Subsection', link: '/section/subsection')
38
+ component.with_breadcrumb(text: 'Current', active: true)
39
+ end
40
+ end
41
+
42
+ def mixed_active_items
43
+ render SdrViewComponents::Elements::BreadcrumbNavComponent.new do |component|
44
+ component.with_breadcrumb(text: 'Home', link: '/')
45
+ component.with_breadcrumb(text: 'Active Section', active: true)
46
+ component.with_breadcrumb(text: 'Another Item', link: '/other')
47
+ end
48
+ end
49
+ # @!endgroup
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Elements
5
+ class ButtonComponentPreview < ViewComponent::Preview
6
+ # @!group Button Variants
7
+ def primary
8
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Primary', variant: 'primary')
9
+ end
10
+
11
+ def secondary
12
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Secondary', variant: 'secondary')
13
+ end
14
+
15
+ def success
16
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Success', variant: 'success')
17
+ end
18
+
19
+ def danger
20
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Danger', variant: 'danger')
21
+ end
22
+
23
+ def warning
24
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Warning', variant: 'warning')
25
+ end
26
+
27
+ def info
28
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Info', variant: 'info')
29
+ end
30
+ # @!endgroup
31
+
32
+ # @!group Button Sizes
33
+ def small
34
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Small Button', variant: 'primary', size: 'sm')
35
+ end
36
+
37
+ def large
38
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Large Button', variant: 'primary', size: 'lg')
39
+ end
40
+ # @!endgroup
41
+
42
+ # @!group Borderless
43
+ def borderless
44
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Borderless Button', variant: 'primary',
45
+ bordered: false)
46
+ end
47
+
48
+ def borderless_secondary
49
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Borderless Secondary', variant: 'secondary',
50
+ bordered: false)
51
+ end
52
+ # @!endgroup
53
+
54
+ # @!group Content Options
55
+ def with_label
56
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Button with Label', variant: 'primary')
57
+ end
58
+
59
+ def with_block_content
60
+ render SdrViewComponents::Elements::ButtonComponent.new(variant: 'primary') do
61
+ 'Button with Block Content'
62
+ end
63
+ end
64
+ # @!endgroup
65
+
66
+ def default
67
+ render SdrViewComponents::Elements::ButtonComponent.new(label: 'Default Button')
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Elements
5
+ class ButtonFormComponentPreview < ViewComponent::Preview
6
+ # @!group Button Variants
7
+ def primary
8
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Primary Form Button',
9
+ variant: :primary)
10
+ end
11
+
12
+ def secondary
13
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Secondary Form Button',
14
+ variant: :secondary)
15
+ end
16
+
17
+ def success
18
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Success Action',
19
+ variant: :success)
20
+ end
21
+
22
+ def danger
23
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Delete Item', variant: :danger)
24
+ end
25
+
26
+ def warning
27
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Warning Action',
28
+ variant: :warning)
29
+ end
30
+
31
+ def info
32
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', label: 'Information Action',
33
+ variant: :info)
34
+ end
35
+ # @!endgroup
36
+
37
+ # @!group With Confirmation
38
+ def with_confirmation
39
+ render SdrViewComponents::Elements::ButtonFormComponent.new(
40
+ link: '/delete-item',
41
+ label: 'Delete (with confirmation)',
42
+ variant: :danger,
43
+ confirm: 'Are you sure you want to delete this item?'
44
+ )
45
+ end
46
+
47
+ def without_confirmation
48
+ render SdrViewComponents::Elements::ButtonFormComponent.new(
49
+ link: '/action',
50
+ label: 'Action (no confirmation)',
51
+ variant: :primary
52
+ )
53
+ end
54
+ # @!endgroup
55
+
56
+ # @!group Turbo Frame Behavior
57
+ def turbo_frame_top
58
+ render SdrViewComponents::Elements::ButtonFormComponent.new(
59
+ link: '/submit',
60
+ label: 'Submit (reload top)',
61
+ variant: :primary,
62
+ top: true
63
+ )
64
+ end
65
+
66
+ def turbo_frame_scoped
67
+ render SdrViewComponents::Elements::ButtonFormComponent.new(
68
+ link: '/submit',
69
+ label: 'Submit (scoped frame)',
70
+ variant: :primary,
71
+ top: false
72
+ )
73
+ end
74
+ # @!endgroup
75
+
76
+ # @!group Content Options
77
+ def with_label
78
+ render SdrViewComponents::Elements::ButtonFormComponent.new(
79
+ link: '/action',
80
+ label: 'Button with Label',
81
+ variant: :primary
82
+ )
83
+ end
84
+
85
+ def with_block_content
86
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/action', variant: :primary) do
87
+ 'Button with Block Content'
88
+ end
89
+ end
90
+ # @!endgroup
91
+
92
+ def default
93
+ render SdrViewComponents::Elements::ButtonFormComponent.new(link: '/', label: 'Form Button')
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Elements
5
+ class ButtonLinkComponentPreview < ViewComponent::Preview
6
+ # @!group Button Variants
7
+ def primary
8
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Primary Link Button',
9
+ variant: :primary)
10
+ end
11
+
12
+ def secondary
13
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Secondary Link Button',
14
+ variant: :secondary)
15
+ end
16
+
17
+ def success
18
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Success Link Button',
19
+ variant: :success)
20
+ end
21
+
22
+ def danger
23
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Danger Link Button',
24
+ variant: :danger)
25
+ end
26
+
27
+ def warning
28
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Warning Link Button',
29
+ variant: :warning)
30
+ end
31
+
32
+ def info
33
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Info Link Button',
34
+ variant: :info)
35
+ end
36
+ # @!endgroup
37
+
38
+ # @!group Button Sizes
39
+ def small
40
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Small Link Button',
41
+ variant: :primary, size: 'sm')
42
+ end
43
+
44
+ def large
45
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Large Link Button',
46
+ variant: :primary, size: 'lg')
47
+ end
48
+ # @!endgroup
49
+
50
+ # @!group Borderless
51
+ def borderless
52
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Borderless Link Button',
53
+ variant: :primary, bordered: false)
54
+ end
55
+
56
+ def borderless_secondary
57
+ render SdrViewComponents::Elements::ButtonLinkComponent
58
+ .new(link: '/example',
59
+ label: 'Borderless Secondary Link Button', variant: :secondary, bordered: false)
60
+ end
61
+ # @!endgroup
62
+
63
+ # @!group Content Options
64
+ def with_label
65
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Label Link Button',
66
+ variant: :primary)
67
+ end
68
+
69
+ def with_block_content
70
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', variant: :primary) do
71
+ 'Link Button with Block Content'
72
+ end
73
+ end
74
+ # @!endgroup
75
+
76
+ def default
77
+ render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Default Link Button')
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SdrViewComponents
4
+ module Elements
5
+ class CardComponentPreview < ViewComponent::Preview
6
+ # @!group Card Slots
7
+ def default
8
+ render SdrViewComponents::Elements::CardComponent.new
9
+ end
10
+
11
+ def with_header
12
+ render SdrViewComponents::Elements::CardComponent.new do |card|
13
+ card.with_header do
14
+ 'Card Header'
15
+ end
16
+ end
17
+ end
18
+
19
+ def with_body
20
+ render SdrViewComponents::Elements::CardComponent.new do |card|
21
+ card.with_body do
22
+ 'Card body content goes here.'
23
+ end
24
+ end
25
+ end
26
+
27
+ def with_header_and_body
28
+ render SdrViewComponents::Elements::CardComponent.new do |card|
29
+ card.with_header do
30
+ 'Card Header'
31
+ end
32
+
33
+ card.with_body do
34
+ 'Card body content goes here.'
35
+ end
36
+ end
37
+ end
38
+ # @!endgroup
39
+ end
40
+ end
41
+ end