-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ButtonGroup
to use Beta::Button
#2013
Merged
Merged
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
559ec62
basic button group
langermank 4e386c3
setup preview for action menu
langermank 3a94421
Generating component snapshots
langermank 570fad2
cleanup preview
langermank 126253f
fix tests
langermank 37f88a4
Merge branch 'main' into button-group-beta-button
langermank 5c2dd06
Create forty-jokes-punch.md
langermank e5754db
rename CSS file
langermank 3998737
fix selector
langermank 9b9bc43
fix import
langermank 171b206
Generating component snapshots
langermank 9d71fce
Update previews/primer/beta/button_group_preview/action_menus.html.erb
langermank 41de5e6
format
langermank 7467a33
tests
langermank 8e7c78b
Merge branch 'main' into button-group-beta-button
langermank 268642c
fix tests
langermank 2c86bb8
fetch or fallback
langermank da073e3
nevermind jon says
langermank 70efe82
add new test
langermank 4935179
fix test?
langermank 0afa94b
Merge branch 'main' into button-group-beta-button
langermank File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/view-components": patch | ||
--- | ||
|
||
Update `ButtonGroup` to use `Beta::Button` |
Binary file modified
BIN
-1.26 KB
(73%)
...ht/screenshots/snapshots.test.ts-snapshots/primer/beta/button_group/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.26 KB
(73%)
...ht/screenshots/snapshots.test.ts-snapshots/primer/beta/button_group/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.ButtonGroup { | ||
display: inline-flex; | ||
|
||
& button { | ||
margin-inline-end: -1px; | ||
position: relative; | ||
border-radius: 0; | ||
|
||
&:focus, | ||
&:active, | ||
&:hover { | ||
z-index: 1; | ||
} | ||
} | ||
|
||
& > :first-child, | ||
& > :first-child.Button-withTooltip button { | ||
border-top-left-radius: var(--borderRadius-medium, 6px); | ||
border-bottom-left-radius: var(--borderRadius-medium, 6px); | ||
} | ||
|
||
& > :last-child, | ||
& > :last-child.Button-withTooltip button { | ||
border-top-right-radius: var(--borderRadius-medium, 6px); | ||
border-bottom-right-radius: var(--borderRadius-medium, 6px); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
previews/primer/beta/button_group_preview/action_menus.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%= render(Primer::Beta::ButtonGroup.new) do |component| %> | ||
<% component.with_button() { "Main menu" } %> | ||
<% component.with_button(icon: "triangle-down", "aria-label": "secondary menu", data: { "menu-id": "my-id" }) %> | ||
<% end %> | ||
|
||
<%= render(Primer::Alpha::ActionMenu.new(anchor_align: :end, menu_id: "my-id")) do |component| %> | ||
<% component.with_item(label: "Item", tag: :button, value: "") %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,14 @@ class PrimerBetaButtonGroupTest < Minitest::Test | |
def test_does_not_render_without_buttons | ||
render_inline(Primer::Beta::ButtonGroup.new) | ||
|
||
refute_selector("div.BtnGroup") | ||
refute_selector("div.ButtonGroup") | ||
end | ||
|
||
def test_renders_button_items | ||
render_inline(Primer::Beta::ButtonGroup.new) { |component| component.with_button { "Button" } } | ||
|
||
assert_selector("div.BtnGroup") do | ||
assert_selector("button.btn.BtnGroup-item", text: "Button") | ||
assert_selector("div.ButtonGroup") do | ||
assert_selector("button.Button--secondary.Button", text: "Button") | ||
end | ||
end | ||
|
||
|
@@ -24,16 +24,14 @@ def test_renders_button_with_props | |
component.with_button { "Button" } | ||
component.with_button(scheme: :primary) { "Primary" } | ||
component.with_button(scheme: :danger) { "Danger" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You'll need to pass the scheme to ButtonGroup now |
||
component.with_button(scheme: :outline) { "Outline" } | ||
component.with_button(classes: "custom-class") { "Custom class" } | ||
end | ||
|
||
assert_selector("div.BtnGroup") do | ||
assert_selector("button.btn.BtnGroup-item", text: "Button") | ||
assert_selector("button.btn.BtnGroup-item.btn-primary", text: "Primary") | ||
assert_selector("button.btn.BtnGroup-item.btn-danger", text: "Danger") | ||
assert_selector("button.btn.BtnGroup-item.btn-outline", text: "Outline") | ||
assert_selector("button.btn.BtnGroup-item.custom-class", text: "Custom class") | ||
assert_selector("div.ButtonGroup") do | ||
assert_selector("button.Button--secondary.Button", text: "Button") | ||
assert_selector("button.Button--primary.Button", text: "Primary") | ||
assert_selector("button.Button--danger.Button", text: "Danger") | ||
assert_selector("button.custom-class", text: "Custom class") | ||
end | ||
end | ||
|
||
|
@@ -46,20 +44,24 @@ def test_does_not_render_content | |
def test_all_buttons_with_same_size | ||
render_inline(Primer::Beta::ButtonGroup.new(size: :small)) do |component| | ||
component.with_button(size: :medium) { "Medium" } | ||
component.with_button(size: :large) { "Large" } | ||
end | ||
|
||
assert_selector("div.BtnGroup") do | ||
assert_selector("button.btn.BtnGroup-item.btn-sm", text: "Medium") | ||
assert_selector("div.ButtonGroup") do | ||
assert_selector("button.Button-small.Button", text: "Medium") | ||
assert_selector("button.Button-small.Button", text: "Large") | ||
end | ||
end | ||
|
||
def test_all_buttons_with_same_variant | ||
render_inline(Primer::Beta::ButtonGroup.new(variant: :small)) do |component| | ||
component.with_button(size: :medium) { "Medium" } | ||
def test_all_buttons_with_same_scheme | ||
render_inline(Primer::Beta::ButtonGroup.new(scheme: :primary)) do |component| | ||
component.with_button(scheme: :primary) { "Primary" } | ||
component.with_button(scheme: :danger) { "Danger" } | ||
end | ||
|
||
assert_selector("div.BtnGroup") do | ||
assert_selector("button.btn.BtnGroup-item.btn-sm", text: "Medium") | ||
assert_selector("div.ButtonGroup") do | ||
assert_selector("button.Button--primary.Button", text: "Primary") | ||
assert_selector("button.Button--primary.Button", text: "Danger") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to use fetch or fallback here and the Button scheme and size optionsJust thinking out loud maybe not since the button will take care of that anyway. Never mind