primer_view_components 0.0.115 → 0.0.116
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_list/divider.rb +0 -2
- data/app/components/primer/alpha/action_list/heading.rb +0 -2
- data/app/components/primer/alpha/action_list/item.rb +0 -2
- data/app/components/primer/alpha/action_list.rb +0 -1
- data/app/components/primer/alpha/auto_complete/item.rb +0 -1
- data/app/components/primer/alpha/auto_complete.rb +8 -9
- data/app/components/primer/alpha/banner.rb +0 -1
- data/app/components/primer/alpha/button_marketing.rb +0 -2
- data/app/components/primer/alpha/dialog.rb +0 -1
- data/app/components/primer/alpha/dropdown/menu.rb +2 -0
- data/app/components/primer/alpha/dropdown.html.erb +3 -3
- data/app/components/primer/alpha/image.rb +0 -1
- data/app/components/primer/alpha/layout.rb +1 -1
- data/app/components/primer/alpha/octicon_symbols.rb +0 -2
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.json +1 -1
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.pcss +12 -0
- data/app/components/primer/alpha/segmented_control.rb +5 -5
- data/app/components/primer/alpha/tab_panels.rb +6 -6
- data/app/components/primer/alpha/text_field.rb +0 -1
- data/app/components/primer/alpha/toggle_switch.rb +6 -8
- data/app/components/primer/alpha/tooltip.rb +0 -2
- data/app/components/primer/alpha/underline_panels.rb +6 -6
- data/app/components/primer/beta/auto_complete/item.rb +1 -0
- data/app/components/primer/beta/auto_complete.rb +12 -10
- data/app/components/primer/beta/avatar.rb +0 -1
- data/app/components/primer/beta/avatar_stack.rb +2 -0
- data/app/components/primer/beta/base_button.rb +0 -1
- data/app/components/primer/beta/blankslate.rb +43 -42
- data/app/components/primer/beta/border_box/header.rb +2 -0
- data/app/components/primer/beta/border_box.rb +2 -0
- data/app/components/primer/beta/breadcrumbs.rb +1 -0
- data/app/components/primer/beta/button.css +1 -1
- data/app/components/primer/beta/button.css.json +1 -1
- data/app/components/primer/beta/button.css.map +1 -1
- data/app/components/primer/beta/button.pcss +5 -0
- data/app/components/primer/beta/button.rb +1 -0
- data/app/components/primer/beta/button_group.rb +3 -0
- data/app/components/primer/beta/clipboard_copy.rb +0 -1
- data/app/components/primer/beta/close_button.rb +0 -1
- data/app/components/primer/beta/counter.rb +0 -1
- data/app/components/primer/beta/details.rb +6 -3
- data/app/components/primer/beta/flash.rb +1 -0
- data/app/components/primer/beta/heading.rb +0 -1
- data/app/components/primer/beta/icon_button.rb +0 -1
- data/app/components/primer/beta/label.rb +0 -1
- data/app/components/primer/beta/link.rb +1 -0
- data/app/components/primer/beta/markdown.rb +0 -1
- data/app/components/primer/beta/octicon.rb +1 -0
- data/app/components/primer/beta/popover.rb +1 -0
- data/app/components/primer/beta/progress_bar.rb +7 -7
- data/app/components/primer/beta/relative_time.rb +0 -1
- data/app/components/primer/beta/spinner.rb +0 -1
- data/app/components/primer/beta/text.rb +0 -1
- data/app/components/primer/beta/truncate.rb +3 -2
- data/app/components/primer/box.rb +0 -1
- data/app/components/primer/button_component.rb +2 -2
- data/app/components/primer/component.rb +1 -0
- data/app/components/primer/conditional_wrapper.rb +0 -2
- data/app/components/primer/dropdown_menu_component.rb +3 -3
- data/app/components/primer/hellip_button.rb +0 -2
- data/app/components/primer/icon_button.rb +0 -1
- data/app/components/primer/layout_component.rb +0 -2
- data/app/components/primer/local_time.rb +0 -1
- data/app/components/primer/octicon_component.rb +0 -1
- data/app/components/primer/state_component.rb +0 -1
- data/app/components/primer/subhead_component.rb +0 -2
- data/app/components/primer/tab_container_component.rb +0 -2
- data/app/components/primer/time_ago_component.rb +0 -1
- data/app/components/primer/timeline_item_component.rb +0 -1
- data/app/components/primer/tooltip.rb +0 -1
- data/app/components/primer/truncate.rb +0 -2
- data/lib/primer/forms/builder.rb +2 -3
- data/lib/primer/forms/dsl/form_reference_input.rb +25 -2
- data/lib/primer/forms/dsl/input.rb +27 -0
- data/lib/primer/forms/form_reference.html.erb +1 -1
- data/lib/primer/forms/form_reference.rb +4 -0
- data/lib/primer/view_components/version.rb +1 -1
- data/previews/primer/alpha/tab_panels_preview.rb +8 -8
- data/previews/primer/beta/details_preview.rb +6 -6
- data/previews/primer/local_time_component_preview.rb +3 -0
- data/previews/primer/time_ago_component_preview.rb +3 -0
- data/previews/primer/url_helpers.rb +2 -2
- metadata +2 -2
@@ -8,8 +8,6 @@ module Primer
|
|
8
8
|
# * This button is displaying a hellip as its content (The three dots character). Therefore a label is needed for screen readers.
|
9
9
|
# * Set the attribute `aria-label` on the system arguments. E.g. `Primer::HellipButton.new("aria-label": "Expand next part")`
|
10
10
|
class HellipButton < Primer::Component
|
11
|
-
warn_on_deprecated_slot_setter
|
12
|
-
|
13
11
|
# @example Default
|
14
12
|
# <%= render(Primer::HellipButton.new("aria-label": "No effect")) %>
|
15
13
|
#
|
@@ -12,7 +12,6 @@ module Primer
|
|
12
12
|
# Either `aria-label` or `aria-description` will be used for the `Tooltip` text, depending on which one is present.
|
13
13
|
# [Learn more about best functional image practices (WAI Images)](https://www.w3.org/WAI/tutorials/images/functional)
|
14
14
|
class IconButton < Primer::Component
|
15
|
-
warn_on_deprecated_slot_setter
|
16
15
|
status :deprecated
|
17
16
|
|
18
17
|
DEFAULT_SCHEME = :default
|
@@ -11,8 +11,6 @@ module Primer
|
|
11
11
|
# The `:heading` slot defaults to rendering a `<div>`. Update the tag to a heading element with the appropriate level to improve page navigation for assistive technologies.
|
12
12
|
# <%= link_to_heading_practices %>
|
13
13
|
class SubheadComponent < Primer::Component
|
14
|
-
warn_on_deprecated_slot_setter
|
15
|
-
|
16
14
|
status :beta
|
17
15
|
|
18
16
|
DEFAULT_HEADING_TAG = :div
|
data/lib/primer/forms/builder.rb
CHANGED
@@ -33,6 +33,8 @@ module Primer
|
|
33
33
|
|
34
34
|
UTILITY_KEYS = Primer::Classify::Utilities::UTILITIES.keys.freeze
|
35
35
|
|
36
|
+
alias primer_fields_for fields_for
|
37
|
+
|
36
38
|
def label(method, text = nil, **options, &block)
|
37
39
|
super(method, text, classify(options).merge(generate_error_markup: false), &block)
|
38
40
|
end
|
@@ -72,9 +74,6 @@ module Primer
|
|
72
74
|
# is expected by Rails/HTML while the second is specific to Primer.
|
73
75
|
# 3. Combines options[:class] and options[:classes] into options[:class]
|
74
76
|
# so the options hash can be easily passed to Rails form builder methods.
|
75
|
-
# 4. Sets generate_error_markup: false, which, in combination with the
|
76
|
-
# monkeypatch at the top of this file, skips rendering any markup around
|
77
|
-
# invalid fields.
|
78
77
|
#
|
79
78
|
def classify(options)
|
80
79
|
options[:classes] = class_names(options.delete(:class), options[:classes])
|
@@ -5,11 +5,34 @@ module Primer
|
|
5
5
|
module Dsl
|
6
6
|
# :nodoc:
|
7
7
|
class FormReferenceInput < Input
|
8
|
-
attr_reader :ref_block, :fields_for_args, :fields_for_kwargs
|
8
|
+
attr_reader :ref_block, :fields_for_args, :fields_for_kwargs, :nested
|
9
|
+
alias nested? nested
|
9
10
|
|
10
|
-
|
11
|
+
# Pass `nested: false` to prevent the referenced form fields from being treated as nested
|
12
|
+
# under the parent form's model. For example, consider these models:
|
13
|
+
|
14
|
+
# class User < ActiveRecord::Base
|
15
|
+
# has_many :addresses
|
16
|
+
# end
|
17
|
+
|
18
|
+
# class Address < ActiveRecord::Base
|
19
|
+
# belongs_to :user
|
20
|
+
# end
|
21
|
+
|
22
|
+
# A sign-up form might include fields from `User` as well as `Address`. Since addresses are
|
23
|
+
# associated with users, it's perfectly natural to accept the address fields as nested
|
24
|
+
# attributes. Rails will name each field accordingly. For example, the `street` field on
|
25
|
+
# `Address` will be named `user[address][street]`.
|
26
|
+
|
27
|
+
# For situations like this where an association exists between two models, the nested
|
28
|
+
# attributes approach works great. However sometimes all you want is to compose two forms
|
29
|
+
# together that aren't connected by an association. In such cases the fields will still
|
30
|
+
# include the name of the parent model, eg. `user[address][street]` instead of what we want,
|
31
|
+
# `address[street]`. To render the form independent of the parent, pass `nested: false`.
|
32
|
+
def initialize(*fields_for_args, builder:, form:, nested: true, **fields_for_kwargs, &block)
|
11
33
|
@fields_for_args = fields_for_args
|
12
34
|
@fields_for_kwargs = fields_for_kwargs
|
35
|
+
@nested = nested
|
13
36
|
@ref_block = block
|
14
37
|
|
15
38
|
super(builder: builder, form: form, **fields_for_kwargs)
|
@@ -43,6 +43,33 @@ module Primer
|
|
43
43
|
@full_width = @input_arguments.delete(:full_width)
|
44
44
|
@size = @input_arguments.delete(:size)
|
45
45
|
|
46
|
+
# If scope_name_to_model is false, the name of the input for eg. `my_field`
|
47
|
+
# will be `my_field` instead of the Rails default of `model[my_field]`.
|
48
|
+
#
|
49
|
+
# We achieve this by passing the `name` option to Rails form builder
|
50
|
+
# methods. These methods will use the passed name if provided instead
|
51
|
+
# of generating a scoped one.
|
52
|
+
#
|
53
|
+
# rubocop:disable Style/IfUnlessModifier
|
54
|
+
unless @input_arguments.delete(:scope_name_to_model) { true }
|
55
|
+
@input_arguments[:name] = name
|
56
|
+
end
|
57
|
+
# rubocop:enable Style/IfUnlessModifier
|
58
|
+
|
59
|
+
# If scope_id_to_model is false, the name of the input for eg. `my_field`
|
60
|
+
# will be `my_field` instead of the Rails default of `model_my_field`.
|
61
|
+
#
|
62
|
+
# We achieve this by passing the `id` option to Rails form builder
|
63
|
+
# methods. These methods will use the passed id if provided instead
|
64
|
+
# of generating a scoped one. The id is the name of the field unless
|
65
|
+
# explicitly provided in system_arguments.
|
66
|
+
#
|
67
|
+
# rubocop:disable Style/IfUnlessModifier
|
68
|
+
unless @input_arguments.delete(:scope_id_to_model) { true }
|
69
|
+
@input_arguments[:id] = @input_arguments.delete(:id) { name }
|
70
|
+
end
|
71
|
+
# rubocop:enable Style/IfUnlessModifier
|
72
|
+
|
46
73
|
# Whether or not to wrap the component in a FormControl, which renders a
|
47
74
|
# label above and validation message beneath the input.
|
48
75
|
@form_control = @input_arguments.delete(:form_control) { true }
|
@@ -9,11 +9,11 @@ module Primer
|
|
9
9
|
# @param number_of_panels [Integer] number
|
10
10
|
# @param align [Symbol] select [left, right]
|
11
11
|
def playground(number_of_panels: 3, align: :left)
|
12
|
-
render(Primer::Alpha::TabPanels.new(label: "label", align: align)) do |
|
12
|
+
render(Primer::Alpha::TabPanels.new(label: "label", align: align)) do |component|
|
13
13
|
Array.new(number_of_panels || 3) do |i|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
component.tab(selected: i.zero?, id: "tab-#{i + 1}") do |tab|
|
15
|
+
tab.with_panel { "Panel #{i + 1}" }
|
16
|
+
tab.with_text { "Tab #{i + 1}" }
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -24,11 +24,11 @@ module Primer
|
|
24
24
|
# @param number_of_panels [Integer] number
|
25
25
|
# @param align [Symbol] select [left, right]
|
26
26
|
def default(number_of_panels: 3, align: :left)
|
27
|
-
render(Primer::Alpha::TabPanels.new(label: "label", align: align)) do |
|
27
|
+
render(Primer::Alpha::TabPanels.new(label: "label", align: align)) do |component|
|
28
28
|
Array.new(number_of_panels || 3) do |i|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
component.tab(selected: i.zero?, id: "tab-#{i + 1}") do |tab|
|
30
|
+
tab.with_panel { "Panel #{i + 1}" }
|
31
|
+
tab.with_text { "Tab #{i + 1}" }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -39,9 +39,9 @@ module Primer
|
|
39
39
|
# @param overlay [Symbol] select [none, default, dark]
|
40
40
|
# @param reset [Boolean] toggle
|
41
41
|
def custom_button(reset: false, overlay: :default)
|
42
|
-
render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |
|
43
|
-
|
44
|
-
|
42
|
+
render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |component|
|
43
|
+
component.with_summary(size: :small, scheme: :primary) { "Click me" }
|
44
|
+
component.with_body { "Body" }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -50,9 +50,9 @@ module Primer
|
|
50
50
|
# @param overlay [Symbol] select [none, default, dark]
|
51
51
|
# @param reset [Boolean] toggle
|
52
52
|
def without_button(reset: false, overlay: :default)
|
53
|
-
render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |
|
54
|
-
|
55
|
-
|
53
|
+
render Primer::Beta::Details.new(reset: reset, overlay: overlay) do |component|
|
54
|
+
component.with_summary(button: false) { "Click me" }
|
55
|
+
component.with_body { "Body" }
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Primer/ComponentNameMigration
|
4
|
+
|
3
5
|
module Primer
|
4
6
|
# @label LocalTime
|
5
7
|
class LocalTimeComponentPreview < ViewComponent::Preview
|
@@ -52,3 +54,4 @@ module Primer
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
57
|
+
# rubocop:enable Primer/ComponentNameMigration
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Primer/ComponentNameMigration
|
4
|
+
|
3
5
|
module Primer
|
4
6
|
# @label TimeAgoComponent
|
5
7
|
class TimeAgoComponentPreview < ViewComponent::Preview
|
@@ -22,3 +24,4 @@ module Primer
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
27
|
+
# rubocop:enable Primer/ComponentNameMigration
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primer_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.116
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|