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.
- checksums.yaml +4 -4
- data/README.md +55 -38
- data/app/assets/sdr_view_components.css +110 -0
- data/app/components/sdr_view_components/elements/heading_component.rb +3 -1
- data/app/components/sdr_view_components/elements/icon_button_component.rb +10 -0
- data/app/components/sdr_view_components/elements/spinner_component.html.erb +2 -2
- data/app/components/sdr_view_components/elements/spinner_component.rb +5 -4
- data/app/components/sdr_view_components/elements/tabs/pane_component.html.erb +3 -0
- data/app/components/sdr_view_components/elements/tabs/pane_component.rb +27 -0
- data/app/components/sdr_view_components/elements/tabs/tab_component.html.erb +3 -0
- data/app/components/sdr_view_components/elements/tabs/tab_component.rb +42 -0
- data/app/components/sdr_view_components/elements/tabs/tab_list_component.html.erb +9 -0
- data/app/components/sdr_view_components/elements/tabs/tab_list_component.rb +33 -0
- data/app/components/sdr_view_components/elements/toast_component.rb +1 -1
- data/app/components/sdr_view_components/tables/base_table_component.html.erb +32 -0
- data/app/components/sdr_view_components/tables/base_table_component.rb +69 -0
- data/app/components/sdr_view_components/tables/cell_component.html.erb +3 -0
- data/app/components/sdr_view_components/tables/cell_component.rb +21 -0
- data/app/components/sdr_view_components/tables/header_component.html.erb +4 -0
- data/app/components/sdr_view_components/tables/header_component.rb +22 -0
- data/app/components/sdr_view_components/tables/list_cell_component.html.erb +5 -0
- data/app/components/sdr_view_components/tables/list_cell_component.rb +22 -0
- data/app/components/sdr_view_components/tables/raw_table_component.rb +10 -0
- data/app/components/sdr_view_components/tables/row_component.html.erb +24 -0
- data/app/components/sdr_view_components/tables/row_component.rb +32 -0
- data/app/components/sdr_view_components/tables/table_component.rb +10 -0
- data/app/views/layouts/lookbook.html.erb +46 -0
- data/lib/sdr_view_components/configuration.rb +22 -0
- data/lib/sdr_view_components/engine.rb +17 -7
- data/lib/sdr_view_components/error.rb +7 -0
- data/lib/sdr_view_components/version.rb +1 -1
- data/lib/sdr_view_components.rb +2 -0
- data/spec/components/previews/sdr_view_components/elements/alert_component_preview.rb +71 -0
- data/spec/components/previews/sdr_view_components/elements/banner_component_preview.rb +58 -0
- data/spec/components/previews/sdr_view_components/elements/breadcrumb_nav_component_preview.rb +52 -0
- data/spec/components/previews/sdr_view_components/elements/button_component_preview.rb +71 -0
- data/spec/components/previews/sdr_view_components/elements/button_form_component_preview.rb +97 -0
- data/spec/components/previews/sdr_view_components/elements/button_link_component_preview.rb +81 -0
- data/spec/components/previews/sdr_view_components/elements/card_component_preview.rb +41 -0
- data/spec/components/previews/sdr_view_components/elements/heading_component_preview.rb +51 -0
- data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview/default.html.erb +5 -0
- data/spec/components/previews/sdr_view_components/elements/horizontal_rule_component_preview.rb +9 -0
- data/spec/components/previews/sdr_view_components/elements/icon_button_component_preview.rb +17 -0
- data/spec/components/previews/sdr_view_components/elements/icon_button_link_component_preview.rb +15 -0
- data/spec/components/previews/sdr_view_components/elements/modal_component_preview/default.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/elements/modal_component_preview/with_header_and_footer.html.erb +19 -0
- data/spec/components/previews/sdr_view_components/elements/modal_component_preview/without_size.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/elements/modal_component_preview.rb +15 -0
- data/spec/components/previews/sdr_view_components/elements/progress_bar_component_preview.rb +97 -0
- data/spec/components/previews/sdr_view_components/elements/spinner_component_preview.rb +83 -0
- data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/default_variant.html.erb +12 -0
- data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/underline_variant.html.erb +12 -0
- data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/with_header.html.erb +16 -0
- data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview.rb +16 -0
- data/spec/components/previews/sdr_view_components/elements/toast_component_preview.rb +29 -0
- data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview/default.html.erb +13 -0
- data/spec/components/previews/sdr_view_components/elements/tooltip_component_preview.rb +9 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/checked.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/default.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview/disabled.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_checkbox_component_preview.rb +17 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/default.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_accept.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_multiple.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview/with_required.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_file_component_preview.rb +25 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/checked.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/default.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview/disabled.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_radio_button_component_preview.rb +17 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/default.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_placeholder.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_required.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview/with_rows.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview.rb +19 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/default.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/disabled.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/required.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview/with_placeholder.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview.rb +19 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/checked.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/default.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/disabled.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_additional_container_content.html.erb +12 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_help_text.html.erb +10 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_label.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_validation_error.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview.rb +33 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview/default.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_additional_container_content.html.erb +14 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_help_text_below.html.erb +10 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_label.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_multiple.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_validation_error.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/file_component_preview.rb +32 -0
- data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_block_content.html.erb +3 -0
- data/spec/components/previews/sdr_view_components/forms/help_text_component_preview/with_text.html.erb +4 -0
- data/spec/components/previews/sdr_view_components/forms/help_text_component_preview.rb +13 -0
- data/spec/components/previews/sdr_view_components/forms/label_component_preview/default.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/label_component_preview/hidden_label.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_caption.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/label_component_preview/with_tooltip.html.erb +17 -0
- data/spec/components/previews/sdr_view_components/forms/label_component_preview.rb +17 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/default.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_additional_container_content.html.erb +14 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text.html.erb +10 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_help_text_below.html.erb +11 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_label.html.erb +10 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_validation_error.html.erb +11 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview.rb +30 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/danger.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/default.html.erb +5 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/info.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/primary.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/secondary.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/success.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/warning.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_block_content_and_value.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview/with_form_id.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/submit_component_preview.rb +29 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/default.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_additional_container_content.html.erb +12 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_help_text_below.html.erb +10 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_hidden_label.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_mark_required.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/with_validation_error.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_area_component_preview.rb +32 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/default.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/disabled.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/label_hidden.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/marked_required.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/required.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_additional_container_content.html.erb +12 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_help_text_below.html.erb +10 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_placeholder.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview/with_validation_error.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/text_field_component_preview.rb +40 -0
- data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/default.html.erb +11 -0
- data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/with_validation_error.html.erb +12 -0
- data/spec/components/previews/sdr_view_components/forms/toggle_component_preview.rb +20 -0
- data/spec/components/previews/sdr_view_components/structure/footer_component_preview.rb +11 -0
- data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant.html.erb +15 -0
- data/spec/components/previews/sdr_view_components/structure/header_component_preview/dark_variant_with_background_color.html.erb +15 -0
- data/spec/components/previews/sdr_view_components/structure/header_component_preview/light_variant.html.erb +15 -0
- data/spec/components/previews/sdr_view_components/structure/header_component_preview/no_rosette.html.erb +15 -0
- data/spec/components/previews/sdr_view_components/structure/header_component_preview/white_variant.html.erb +15 -0
- data/spec/components/previews/sdr_view_components/structure/header_component_preview.rb +16 -0
- data/spec/components/previews/sdr_view_components/tables/cell_component_preview/default.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/tables/cell_component_preview/with_colspan.html.erb +17 -0
- data/spec/components/previews/sdr_view_components/tables/cell_component_preview.rb +11 -0
- data/spec/components/previews/sdr_view_components/tables/header_component_preview/default.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/tables/header_component_preview/with_tooltip.html.erb +19 -0
- data/spec/components/previews/sdr_view_components/tables/header_component_preview.rb +11 -0
- data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_item_values.html.erb +7 -0
- data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview/with_items.html.erb +11 -0
- data/spec/components/previews/sdr_view_components/tables/list_cell_component_preview.rb +27 -0
- data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview/default.html.erb +26 -0
- data/spec/components/previews/sdr_view_components/tables/raw_table_component_preview.rb +9 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview/label_only.html.erb +5 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_cells.html.erb +13 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_first_value_and_values.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_label_content.html.erb +11 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_tooltip.html.erb +18 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_value.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview/with_values.html.erb +8 -0
- data/spec/components/previews/sdr_view_components/tables/row_component_preview.rb +21 -0
- data/spec/components/previews/sdr_view_components/tables/table_component_preview.rb +81 -0
- metadata +163 -6
- data/app/assets/stylesheets/styles.scss +0 -118
- data/app/components/component_support/file_hierarchy.rb +0 -22
- data/app/components/sdr_view_components/forms/button_component.rb +0 -42
data/spec/components/previews/sdr_view_components/forms/basic/basic_text_area_component_preview.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
module Basic
|
|
6
|
+
class BasicTextAreaComponentPreview < ViewComponent::Preview
|
|
7
|
+
def default; end
|
|
8
|
+
|
|
9
|
+
# @!group Text Area Options
|
|
10
|
+
def with_rows; end
|
|
11
|
+
|
|
12
|
+
def with_placeholder; end
|
|
13
|
+
|
|
14
|
+
def with_required; end
|
|
15
|
+
# @!endgroup
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/spec/components/previews/sdr_view_components/forms/basic/basic_text_field_component_preview.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
module Basic
|
|
6
|
+
class BasicTextFieldComponentPreview < ViewComponent::Preview
|
|
7
|
+
def default; end
|
|
8
|
+
|
|
9
|
+
# @!group Input Options
|
|
10
|
+
def with_placeholder; end
|
|
11
|
+
|
|
12
|
+
def disabled; end
|
|
13
|
+
|
|
14
|
+
def required; end
|
|
15
|
+
# @!endgroup
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/checked.html.erb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::CheckboxComponentPreview::CheckboxPreviewModel.new(test_boolean_field: false) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::CheckboxComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :test_boolean_field,
|
|
7
|
+
input_checked: true
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/default.html.erb
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::CheckboxComponentPreview::CheckboxPreviewModel.new(test_boolean_field: false) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::CheckboxComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :test_boolean_field
|
|
7
|
+
) %>
|
|
8
|
+
<% end %>
|
data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/disabled.html.erb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::CheckboxComponentPreview::CheckboxPreviewModel.new(test_boolean_field: false) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::CheckboxComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :test_boolean_field,
|
|
7
|
+
input_disabled: true
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::CheckboxComponentPreview::CheckboxPreviewModel.new(test_boolean_field: false) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::CheckboxComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :test_boolean_field
|
|
7
|
+
) do |component| %>
|
|
8
|
+
<% component.with_additional_container_content do %>
|
|
9
|
+
<span class="text-info">Extra info: This is additional container content.</span>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% end %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::CheckboxComponentPreview::CheckboxPreviewModel.new(test_boolean_field: false) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::CheckboxComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :test_boolean_field,
|
|
7
|
+
help_text: 'This help text appears below the checkbox.',
|
|
8
|
+
variant: :help_text_below
|
|
9
|
+
) %>
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::CheckboxComponentPreview::CheckboxPreviewModel.new(test_boolean_field: false) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::CheckboxComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :test_boolean_field,
|
|
7
|
+
label_text: 'I agree to the terms and conditions'
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::CheckboxComponentPreview::CheckboxPreviewModel.new(test_boolean_field: false) %>
|
|
2
|
+
<% model.valid? %>
|
|
3
|
+
|
|
4
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
5
|
+
<%= render SdrViewComponents::Forms::CheckboxComponent.new(
|
|
6
|
+
form: form,
|
|
7
|
+
field_name: :test_boolean_field
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
class CheckboxComponentPreview < ViewComponent::Preview
|
|
6
|
+
def default; end
|
|
7
|
+
|
|
8
|
+
# @!group Checkbox State
|
|
9
|
+
def checked; end
|
|
10
|
+
|
|
11
|
+
def disabled; end
|
|
12
|
+
# @!endgroup
|
|
13
|
+
|
|
14
|
+
def with_label; end
|
|
15
|
+
|
|
16
|
+
# Help text can only be put below a checkbox.
|
|
17
|
+
def with_help_text; end
|
|
18
|
+
|
|
19
|
+
def with_validation_error; end
|
|
20
|
+
|
|
21
|
+
def with_additional_container_content; end
|
|
22
|
+
|
|
23
|
+
class CheckboxPreviewModel
|
|
24
|
+
include ActiveModel::Model
|
|
25
|
+
include ActiveModel::Attributes
|
|
26
|
+
|
|
27
|
+
attribute :test_boolean_field, :boolean, default: false
|
|
28
|
+
|
|
29
|
+
validates :test_boolean_field, acceptance: true
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/spec/components/previews/sdr_view_components/forms/file_component_preview/default.html.erb
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::FileComponentPreview::FilePreviewModel.new(document: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/upload') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::FileComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :file
|
|
7
|
+
) %>
|
|
8
|
+
<% end %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::FileComponentPreview::FilePreviewModel.new(document: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/upload') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::FileComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :file
|
|
7
|
+
) do |component| %>
|
|
8
|
+
<% component.with_additional_container_content do %>
|
|
9
|
+
<div class="alert alert-info mt-2" role="alert">
|
|
10
|
+
<strong>Note:</strong> Accepted file types are PDF, DOC, and DOCX only.
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::FileComponentPreview::FilePreviewModel.new(document: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/upload') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::FileComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :file,
|
|
7
|
+
help_text: 'Select a file to upload. Maximum file size: 10MB.'
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::FileComponentPreview::FilePreviewModel.new(document: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/upload') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::FileComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :file,
|
|
7
|
+
variant: :help_text_below,
|
|
8
|
+
help_text: 'Help text appears below the file input when using help_text_below variant.'
|
|
9
|
+
) %>
|
|
10
|
+
<% end %>
|
data/spec/components/previews/sdr_view_components/forms/file_component_preview/with_label.html.erb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::FileComponentPreview::FilePreviewModel.new(document: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/upload') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::FileComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :document,
|
|
7
|
+
label_text: 'Upload your document'
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::FileComponentPreview::FilePreviewModel.new(document: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/upload') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::FileComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :file,
|
|
7
|
+
input_multiple: true
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::FileComponentPreview::FilePreviewModel.new(document: nil) %>
|
|
2
|
+
<% model.valid? %>
|
|
3
|
+
|
|
4
|
+
<%= form_with(model: model, url: '/upload') do |form| %>
|
|
5
|
+
<%= render SdrViewComponents::Forms::FileComponent.new(
|
|
6
|
+
form: form,
|
|
7
|
+
field_name: :file
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
class FileComponentPreview < ViewComponent::Preview
|
|
6
|
+
def default; end
|
|
7
|
+
|
|
8
|
+
def with_label; end
|
|
9
|
+
|
|
10
|
+
# @!group Help text
|
|
11
|
+
def with_help_text; end
|
|
12
|
+
|
|
13
|
+
def with_help_text_below; end
|
|
14
|
+
# @!endgroup
|
|
15
|
+
|
|
16
|
+
def with_multiple; end
|
|
17
|
+
|
|
18
|
+
def with_additional_container_content; end
|
|
19
|
+
|
|
20
|
+
def with_validation_error; end
|
|
21
|
+
|
|
22
|
+
class FilePreviewModel
|
|
23
|
+
include ActiveModel::Model
|
|
24
|
+
include ActiveModel::Attributes
|
|
25
|
+
|
|
26
|
+
attribute :document, :string, default: nil
|
|
27
|
+
|
|
28
|
+
validates :document, presence: true
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%= form_with(url: '/example', scope: :item) do |form| %>
|
|
2
|
+
<%= render SdrViewComponents::Forms::LabelComponent.new(
|
|
3
|
+
form: form,
|
|
4
|
+
field_name: :title,
|
|
5
|
+
text: 'Collection title',
|
|
6
|
+
tooltip: 'Use the public title shown to repository users.'
|
|
7
|
+
) %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
window.addEventListener('load', () => {
|
|
12
|
+
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
|
|
13
|
+
;[...tooltipTriggerList].forEach((tooltipTriggerEl) => {
|
|
14
|
+
window.bootstrap.Tooltip.getOrCreateInstance(tooltipTriggerEl)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
class LabelComponentPreview < ViewComponent::Preview
|
|
6
|
+
def default; end
|
|
7
|
+
|
|
8
|
+
# @!group Label options
|
|
9
|
+
def hidden_label; end
|
|
10
|
+
|
|
11
|
+
def with_tooltip; end
|
|
12
|
+
|
|
13
|
+
def with_caption; end
|
|
14
|
+
# @!endgroup
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::RadioButtonComponentPreview::RadioButtonPreviewModel.new(delivery_method: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::RadioButtonComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :delivery_method,
|
|
7
|
+
input_value: 'email'
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::RadioButtonComponentPreview::RadioButtonPreviewModel.new(delivery_method: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::RadioButtonComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :delivery_method,
|
|
7
|
+
input_value: 'email',
|
|
8
|
+
label_text: 'Email'
|
|
9
|
+
) do |component| %>
|
|
10
|
+
<% component.with_additional_container_content do %>
|
|
11
|
+
<span class="text-info">Recommended if you want notifications delivered to your inbox.</span>
|
|
12
|
+
<% end %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::RadioButtonComponentPreview::RadioButtonPreviewModel.new(delivery_method: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::RadioButtonComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :delivery_method,
|
|
7
|
+
input_value: 'email',
|
|
8
|
+
help_text: 'Use this option to receive updates by email.'
|
|
9
|
+
) %>
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::RadioButtonComponentPreview::RadioButtonPreviewModel.new(delivery_method: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::RadioButtonComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :delivery_method,
|
|
7
|
+
input_value: 'email',
|
|
8
|
+
variant: :help_text_below,
|
|
9
|
+
help_text: 'Use this option to receive updates by email.'
|
|
10
|
+
) %>
|
|
11
|
+
<% end %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::RadioButtonComponentPreview::RadioButtonPreviewModel.new(delivery_method: nil) %>
|
|
2
|
+
|
|
3
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
4
|
+
<%= render SdrViewComponents::Forms::RadioButtonComponent.new(
|
|
5
|
+
form: form,
|
|
6
|
+
field_name: :delivery_method,
|
|
7
|
+
input_value: 'email',
|
|
8
|
+
label_text: 'Email'
|
|
9
|
+
) %>
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::RadioButtonComponentPreview::RadioButtonPreviewModel.new(delivery_method: nil) %>
|
|
2
|
+
<% model.valid? %>
|
|
3
|
+
|
|
4
|
+
<%= form_with(model: model, url: '/example') do |form| %>
|
|
5
|
+
<%= render SdrViewComponents::Forms::RadioButtonComponent.new(
|
|
6
|
+
form: form,
|
|
7
|
+
field_name: :delivery_method,
|
|
8
|
+
input_value: 'email',
|
|
9
|
+
label_text: 'Email'
|
|
10
|
+
) %>
|
|
11
|
+
<% end %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
class RadioButtonComponentPreview < ViewComponent::Preview
|
|
6
|
+
def default; end
|
|
7
|
+
|
|
8
|
+
def with_label; end
|
|
9
|
+
|
|
10
|
+
# @!group Help text
|
|
11
|
+
def with_help_text; end
|
|
12
|
+
|
|
13
|
+
def with_help_text_below; end
|
|
14
|
+
# @!endgroup
|
|
15
|
+
|
|
16
|
+
def with_additional_container_content; end
|
|
17
|
+
|
|
18
|
+
def with_validation_error; end
|
|
19
|
+
|
|
20
|
+
class RadioButtonPreviewModel
|
|
21
|
+
include ActiveModel::Model
|
|
22
|
+
include ActiveModel::Attributes
|
|
23
|
+
|
|
24
|
+
attribute :delivery_method, :string, default: nil
|
|
25
|
+
|
|
26
|
+
validates :delivery_method, presence: true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%= form_with(url: '/items/123/publish', method: :post, html: { id: 'publish-item-form' }) do |form| %>
|
|
2
|
+
<%= form.hidden_field :item_id, value: '123' %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<%= render SdrViewComponents::Forms::SubmitComponent.new(
|
|
6
|
+
label: 'Publish item',
|
|
7
|
+
form_id: 'publish-item-form'
|
|
8
|
+
) %>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
class SubmitComponentPreview < ViewComponent::Preview
|
|
6
|
+
# @!group Button Variants
|
|
7
|
+
def primary; end
|
|
8
|
+
|
|
9
|
+
def secondary; end
|
|
10
|
+
|
|
11
|
+
def success; end
|
|
12
|
+
|
|
13
|
+
def danger; end
|
|
14
|
+
|
|
15
|
+
def warning; end
|
|
16
|
+
|
|
17
|
+
def info; end
|
|
18
|
+
# @!endgroup
|
|
19
|
+
|
|
20
|
+
# @!group Content Options
|
|
21
|
+
def with_block_content_and_value; end
|
|
22
|
+
# @!endgroup
|
|
23
|
+
|
|
24
|
+
def with_form_id; end
|
|
25
|
+
|
|
26
|
+
def default; end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/spec/components/previews/sdr_view_components/forms/text_area_component_preview/default.html.erb
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
) %>
|
|
8
|
+
<% end %>
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
) do |component| %>
|
|
8
|
+
<% component.with_additional_container_content do %>
|
|
9
|
+
<p>Character limit: 500.</p>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% end %>
|
|
12
|
+
<% 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
|
+
help_text: 'Describe the item in one or two sentences.'
|
|
8
|
+
) %>
|
|
9
|
+
<% end %>
|