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 Nov 13, 2023
2 parents c67b503 + e746b03 commit 3c26d94
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 64 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-timers-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': minor
---

Remove touch target gaps between ActionBar items
5 changes: 5 additions & 0 deletions .changeset/soft-singers-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': minor
---

Add missing 64px Avatar size
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.
18 changes: 1 addition & 17 deletions app/components/primer/alpha/action_bar.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.ActionBar {
position: relative;
display: flex !important;
min-width: calc(var(--control-medium-size) * 3);
min-width: calc(var(--control-medium-size) * 3);
align-items: center;
flex-grow: 1;
flex-shrink: 1;
Expand Down Expand Up @@ -51,19 +51,3 @@
.ActionBar--large .ActionBar-divider {
margin: 0 var(--controlStack-large-gap-condensed);
}

/* Increase spacing so touch targets don't overlap */

@media (pointer: coarse) {
.ActionBar .ActionBar-item-container {
gap: calc(var(--control-minTarget-coarse) - var(--control-medium-size)); /* 12px */
}

.ActionBar--small .ActionBar-item-container {
gap: calc(var(--control-minTarget-coarse) - var(--control-small-size)); /* 16px */
}

.ActionBar--large .ActionBar-item-container {
gap: calc(var(--control-minTarget-coarse) - var(--control-large-size)); /* 4px */
}
}
2 changes: 1 addition & 1 deletion app/components/primer/beta/avatar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Avatar < Primer::Component
DEFAULT_SHAPE = :circle
SHAPE_OPTIONS = [DEFAULT_SHAPE, :square].freeze

SIZE_OPTIONS = [16, DEFAULT_SIZE, SMALL_THRESHOLD, 32, 40, 48, 80].freeze
SIZE_OPTIONS = [16, DEFAULT_SIZE, SMALL_THRESHOLD, 32, 40, 48, 64, 80].freeze

# @param src [String] The source url of the avatar image.
# @param alt [String] Passed through to alt on img tag.
Expand Down
6 changes: 6 additions & 0 deletions previews/primer/beta/avatar_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def size_48
render(Primer::Beta::Avatar.new(size: 48, src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser"))
end

# @label 64px
# @snapshot
def size_64
render(Primer::Beta::Avatar.new(size: 64, src: Primer::ExampleImage::BASE64_SRC, alt: "@kittenuser"))
end

# @label 80px
# @snapshot
def size_80
Expand Down
2 changes: 1 addition & 1 deletion static/arguments.json
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@
"name": "size",
"type": "Integer",
"default": "`20`",
"description": "One of `16`, `20`, `24`, `32`, `40`, `48`, or `80`."
"description": "One of `16`, `20`, `24`, `32`, `40`, `48`, `64`, or `80`."
},
{
"name": "shape",
Expand Down
1 change: 1 addition & 0 deletions static/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@
32,
40,
48,
64,
80
],
"SMALL_THRESHOLD": 24
Expand Down
15 changes: 14 additions & 1 deletion static/info_arch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9258,7 +9258,7 @@
"name": "size",
"type": "Integer",
"default": "`20`",
"description": "One of `16`, `20`, `24`, `32`, `40`, `48`, or `80`."
"description": "One of `16`, `20`, `24`, `32`, `40`, `48`, `64`, or `80`."
},
{
"name": "shape",
Expand Down Expand Up @@ -9403,6 +9403,19 @@
]
}
},
{
"preview_path": "primer/beta/avatar/size_64",
"name": "size_64",
"snapshot": "true",
"skip_rules": {
"wont_fix": [
"region"
],
"will_fix": [
"color-contrast"
]
}
},
{
"preview_path": "primer/beta/avatar/size_80",
"name": "size_80",
Expand Down
13 changes: 13 additions & 0 deletions static/previews.json
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,19 @@
]
}
},
{
"preview_path": "primer/beta/avatar/size_64",
"name": "size_64",
"snapshot": "true",
"skip_rules": {
"wont_fix": [
"region"
],
"will_fix": [
"color-contrast"
]
}
},
{
"preview_path": "primer/beta/avatar/size_80",
"name": "size_80",
Expand Down
37 changes: 37 additions & 0 deletions test/components/alpha/action_bar_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,43 @@ module Alpha
class ActionBarTest < Minitest::Test
include Primer::ComponentTestHelpers

def test_renders
render_inline(Primer::Alpha::ActionBar.new) do |component|
component.with_item_icon_button(icon: :pencil, label: "Button 1")
component.with_item_icon_button(icon: :pencil, label: "Button 2")
component.with_item_icon_button(icon: :pencil, label: "Button 3")
component.with_item_icon_button(icon: :pencil, label: "Button 4")
end

assert_selector("action-bar") do
assert_selector("tool-tip", text: "Button 1")
assert_selector("tool-tip", text: "Button 2")
assert_selector("tool-tip", text: "Button 3")
assert_selector("tool-tip", text: "Button 4")
assert_selector("[data-target=\"action-bar.moreMenu\"]", visible: :hidden)
end
end

def test_size_small
render_inline(Primer::Alpha::ActionBar.new(size: :small)) do |component|
component.with_item_icon_button(icon: :pencil, label: "Button 1")
component.with_item_icon_button(icon: :pencil, label: "Button 2")
component.with_item_divider
component.with_item_icon_button(icon: :pencil, label: "Button 3")
component.with_item_icon_button(icon: :pencil, label: "Button 4")
end

assert_selector("[data-targets=\"action-bar.items\"] .Button--small", count: 4)
end

def test_item_merges_item_arguments
render_inline(Primer::Alpha::ActionBar.new(size: :small)) do |component|
component.with_item_icon_button(icon: :pencil, label: "Button 1", item_arguments: { classes: "foo", tag: :span })
end

assert_selector("span.foo.ActionBar-item")
end

def test_renders_action_menu_items_with_type_button
render_preview(:default)

Expand Down
44 changes: 0 additions & 44 deletions test/components/primer/alpha/action_bar_test.rb

This file was deleted.

0 comments on commit 3c26d94

Please sign in to comment.