Skip to content

Commit

Permalink
Merge branch 'main' into refactor-dialog-to-use-dialog-internally
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus authored Jan 11, 2024
2 parents 67ab782 + fbaea76 commit 1354ec4
Show file tree
Hide file tree
Showing 24 changed files with 111 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/healthy-needles-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Allow setting `test_selector` on select list options
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion lib/primer/forms/dsl/select_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class SelectInput < Input

# :nodoc:
class Option
include Primer::TestSelectorHelper

attr_reader :label, :value, :system_arguments

def initialize(label:, value:, **system_arguments)
@label = label
@value = value
@system_arguments = system_arguments
@system_arguments = add_test_selector(system_arguments)
end
end

Expand Down
34 changes: 34 additions & 0 deletions previews/primer/alpha/dialog_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,40 @@ def body_has_scrollbar_overflow(title: "Test Dialog", subtitle: nil, button_text
def autofocus_element
render_with_template(locals: {})
end

# @label Left Side
#
# @param title [String] text
# @param subtitle [String] text
# @param size [Symbol] select [small, medium, medium_portrait, large, xlarge]
# @param position_narrow [Symbol] select [inherit, bottom, fullscreen, left, right]
# @param visually_hide_title [Boolean] toggle
# @param button_text [String] text
# @param body_text [String] text
# @snapshot interactive
def left_side(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", body_text: "Content", position: :center, position_narrow: :fullscreen, visually_hide_title: false)
render(Primer::Alpha::Dialog.new(title: title, subtitle: subtitle, size: size, position: :left, position_narrow: position_narrow, visually_hide_title: visually_hide_title)) do |d|
d.with_show_button { button_text }
d.with_body { body_text }
end
end

# @label Right Side
#
# @param title [String] text
# @param subtitle [String] text
# @param size [Symbol] select [small, medium, medium_portrait, large, xlarge]
# @param position_narrow [Symbol] select [inherit, bottom, fullscreen, left, right]
# @param visually_hide_title [Boolean] toggle
# @param button_text [String] text
# @param body_text [String] text
# @snapshot interactive
def right_side(title: "Test Dialog", subtitle: nil, size: :medium, button_text: "Show Dialog", body_text: "Content", position: :center, position_narrow: :fullscreen, visually_hide_title: false)
render(Primer::Alpha::Dialog.new(title: title, subtitle: subtitle, size: size, position: :right, position_narrow: position_narrow, visually_hide_title: visually_hide_title)) do |d|
d.with_show_button { button_text }
d.with_body { body_text }
end
end
end
end
end
26 changes: 26 additions & 0 deletions static/info_arch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3330,6 +3330,32 @@
"color-contrast"
]
}
},
{
"preview_path": "primer/alpha/dialog/left_side",
"name": "left_side",
"snapshot": "interactive",
"skip_rules": {
"wont_fix": [
"region"
],
"will_fix": [
"color-contrast"
]
}
},
{
"preview_path": "primer/alpha/dialog/right_side",
"name": "right_side",
"snapshot": "interactive",
"skip_rules": {
"wont_fix": [
"region"
],
"will_fix": [
"color-contrast"
]
}
}
],
"subcomponents": [
Expand Down
26 changes: 26 additions & 0 deletions static/previews.json
Original file line number Diff line number Diff line change
Expand Up @@ -3100,6 +3100,32 @@
"color-contrast"
]
}
},
{
"preview_path": "primer/alpha/dialog/left_side",
"name": "left_side",
"snapshot": "interactive",
"skip_rules": {
"wont_fix": [
"region"
],
"will_fix": [
"color-contrast"
]
}
},
{
"preview_path": "primer/alpha/dialog/right_side",
"name": "right_side",
"snapshot": "interactive",
"skip_rules": {
"wont_fix": [
"region"
],
"will_fix": [
"color-contrast"
]
}
}
]
},
Expand Down
17 changes: 17 additions & 0 deletions test/lib/primer/forms/select_list_input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,21 @@ def test_no_error_markup

refute_selector ".field_with_errors", visible: :all
end

def test_option_includes_test_selector
render_in_view_context do
primer_form_with(url: "/foo") do |f|
render_inline_form(f) do |select_form|
select_form.select_list(name: :foo, label: "Foo", hidden: true) do |list|
list.option(
label: "Foo",
value: "foo",
test_selector: "test-selector-foo",
)
end
end
end
end
assert_selector "[data-test-selector='test-selector-foo']", visible: :hidden
end
end

0 comments on commit 1354ec4

Please sign in to comment.