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.
- checksums.yaml +4 -4
- data/Rakefile +31 -5
- data/app/assets/sdr_view_components.css +9 -1
- data/app/components/sdr_view_components/elements/toast_component.html.erb +4 -8
- data/app/components/sdr_view_components/forms/basic_select_field_component.rb +24 -0
- data/app/components/sdr_view_components/forms/select_field_component.rb +20 -0
- data/app/components/sdr_view_components/forms/toggle_component.html.erb +1 -1
- data/app/components/sdr_view_components/forms/toggle_option_component.html.erb +1 -1
- data/app/components/sdr_view_components/tables/row_component.html.erb +1 -1
- data/app/views/layouts/lookbook.html.erb +1 -2
- data/lib/sdr_view_components/version.rb +1 -1
- 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_select_field_component_preview/default.html.erb +11 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_select_field_component_preview/with_prompt.html.erb +12 -0
- data/spec/components/previews/sdr_view_components/forms/basic/basic_select_field_component_preview.rb +13 -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 +8 -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 +8 -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_disabled_label.html.erb +11 -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 +10 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview.rb +34 -0
- data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/default.html.erb +13 -0
- data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_additional_container_content.html.erb +19 -0
- data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_help_text.html.erb +14 -0
- data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_help_text_below.html.erb +15 -0
- data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_prompt.html.erb +14 -0
- data/spec/components/previews/sdr_view_components/forms/select_field_component_preview/with_validation_error.html.erb +15 -0
- data/spec/components/previews/sdr_view_components/forms/select_field_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 +8 -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 +8 -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 +11 -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 +152 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
class SelectFieldComponentPreview < ViewComponent::Preview
|
|
6
|
+
def default; end
|
|
7
|
+
|
|
8
|
+
def with_prompt; 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 SelectFieldPreviewModel
|
|
21
|
+
include ActiveModel::Model
|
|
22
|
+
include ActiveModel::Attributes
|
|
23
|
+
|
|
24
|
+
attribute :resource_type, :string, default: nil
|
|
25
|
+
|
|
26
|
+
validates :resource_type, 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 %>
|
|
@@ -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,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,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,8 @@
|
|
|
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
|
+
) %>
|
|
8
|
+
<% 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
|
data/spec/components/previews/sdr_view_components/forms/toggle_component_preview/default.html.erb
ADDED
|
@@ -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,11 @@
|
|
|
1
|
+
<% model = SdrViewComponents::Forms::ToggleComponentPreview::TogglePreviewModel.new(audience: nil) %>
|
|
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,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,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,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,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>
|