sdr_view_components 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- 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_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 +139 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b973a9d37ca8cbaf8923757222f1e73ae754a72ca99731008c68d22c7be41f28
|
|
4
|
+
data.tar.gz: 6014055eb861360362ee8527f5f7d2afba60665428720df0e095982af8aa9c46
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ec8945789ecbc351308b32e6f7df8600e8b43d9bfe92ef9bd4013279b69a20a0eeebf5f4ea6cf6fb36946690a5564020e57e268826a145c1a0911d9cd1aad796
|
|
7
|
+
data.tar.gz: d5fe578fc6d4c376408b315536cf97d538dd19c466785e73472266d402663d95150f2ae5e7fe9095989e1c39bac616c88582067282863d893a3eebbfa35e2c1a
|
|
@@ -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
|
data/spec/components/previews/sdr_view_components/elements/breadcrumb_nav_component_preview.rb
ADDED
|
@@ -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
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Elements
|
|
5
|
+
class HeadingComponentPreview < ViewComponent::Preview
|
|
6
|
+
# @!group Heading Levels
|
|
7
|
+
def h1
|
|
8
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h1, text: 'Page title')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def h2
|
|
12
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h2, text: 'Section heading')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def h3
|
|
16
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h3, text: 'Subsection heading')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def h4
|
|
20
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h4, text: 'Supporting heading')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def h5
|
|
24
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h5, text: 'Minor heading')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def h6
|
|
28
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h6, text: 'Eyebrow heading')
|
|
29
|
+
end
|
|
30
|
+
# @!endgroup
|
|
31
|
+
|
|
32
|
+
# @!group Variant Styling
|
|
33
|
+
def h2_with_h1_styling
|
|
34
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h2, text: 'Rendered as h2, styled like h1',
|
|
35
|
+
variant: :h1)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def h3_with_h2_styling
|
|
39
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h3, text: 'Rendered as h3, styled like h2',
|
|
40
|
+
variant: :h2)
|
|
41
|
+
end
|
|
42
|
+
# @!endgroup
|
|
43
|
+
|
|
44
|
+
def with_block_content
|
|
45
|
+
render SdrViewComponents::Elements::HeadingComponent.new(level: :h2) do
|
|
46
|
+
'Heading supplied by block content'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Elements
|
|
5
|
+
class IconButtonComponentPreview < ViewComponent::Preview
|
|
6
|
+
# @!group Icon Buttons
|
|
7
|
+
def delete
|
|
8
|
+
render SdrViewComponents::Elements::IconButtonComponent.new(icon: :delete, label: 'Delete item')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def download
|
|
12
|
+
render SdrViewComponents::Elements::IconButtonComponent.new(icon: :download, label: 'Download file')
|
|
13
|
+
end
|
|
14
|
+
# @!endgroup
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/spec/components/previews/sdr_view_components/elements/icon_button_link_component_preview.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Elements
|
|
5
|
+
class IconButtonLinkComponentPreview < ViewComponent::Preview
|
|
6
|
+
def default
|
|
7
|
+
render SdrViewComponents::Elements::IconButtonLinkComponent.new(
|
|
8
|
+
icon: :download,
|
|
9
|
+
label: 'Download item',
|
|
10
|
+
link: '/example'
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/spec/components/previews/sdr_view_components/elements/modal_component_preview/default.html.erb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#default-modal-preview">
|
|
2
|
+
Open default modal
|
|
3
|
+
</button>
|
|
4
|
+
|
|
5
|
+
<%= render SdrViewComponents::Elements::ModalComponent.new(id: 'default-modal-preview') do |modal| %>
|
|
6
|
+
<% modal.with_body do %>
|
|
7
|
+
<p class="mb-0">Use this modal to review submission details before publishing.</p>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modal-with-header-and-footer-preview">
|
|
2
|
+
Open modal with header and footer
|
|
3
|
+
</button>
|
|
4
|
+
|
|
5
|
+
<%= render SdrViewComponents::Elements::ModalComponent.new(id: 'modal-with-header-and-footer-preview') do |modal| %>
|
|
6
|
+
<% modal.with_header do %>
|
|
7
|
+
<h2 class="h5 mb-0">Publish item</h2>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% modal.with_body do %>
|
|
11
|
+
<p>This item is ready to publish to the repository.</p>
|
|
12
|
+
<p class="mb-0">Review the metadata one final time before continuing.</p>
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
15
|
+
<% modal.with_footer do %>
|
|
16
|
+
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
17
|
+
<button type="button" class="btn btn-primary">Publish</button>
|
|
18
|
+
<% end %>
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#without-size-modal-preview">
|
|
2
|
+
Open modal without size
|
|
3
|
+
</button>
|
|
4
|
+
|
|
5
|
+
<%= render SdrViewComponents::Elements::ModalComponent.new(id: 'without-size-modal-preview', size: nil) do |modal| %>
|
|
6
|
+
<% modal.with_body do %>
|
|
7
|
+
<p class="mb-0">This example renders the modal without an explicit size class.</p>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Elements
|
|
5
|
+
class ModalComponentPreview < ViewComponent::Preview
|
|
6
|
+
# @!group Sizes
|
|
7
|
+
def default; end
|
|
8
|
+
|
|
9
|
+
def without_size; end
|
|
10
|
+
# @!endgroup
|
|
11
|
+
|
|
12
|
+
def with_header_and_footer; end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|