sdr_view_components 0.5.0 → 0.7.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/README.md +34 -0
- data/app/assets/sdr_view_components.css +8 -0
- data/app/components/sdr_view_components/elements/heading_component.rb +3 -2
- data/app/components/sdr_view_components/elements/tabs/tab_list_component.html.erb +16 -4
- data/app/components/sdr_view_components/elements/tabs/tab_list_component.rb +29 -2
- data/app/components/sdr_view_components/forms/fieldset_component.html.erb +17 -0
- data/app/components/sdr_view_components/forms/fieldset_component.rb +43 -0
- data/app/components/sdr_view_components/forms/has_one_component.html.erb +7 -0
- data/app/components/sdr_view_components/forms/has_one_component.rb +30 -0
- data/app/components/sdr_view_components/tab_form/tabbed_form_builder.rb +1 -1
- data/app/javascript/sdr_view_components/tab_select_controller.js +22 -0
- data/lib/sdr_view_components/version.rb +1 -1
- data/spec/components/previews/sdr_view_components/elements/button_link_component_preview.rb +6 -0
- data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/collapsible.html.erb +14 -0
- data/spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview.rb +2 -0
- data/spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_validation_error.html.erb +1 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/default.html.erb +10 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/hidden_label.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/mark_required.html.erb +6 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_help_link.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_help_text.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_legend_slot.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_tooltip.html.erb +9 -0
- data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview.rb +25 -0
- data/spec/components/previews/sdr_view_components/forms/radio_button_component_preview/with_validation_error.html.erb +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20d06b21754a66cf773ed738934dca7b897e95de724e6ca8fc70942f56a8bf1c
|
|
4
|
+
data.tar.gz: 605b5ae6c58e73324e9bdbbac7d53ff6e0ddf9d53b845c75393255d411ef701d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b99a2ffdfb693b1780e6b44b93a51d0ba6ab62e9958336056ccacd59fd5e4b5d063961bcfe55d688d0b5c907ea0fc323872808cdd52743c1dfe44b7ceb676a39
|
|
7
|
+
data.tar.gz: 17849d2bfd15fd3e540ed8a6e0307825c00efbf53143836c2547d10f5a812ac490b71b5ae0cb0007aced34068b68debfe9970449633d8005969018497869ba29
|
data/README.md
CHANGED
|
@@ -65,6 +65,19 @@ application.register("sdr-tab-link", TabLinkController)
|
|
|
65
65
|
application.register("sdr-tab-nav", TabNavController)
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
`SdrViewComponents::Elements::Tabs::TabListComponent`'s `collapse_below` option (see [General usage](#general-usage) below) ships `sdr_view_components/tab_select_controller`, registered as `sdr-tab-select`:
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
pin "sdr_view_components/tab_select_controller", to: "sdr_view_components/tab_select_controller.js"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import { application } from "controllers/application"
|
|
76
|
+
import TabSelectController from "sdr_view_components/tab_select_controller"
|
|
77
|
+
|
|
78
|
+
application.register("sdr-tab-select", TabSelectController)
|
|
79
|
+
```
|
|
80
|
+
|
|
68
81
|
## Usage
|
|
69
82
|
|
|
70
83
|
### Form components
|
|
@@ -112,6 +125,10 @@ Each of the supported components above uses the provided "basic" components:
|
|
|
112
125
|
|
|
113
126
|
At a minimum, each of these components must be provided wih the `form:` and `field_name:` parameters. Additionally, you can provide additional parameters that will be passed to the standard ActionView::Helpers::Tag.
|
|
114
127
|
|
|
128
|
+
#### Fieldset component
|
|
129
|
+
|
|
130
|
+
`SdrViewComponents::Forms::FieldsetComponent` renders a `<fieldset>` for grouping related fields (e.g. a set of checkboxes) that don't belong to a single bound form field. It supports a `label:` (or a `legend` slot for custom markup), `tooltip:`, `mark_required:`, `help_text:`, and a `help_link` slot. Any other keyword arguments (`id:`, `data:`, `aria:`, etc.) are passed through to the `<fieldset>` tag.
|
|
131
|
+
|
|
115
132
|
### Tab form components
|
|
116
133
|
|
|
117
134
|
SdrViewComponents provides components for rendering a tabbed form, where a form's fields are split across tabs rather than shown all at once:
|
|
@@ -151,6 +168,23 @@ See the Lookbook preview for `SdrViewComponents::TabForm::TabListComponent` for
|
|
|
151
168
|
|
|
152
169
|
### General usage:
|
|
153
170
|
|
|
171
|
+
`SdrViewComponents::Elements::Tabs::TabListComponent` accepts a `collapse_below:` option (one of `:sm`, `:md`, `:lg`, `:xl`, `:xxl`). When given, the tabs are replaced with a `<select>` below that Bootstrap breakpoint instead of wrapping or scrolling -- the `<select>` drives the same Bootstrap tab JavaScript as the tabs, so panes switch the same way regardless of which control is visible. Leave it unset (the default) to always render the tabs. This requires the `sdr-tab-select` controller -- see [JavaScript](#javascript) above.
|
|
172
|
+
|
|
173
|
+
```erb
|
|
174
|
+
<%= render SdrViewComponents::Elements::Tabs::TabListComponent.new(variant: :underline, collapse_below: :xl) do |tab_list| %>
|
|
175
|
+
<% tab_list.with_tab(label: 'Details', id: 'details-tab', pane_id: 'details-pane', active: true) %>
|
|
176
|
+
<% tab_list.with_tab(label: 'History', id: 'history-tab', pane_id: 'history-pane') %>
|
|
177
|
+
|
|
178
|
+
<% tab_list.with_pane(id: 'details-pane', tab_id: 'details-tab', active: true) do %>
|
|
179
|
+
<p>Details pane content.</p>
|
|
180
|
+
<% end %>
|
|
181
|
+
|
|
182
|
+
<% tab_list.with_pane(id: 'history-pane', tab_id: 'history-tab') do %>
|
|
183
|
+
<p>History pane content.</p>
|
|
184
|
+
<% end %>
|
|
185
|
+
<% end %>
|
|
186
|
+
```
|
|
187
|
+
|
|
154
188
|
```
|
|
155
189
|
<% render SdrViewComponent::....>
|
|
156
190
|
```
|
|
@@ -4,13 +4,14 @@ module SdrViewComponents
|
|
|
4
4
|
module Elements
|
|
5
5
|
# Applies an h# component with the expected styling.
|
|
6
6
|
class HeadingComponent < BaseComponent
|
|
7
|
-
def initialize(level:, text: nil, variant: nil, classes: [])
|
|
7
|
+
def initialize(level:, text: nil, variant: nil, classes: [], **options)
|
|
8
8
|
raise ArgumentError, 'Invalid level' unless %i[h1 h2 h3 h4 h5 h6].include?(level.to_sym)
|
|
9
9
|
|
|
10
10
|
@level = level
|
|
11
11
|
@variant = variant
|
|
12
12
|
@classes = classes
|
|
13
13
|
@text = text # Provide text or content
|
|
14
|
+
@options = options
|
|
14
15
|
super()
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -22,7 +23,7 @@ module SdrViewComponents
|
|
|
22
23
|
def call
|
|
23
24
|
return unless tag.respond_to?(@level)
|
|
24
25
|
|
|
25
|
-
tag.public_send(@level, class: classes) do
|
|
26
|
+
tag.public_send(@level, class: classes, **@options) do
|
|
26
27
|
@text || content
|
|
27
28
|
end
|
|
28
29
|
end
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
<% if collapse_below? %>
|
|
2
|
+
<div data-controller="sdr-tab-select" data-action="shown.bs.tab->sdr-tab-select#sync">
|
|
3
|
+
<%= tag.select class: select_classes, 'aria-label': 'Select a tab', data: { sdr_tab_select_target: 'select', action: 'sdr-tab-select#change' } do %>
|
|
4
|
+
<% tabs.each do |tab| %><%= tag.option(tab.label, value: tab.id, selected: tab.active?) %><% end %>
|
|
5
|
+
<% end %>
|
|
6
|
+
|
|
7
|
+
<%= tag.ul class: classes, role: 'tablist' do %>
|
|
8
|
+
<% tabs.each do |tab| %><%= tab %><% end %>
|
|
9
|
+
<% end %>
|
|
10
|
+
</div>
|
|
11
|
+
<% else %>
|
|
12
|
+
<%= tag.ul class: classes, role: 'tablist' do %>
|
|
13
|
+
<% tabs.each do |tab| %><%= tab %><% end %>
|
|
14
|
+
<% end %>
|
|
3
15
|
<% end %>
|
|
4
16
|
|
|
5
17
|
<%= header %>
|
|
6
18
|
|
|
7
|
-
|
|
19
|
+
<%= tag.div class: content_classes do %>
|
|
8
20
|
<% panes.each do |pane| %><%= pane %><% end %>
|
|
9
|
-
|
|
21
|
+
<% end %>
|
|
@@ -5,21 +5,48 @@ module SdrViewComponents
|
|
|
5
5
|
module Tabs
|
|
6
6
|
# Component for rendering a list of tabs in a tabbed interface.
|
|
7
7
|
class TabListComponent < BaseComponent
|
|
8
|
+
BREAKPOINTS = %i[sm md lg xl xxl].freeze
|
|
9
|
+
|
|
8
10
|
renders_one :header # optional
|
|
9
11
|
renders_many :tabs, Elements::Tabs::TabComponent
|
|
10
12
|
renders_many :panes, Elements::Tabs::PaneComponent
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
# @param classes [Array<String>, String] additional classes for the tab list.
|
|
15
|
+
# @param content_classes [Array<String>, String] additional classes for the tab content container.
|
|
16
|
+
# @param variant [Symbol] the visual style of the tabs (:default or :underline).
|
|
17
|
+
# @param collapse_below [Symbol, nil] if given, the tabs are replaced with a `<select>`
|
|
18
|
+
# below this Bootstrap breakpoint (one of :sm, :md, :lg, :xl, :xxl). The tabs remain
|
|
19
|
+
# fully functional (the `<select>` drives the same Bootstrap tab JavaScript) -- this
|
|
20
|
+
# only changes how they're presented at narrow viewports. Leave nil (the default) to
|
|
21
|
+
# always render the tabs.
|
|
22
|
+
def initialize(classes: [], content_classes: [], variant: :default, collapse_below: nil)
|
|
13
23
|
@classes = classes
|
|
24
|
+
@content_classes = content_classes
|
|
14
25
|
@variant = variant
|
|
26
|
+
@collapse_below = collapse_below
|
|
15
27
|
|
|
16
28
|
raise ArgumentError, "Invalid variant: #{variant}" unless %i[underline default].include?(variant)
|
|
29
|
+
if collapse_below && BREAKPOINTS.exclude?(collapse_below)
|
|
30
|
+
raise ArgumentError, "Invalid collapse_below: #{collapse_below}"
|
|
31
|
+
end
|
|
17
32
|
|
|
18
33
|
super()
|
|
19
34
|
end
|
|
20
35
|
|
|
36
|
+
def collapse_below?
|
|
37
|
+
@collapse_below.present?
|
|
38
|
+
end
|
|
39
|
+
|
|
21
40
|
def classes
|
|
22
|
-
merge_classes('nav', @classes, variant_classes)
|
|
41
|
+
merge_classes('nav', @classes, variant_classes, collapse_below? ? ['d-none', "d-#{@collapse_below}-flex"] : nil)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def select_classes
|
|
45
|
+
merge_classes('form-select', "d-#{@collapse_below}-none", @classes)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def content_classes
|
|
49
|
+
merge_classes('tab-content', @content_classes)
|
|
23
50
|
end
|
|
24
51
|
|
|
25
52
|
private
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<%= tag.fieldset class: classes, **options do %>
|
|
2
|
+
<% if legend? || label %>
|
|
3
|
+
<%= tag.legend class: legend_classes do %>
|
|
4
|
+
<% if legend? %>
|
|
5
|
+
<%= legend %>
|
|
6
|
+
<% else %>
|
|
7
|
+
<%= tag.label class: label_classes do %><%= label %><% end %>
|
|
8
|
+
<% end %>
|
|
9
|
+
<%= render SdrViewComponents::Elements::TooltipComponent.new(target_label: label, tooltip:) %>
|
|
10
|
+
<%= help_link if help_link? %>
|
|
11
|
+
<% if help_text.present? %>
|
|
12
|
+
<p class="mb-2"><%= help_text %></p>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
|
15
|
+
<% end %>
|
|
16
|
+
<%= content %>
|
|
17
|
+
<% end %>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
# Component for rendering a form fieldset.
|
|
6
|
+
class FieldsetComponent < BaseComponent
|
|
7
|
+
renders_one :legend # Provide legend or label
|
|
8
|
+
renders_one :help_link # Optional
|
|
9
|
+
|
|
10
|
+
def initialize(label: nil, hidden_label: false, classes: [], label_classes: [], legend_classes: [], # rubocop:disable Metrics/ParameterLists
|
|
11
|
+
tooltip: nil, mark_required: false, help_text: nil, **options)
|
|
12
|
+
@label = label
|
|
13
|
+
@hidden_label = hidden_label
|
|
14
|
+
@classes = classes
|
|
15
|
+
@label_classes = label_classes
|
|
16
|
+
@legend_classes = legend_classes
|
|
17
|
+
@tooltip = tooltip
|
|
18
|
+
@options = options
|
|
19
|
+
@mark_required = mark_required
|
|
20
|
+
@help_text = help_text
|
|
21
|
+
super()
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
attr_reader :options, :tooltip, :mark_required, :help_text
|
|
25
|
+
|
|
26
|
+
def label_classes
|
|
27
|
+
merge_classes(@label_classes, @hidden_label ? 'visually-hidden' : 'form-label fw-bold')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def label
|
|
31
|
+
mark_label_required(label: @label, mark_required:) if @label.present?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def classes
|
|
35
|
+
merge_classes('form-fieldset', @classes)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def legend_classes
|
|
39
|
+
merge_classes(@legend_classes)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new(**fieldset_args) do %>
|
|
2
|
+
<%= tag.div class: 'mb-3' do %>
|
|
3
|
+
<%= form.fields_for field_name do |nested_form| %>
|
|
4
|
+
<%= render form_component.new(form: nested_form, **form_component_args) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% end %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
# Encapsulates a has_one (non-repeatable) form.
|
|
6
|
+
class HasOneComponent < BaseComponent
|
|
7
|
+
def initialize(form:, field_name:, form_component:, **args)
|
|
8
|
+
@form = form
|
|
9
|
+
@field_name = field_name
|
|
10
|
+
@form_component = form_component
|
|
11
|
+
@args = args
|
|
12
|
+
super()
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
attr_reader :form, :field_name, :form_component, :args
|
|
16
|
+
|
|
17
|
+
# Returns a hash of arguments for the fieldset component.
|
|
18
|
+
# Includes argument prefixed with 'fieldset_'.
|
|
19
|
+
def fieldset_args
|
|
20
|
+
args_for(args:, prefix: 'fieldset_')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Returns a hash of arguments for the form component.
|
|
24
|
+
# Includes argument prefixed with 'form_'.
|
|
25
|
+
def form_component_args
|
|
26
|
+
args_for(args:, prefix: 'form_')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -14,7 +14,7 @@ module SdrViewComponents
|
|
|
14
14
|
# created via `fields_for`, by falling back to the parent builder's `id`. Rails' `fields_for`
|
|
15
15
|
# doesn't otherwise propagate the `html: { id: }` option to nested builders.
|
|
16
16
|
class TabbedFormBuilder < ActionView::Helpers::FormBuilder
|
|
17
|
-
FIELD_METHODS = %i[text_field email_field textarea text_area hidden_field file_field radio_button
|
|
17
|
+
FIELD_METHODS = %i[text_field email_field textarea text_area hidden_field file_field radio_button check_box
|
|
18
18
|
date_field].freeze
|
|
19
19
|
|
|
20
20
|
FIELD_METHODS.each do |field_method|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
|
2
|
+
|
|
3
|
+
// Drives a <select> that stands in for a tab list on narrow viewports (see
|
|
4
|
+
// TabListComponent's `collapse_below` option). Selecting an option shows the
|
|
5
|
+
// corresponding tab; activating a tab some other way (e.g. clicking the tab
|
|
6
|
+
// list above the collapse breakpoint) keeps the select's value in sync.
|
|
7
|
+
//
|
|
8
|
+
// Uses window.bootstrap rather than `import * as bootstrap from 'bootstrap'`:
|
|
9
|
+
// the UMD bootstrap.bundle.min.js has no ES module exports, so an ESM import
|
|
10
|
+
// of it resolves to an empty namespace object even though the script itself
|
|
11
|
+
// still assigns the real API to window.bootstrap as a side effect.
|
|
12
|
+
export default class extends Controller {
|
|
13
|
+
static targets = ['select']
|
|
14
|
+
|
|
15
|
+
change (event) {
|
|
16
|
+
window.bootstrap.Tab.getOrCreateInstance(document.getElementById(event.target.value)).show()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
sync (event) {
|
|
20
|
+
this.selectTarget.value = event.target.id
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -33,6 +33,12 @@ module SdrViewComponents
|
|
|
33
33
|
render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Info Link Button',
|
|
34
34
|
variant: :info)
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
def nil
|
|
38
|
+
render SdrViewComponents::Elements::ButtonLinkComponent.new(link: '/example', label: 'Nil Variant Link Button',
|
|
39
|
+
variant: nil)
|
|
40
|
+
end
|
|
41
|
+
|
|
36
42
|
# @!endgroup
|
|
37
43
|
|
|
38
44
|
# @!group Button Sizes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%# Resize the preview frame below the sm breakpoint to see the tabs collapse into a select. %>
|
|
2
|
+
<%# The sdr-tab-select controller isn't registered in this dummy app, so the select won't switch panes here -- see the consuming app for a working example. %>
|
|
3
|
+
<%= render SdrViewComponents::Elements::Tabs::TabListComponent.new(variant: :underline, collapse_below: :sm) do |tab_list| %>
|
|
4
|
+
<% tab_list.with_tab(label: 'Details', id: 'details-tab', pane_id: 'details-pane', active: true) %>
|
|
5
|
+
<% tab_list.with_tab(label: 'History', id: 'history-tab', pane_id: 'history-pane') %>
|
|
6
|
+
|
|
7
|
+
<% tab_list.with_pane(id: 'details-pane', tab_id: 'details-tab', active: true) do %>
|
|
8
|
+
<p>Details pane content.</p>
|
|
9
|
+
<% end %>
|
|
10
|
+
|
|
11
|
+
<% tab_list.with_pane(id: 'history-pane', tab_id: 'history-tab') do %>
|
|
12
|
+
<p>History pane content.</p>
|
|
13
|
+
<% end %>
|
|
14
|
+
<% end %>
|
data/spec/components/previews/sdr_view_components/forms/fieldset_component_preview/default.html.erb
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new(label: 'Contributors') do %>
|
|
2
|
+
<div class="form-check">
|
|
3
|
+
<input class="form-check-input" type="checkbox" id="contributor1" name="contributor1">
|
|
4
|
+
<label class="form-check-label" for="contributor1">Jane Stanford</label>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="form-check">
|
|
7
|
+
<input class="form-check-input" type="checkbox" id="contributor2" name="contributor2">
|
|
8
|
+
<label class="form-check-label" for="contributor2">Leland Stanford</label>
|
|
9
|
+
</div>
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new(label: 'Contributors', hidden_label: true) do %>
|
|
2
|
+
<div class="form-check">
|
|
3
|
+
<input class="form-check-input" type="checkbox" id="contributor1" name="contributor1">
|
|
4
|
+
<label class="form-check-label" for="contributor1">Jane Stanford</label>
|
|
5
|
+
</div>
|
|
6
|
+
<% end %>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new(label: 'Contributors', mark_required: true) do %>
|
|
2
|
+
<div class="form-check">
|
|
3
|
+
<input class="form-check-input" type="checkbox" id="contributor1" name="contributor1">
|
|
4
|
+
<label class="form-check-label" for="contributor1">Jane Stanford</label>
|
|
5
|
+
</div>
|
|
6
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new(label: 'Contributors') do |component| %>
|
|
2
|
+
<% component.with_help_link do %>
|
|
3
|
+
<a href="#" class="ms-2">What is a contributor?</a>
|
|
4
|
+
<% end %>
|
|
5
|
+
<div class="form-check">
|
|
6
|
+
<input class="form-check-input" type="checkbox" id="contributor1" name="contributor1">
|
|
7
|
+
<label class="form-check-label" for="contributor1">Jane Stanford</label>
|
|
8
|
+
</div>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new(
|
|
2
|
+
label: 'Contributors',
|
|
3
|
+
help_text: 'Add every contributor who created this resource.'
|
|
4
|
+
) do %>
|
|
5
|
+
<div class="form-check">
|
|
6
|
+
<input class="form-check-input" type="checkbox" id="contributor1" name="contributor1">
|
|
7
|
+
<label class="form-check-label" for="contributor1">Jane Stanford</label>
|
|
8
|
+
</div>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new do |component| %>
|
|
2
|
+
<% component.with_legend do %>
|
|
3
|
+
<span class="form-label fw-bold">Contributors <em>(custom legend markup)</em></span>
|
|
4
|
+
<% end %>
|
|
5
|
+
<div class="form-check">
|
|
6
|
+
<input class="form-check-input" type="checkbox" id="contributor1" name="contributor1">
|
|
7
|
+
<label class="form-check-label" for="contributor1">Jane Stanford</label>
|
|
8
|
+
</div>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%= render SdrViewComponents::Forms::FieldsetComponent.new(
|
|
2
|
+
label: 'Contributors',
|
|
3
|
+
tooltip: 'Select every contributor who created this resource.'
|
|
4
|
+
) do %>
|
|
5
|
+
<div class="form-check">
|
|
6
|
+
<input class="form-check-input" type="checkbox" id="contributor1" name="contributor1">
|
|
7
|
+
<label class="form-check-label" for="contributor1">Jane Stanford</label>
|
|
8
|
+
</div>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SdrViewComponents
|
|
4
|
+
module Forms
|
|
5
|
+
class FieldsetComponentPreview < ViewComponent::Preview
|
|
6
|
+
def default; end
|
|
7
|
+
|
|
8
|
+
# @!group Label options
|
|
9
|
+
def hidden_label; end
|
|
10
|
+
|
|
11
|
+
def mark_required; end
|
|
12
|
+
|
|
13
|
+
def with_tooltip; end
|
|
14
|
+
|
|
15
|
+
def with_legend_slot; end
|
|
16
|
+
# @!endgroup
|
|
17
|
+
|
|
18
|
+
# @!group Help
|
|
19
|
+
def with_help_text; end
|
|
20
|
+
|
|
21
|
+
def with_help_link; end
|
|
22
|
+
# @!endgroup
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sdr_view_components
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aaron Collier
|
|
@@ -117,7 +117,11 @@ files:
|
|
|
117
117
|
- app/components/sdr_view_components/forms/checkbox_component.rb
|
|
118
118
|
- app/components/sdr_view_components/forms/field_component.html.erb
|
|
119
119
|
- app/components/sdr_view_components/forms/field_component.rb
|
|
120
|
+
- app/components/sdr_view_components/forms/fieldset_component.html.erb
|
|
121
|
+
- app/components/sdr_view_components/forms/fieldset_component.rb
|
|
120
122
|
- app/components/sdr_view_components/forms/file_component.rb
|
|
123
|
+
- app/components/sdr_view_components/forms/has_one_component.html.erb
|
|
124
|
+
- app/components/sdr_view_components/forms/has_one_component.rb
|
|
121
125
|
- app/components/sdr_view_components/forms/help_text_component.html.erb
|
|
122
126
|
- app/components/sdr_view_components/forms/help_text_component.rb
|
|
123
127
|
- app/components/sdr_view_components/forms/invalid_feedback_component.rb
|
|
@@ -170,6 +174,7 @@ files:
|
|
|
170
174
|
- app/javascript/sdr_view_components/tab_error_controller.js
|
|
171
175
|
- app/javascript/sdr_view_components/tab_link_controller.js
|
|
172
176
|
- app/javascript/sdr_view_components/tab_nav_controller.js
|
|
177
|
+
- app/javascript/sdr_view_components/tab_select_controller.js
|
|
173
178
|
- app/javascript/sdr_view_components/toast_controller.js
|
|
174
179
|
- app/views/layouts/lookbook.html.erb
|
|
175
180
|
- config/routes.rb
|
|
@@ -199,6 +204,7 @@ files:
|
|
|
199
204
|
- spec/components/previews/sdr_view_components/elements/progress_bar_component_preview.rb
|
|
200
205
|
- spec/components/previews/sdr_view_components/elements/spinner_component_preview.rb
|
|
201
206
|
- spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview.rb
|
|
207
|
+
- spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/collapsible.html.erb
|
|
202
208
|
- spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/default_variant.html.erb
|
|
203
209
|
- spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/underline_variant.html.erb
|
|
204
210
|
- spec/components/previews/sdr_view_components/elements/tabs/tab_list_component_preview/with_header.html.erb
|
|
@@ -240,6 +246,14 @@ files:
|
|
|
240
246
|
- spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_help_text.html.erb
|
|
241
247
|
- spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_label.html.erb
|
|
242
248
|
- spec/components/previews/sdr_view_components/forms/checkbox_component_preview/with_validation_error.html.erb
|
|
249
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview.rb
|
|
250
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview/default.html.erb
|
|
251
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview/hidden_label.html.erb
|
|
252
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview/mark_required.html.erb
|
|
253
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_help_link.html.erb
|
|
254
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_help_text.html.erb
|
|
255
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_legend_slot.html.erb
|
|
256
|
+
- spec/components/previews/sdr_view_components/forms/fieldset_component_preview/with_tooltip.html.erb
|
|
243
257
|
- spec/components/previews/sdr_view_components/forms/file_component_preview.rb
|
|
244
258
|
- spec/components/previews/sdr_view_components/forms/file_component_preview/default.html.erb
|
|
245
259
|
- spec/components/previews/sdr_view_components/forms/file_component_preview/with_additional_container_content.html.erb
|