Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f66d829
generate the component
jonrohan Aug 23, 2022
1481fc4
docs: build docs
actions-user Aug 23, 2022
58eea81
Updating action bar
jonrohan Aug 26, 2022
78e771f
Merge remote-tracking branch 'origin/main' into action_bar
jonrohan Aug 26, 2022
438341c
docs: build docs
actions-user Aug 26, 2022
bf63bbb
Add ActionBar styles
simurai Aug 26, 2022
6bbb4f2
Add vertical direction
simurai Aug 26, 2022
b4e1624
Add density option
simurai Aug 26, 2022
17d8bf5
Updating resize behaivor
jonrohan Aug 26, 2022
2cfa9d3
Add size option
simurai Aug 29, 2022
57fbaa9
Updating to latest primer/behaviors
jonrohan Aug 29, 2022
dd740e9
Adding comment box preview
jonrohan Aug 29, 2022
39eaab6
When all items are hidden make sure they get reshown
jonrohan Aug 29, 2022
10495ba
Don't set hidden on undefined elements
jonrohan Aug 29, 2022
d5ee951
Move to Experimental module
jonrohan Aug 29, 2022
9d4e313
Move comment box to a pattern folder
jonrohan Aug 29, 2022
8e3d312
Adding label
jonrohan Aug 29, 2022
17a1cad
Fixing lint issues
jonrohan Aug 29, 2022
1c1bc87
Remove experimental from docs
jonrohan Aug 29, 2022
21fdee9
docs: build docs
actions-user Aug 29, 2022
8eb3721
Updating to use resizeobserver
jonrohan Aug 29, 2022
f9abf1b
Adding container options for comment box
jonrohan Aug 29, 2022
4b726f6
Moving test
jonrohan Aug 29, 2022
610eda2
disable error for private variable
jonrohan Aug 29, 2022
f5ef4c9
Ignore experimental paths
jonrohan Aug 29, 2022
630f71c
Remove direction
simurai Aug 30, 2022
50c411a
Updating js behavior
jonrohan Aug 30, 2022
c5de64d
Fix jittering
jonrohan Aug 30, 2022
741b4c4
Add touch support
simurai Aug 30, 2022
25d5f8c
Merge branch 'action_bar' of https://github.com/primer/view_component…
simurai Aug 30, 2022
a730501
docs: build docs
actions-user Aug 30, 2022
f73a64c
Hide menu when button is hidden
jonrohan Aug 30, 2022
095f450
Focus on initial in case no hiding is needed
jonrohan Aug 30, 2022
ccbf710
Merge branch 'main' into action_bar
jonrohan Aug 31, 2022
0452d1f
Use Primer::Beta::IconButton instead 🎉
jonrohan Aug 31, 2022
96b550f
Setting the menu icon button to new button also
jonrohan Aug 31, 2022
fd4e89f
Adjustments for sizing
jonrohan Aug 31, 2022
decfc87
docs: build docs
actions-user Aug 31, 2022
0cda2da
Increase touch target
simurai Aug 31, 2022
6966ab5
docs: build docs
actions-user Aug 31, 2022
ff1ceb5
Move touch target styles to .Button--iconOnly
simurai Aug 31, 2022
5b16bdb
Merge branch 'action_bar' of https://github.com/primer/view_component…
simurai Aug 31, 2022
da1c090
Remove debug bg
simurai Aug 31, 2022
5a3af76
Simplifying Item class
jonrohan Aug 31, 2022
40da716
docs: build docs
actions-user Aug 31, 2022
2d79268
Updating render test
jonrohan Aug 31, 2022
2667469
Merge branch 'main' into action_bar
jonrohan Aug 31, 2022
19a40aa
Experimental also
jonrohan Aug 31, 2022
7232408
docs: build docs
actions-user Aug 31, 2022
fc4f724
Create cold-coins-tease.md
jonrohan Sep 2, 2022
af2cacb
Merge branch 'main' into action_bar
jonrohan Sep 6, 2022
cb1e5d5
Rename web component file to match component name
jonrohan Sep 6, 2022
fcf182c
Remove from nav
jonrohan Sep 7, 2022
2715c38
Renaming to action-bar-menu
jonrohan Sep 7, 2022
d1642f4
Setting important since this is on a catalyst component
jonrohan Sep 7, 2022
d49401c
Use `controlStack-[size]-gap`
simurai Sep 7, 2022
4404db3
Lint
simurai Sep 7, 2022
472c8bf
Update calc of touch target gap
simurai Sep 7, 2022
78126c9
Updating eslint config for naming
jonrohan Sep 7, 2022
fa8a568
Merge branch 'main' into action_bar
jonrohan Sep 7, 2022
71616ab
Merge branch 'main' into action_bar
jonrohan Sep 8, 2022
a1155f7
Fixes lint?
jonrohan Sep 8, 2022
93171bc
npm ci
jonrohan Sep 8, 2022
08731aa
Merge branch 'main' into action_bar
jonrohan Sep 8, 2022
f2e66ba
Merge branch 'main' into action_bar
jonrohan Sep 8, 2022
798e642
Merge branch 'main' into action_bar
jonrohan Sep 8, 2022
1335976
Allow tag to be passed in
jonrohan Sep 8, 2022
8a33425
passing menu arguments
jonrohan Sep 14, 2022
68f5e97
Merge remote-tracking branch 'origin/main' into action_bar
jonrohan Sep 15, 2022
b9e71f5
Merge remote-tracking branch 'origin/main' into action_bar
jonrohan Sep 16, 2022
ecd2c49
Fix the import
jonrohan Sep 16, 2022
782ee31
Separate run for slow tests (#1378)
jonrohan Sep 16, 2022
9bc7e64
Run axe scanner on written previews in test/previews (#1377)
jonrohan Sep 16, 2022
53e8bef
Run deprecated job as a test instead of ci job (#1379)
jonrohan Sep 16, 2022
49a4c55
switching to left align
jonrohan Sep 16, 2022
9f611c0
Merge branch 'main' into action_bar
jonrohan Sep 16, 2022
cbb61a9
Give icon_button a wrapper argument
jonrohan Sep 16, 2022
fc287a3
Improve the overflow
jonrohan Sep 16, 2022
8d55fe5
docs: build docs
actions-user Sep 16, 2022
cc24a2c
Hardcode size for now
jonrohan Sep 16, 2022
f6f7462
responsive fix
jonrohan Sep 17, 2022
2244621
Fixing comment header
jonrohan Sep 20, 2022
2ae6e2c
Merge remote-tracking branch 'origin/main' into action_bar
jonrohan Sep 20, 2022
40aaaa1
change to c
jonrohan Sep 20, 2022
419ecda
adjust naming
jonrohan Sep 20, 2022
9904c39
remove button selector
jonrohan Sep 20, 2022
fa08dff
Use offsetWidth
jonrohan Sep 20, 2022
f27eb9b
Try setting local variable
jonrohan Sep 20, 2022
eef9dee
Merge branch 'main' into action_bar
jonrohan Sep 30, 2022
db09b2c
docs: build docs
actions-user Sep 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-coins-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/view-components": patch
---

Primer::Experimental::ActionBar component
4 changes: 2 additions & 2 deletions app/components/primer/alpha/tab_nav.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class TabNav < Primer::Component
# Renders extra content to the `TabNav`. This will be rendered after the tabs.
#
# @param align [Symbol] <%= one_of(Primer::Alpha::TabNav::EXTRA_ALIGN_OPTIONS) %>
renders_one :extra, lambda { |align: EXTRA_ALIGN_DEFAULT, &block|
@align = fetch_or_fallback(EXTRA_ALIGN_OPTIONS, align, EXTRA_ALIGN_DEFAULT)
renders_one :extra, lambda { |align: Primer::TabNavHelper::EXTRA_ALIGN_DEFAULT, &block|
@align = fetch_or_fallback(Primer::TabNavHelper::EXTRA_ALIGN_OPTIONS, align, Primer::TabNavHelper::EXTRA_ALIGN_DEFAULT)

view_context.capture { block&.call }
}
Expand Down
5 changes: 3 additions & 2 deletions app/components/primer/alpha/tab_panels.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<%= tab_container_wrapper(with_panel: true, **@wrapper_arguments) do %>
<% align = @align %>
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
<%= extra if @align == :left %>
<%= extra if align == :left %>
<%= render Primer::BaseComponent.new(**@body_arguments) do %>
<% tabs.each do |tab| %>
<%= tab %>
<% end %>
<% end %>
<%= extra if @align == :right %>
<%= extra if align == :right %>
<% end %>
<% tabs.each do |tab| %>
<%= tab.panel %>
Expand Down
4 changes: 2 additions & 2 deletions app/components/primer/alpha/tab_panels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class TabPanels < Primer::Component
# Renders extra content to the `TabPanels`. This will be rendered after the tabs.
#
# @param align [Symbol] <%= one_of(Primer::Alpha::TabNav::EXTRA_ALIGN_OPTIONS) %>
renders_one :extra, lambda { |align: EXTRA_ALIGN_DEFAULT, &block|
@align = fetch_or_fallback(EXTRA_ALIGN_OPTIONS, align, EXTRA_ALIGN_DEFAULT)
renders_one :extra, lambda { |align: Primer::TabNavHelper::EXTRA_ALIGN_DEFAULT, &block|
@align = fetch_or_fallback(Primer::TabNavHelper::EXTRA_ALIGN_OPTIONS, align, Primer::TabNavHelper::EXTRA_ALIGN_DEFAULT)

view_context.capture { block&.call }
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/primer/beta/base_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(
**system_arguments
)
@system_arguments = system_arguments
@system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
@system_arguments[:tag] = tag

@system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE) if @system_arguments[:tag] == :button

Expand Down
9 changes: 9 additions & 0 deletions app/components/primer/beta/button.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,13 @@ summary.Button {
&.Button--large {
width: var(--primer-control-large-size, 40px);
}

/* Increase touch target */
Copy link
Contributor

@simurai simurai Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This increases the touch target for .Button--iconOnly to 44x44px. There is some small risk that it will overlap something else next to it, but maybe still ok to enable this by default.

image

For ActionBar there is some additional spacing added between each .Button--iconOnly to avoid overlapping.

/cc @langermank

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I haven't thoroughly tested this yet. We merged it a bit hastily 😅 we can write some previews to try and simulate how it would behave.

@media (pointer: coarse) {
position: relative;

&::before {
@mixin minTouchTarget 44px, 44px;
}
}
}
3 changes: 3 additions & 0 deletions app/components/primer/beta/icon_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class IconButton < Primer::Component
# @param icon [String] Name of <%= link_to_octicons %> to use.
# @param wrapper_arguments [Hash] Optional keyword arguments to be passed to the wrapper `<div>` tag.
# @param scheme [Symbol] <%= one_of(Primer::Beta::IconButton::SCHEME_OPTIONS) %>
# @param wrapper_arguments [Hash] Optional keyword arguments to be passed to the wrapper `<div>` tag.
# @param size [Symbol] <%= one_of(Primer::Beta::Button::SIZE_OPTIONS) %>
# @param tag [Symbol] <%= one_of(Primer::Beta::BaseButton::TAG_OPTIONS) %>
# @param type [Symbol] <%= one_of(Primer::Beta::BaseButton::TYPE_OPTIONS) %>
Expand All @@ -63,6 +64,8 @@ def initialize(icon:, scheme: DEFAULT_SCHEME, wrapper_arguments: {}, tooltip_dir
@system_arguments = system_arguments
@system_arguments[:id] ||= "icon-button-#{SecureRandom.hex(4)}"

@wrapper_arguments = wrapper_arguments

@system_arguments[:classes] = class_names(
"Button",
"Button--iconOnly",
Expand Down
37 changes: 37 additions & 0 deletions app/components/primer/experimental/action_bar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<%= render Primer::BaseComponent.new(**@system_arguments) do %>
<%= render Primer::BaseComponent.new(tag: :div, classes: "ActionBar-item-container", "data-target": "action-bar.itemContainer") do %>
<% items.each do |item| %>
<%= item %>
<% end %>
<% end %>
<%# Replace with ActionMenu %>
<%= render Primer::BaseComponent.new(tag: :"action-menu", "data-anchor-align": "end", "data-target": "action-bar.moreMenu", hidden: true, classes: "ActionBar-more-menu") do %>
<%= render Primer::Beta::IconButton.new(size: @size, scheme: :invisible, icon: :"kebab-horizontal", "aria-label": "Menu", "aria-haspopup": true, "aria-expanded": false, "aria-controls": "#{@menu_id}-list", id: @menu_id) %>
<div class="Overlay-backdrop--anchor" data-menu-overlay>
<div class="Overlay Overlay-whenNarrow Overlay--height-auto Overlay--width-auto" hidden>
<div class="Overlay-body Overlay-body--paddingNone">
<ul class="ActionList" id="<%= @menu_id %>-list" role="menu" aria-labelledby="<%= @menu_id %>-text">
<% items.each do |item| %>
<% if item.slot_type?(:divider) %>
<li class="ActionList-sectionDivider" role="presentation" aria-hidden data-targets="action-bar.menuItems" hidden></li>
<% else %>
<%= render(Primer::BaseComponent.new(tag: :li, role: :none, classes: "ActionList-item", "data-targets": "action-bar.menuItems", hidden: true)) do %>
<%= render(Primer::BaseComponent.new(**item.menu_arguments)) do %>
<% if item.slot_type?(:icon_button) %>
<%= render Primer::BaseComponent.new(tag: :span, classes: "ActionList-item-visual ActionList-item-visual--leading") do %>
<%= render Primer::OcticonComponent.new(icon: item.icon) %>
<% end %>
<% end %>
<span class="ActionList-item-label">
<%= item.label %>
</span>
<% end %>
<% end %>
<% end %>
<% end %>
</ul>
</div>
</div>
</div>
<% end %>
<% end %>
52 changes: 52 additions & 0 deletions app/components/primer/experimental/action_bar.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* CSS for ActionBar */

.ActionBar {
display: flex !important;
align-items: center;
overflow: hidden;
min-width: 0;
justify-content: space-between;
position: relative;
flex: 1 1 auto;
}

.ActionBar-item-container {
display: flex;
align-items: center;
}

.ActionBar-more-menu {
flex-shrink: 0;
}

/* Divider */

.ActionBar-divider {
margin: 0 var(--primer-controlStack-medium-gap-condensed, 8px);
height: calc(var(--primer-control-medium-size, 32px) / 2);
border-left: var(--primer-borderWidth-thin, 1px) solid var(--color-border-subtle);
}

.ActionBar--small .ActionBar-divider {
margin: 0 var(--primer-controlStack-small-gap-condensed, 8px);
}

.ActionBar--large .ActionBar-divider {
margin: 0 var(--primer-controlStack-large-gap-condensed, 8px);
}

/* Increase spacing so touch targets don't overlap */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this back to make sure there is enough spacing between items so that the touch targets don't overlap.

Screen Shot 2022-08-31 at 14 08 40


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

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

.ActionBar--large .ActionBar-item-container {
gap: calc(var(--primer-control-minTarget-coarse, 44px) - var(--primer-control-large-size, 40px)); /* 4px */
}
}
98 changes: 98 additions & 0 deletions app/components/primer/experimental/action_bar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# frozen_string_literal: true

module Primer
module Experimental
# Add a general description of component here
# Add additional usage considerations or best practices that may aid the user to use the component correctly.
# @accessibility Add any accessibility considerations
class ActionBar < Primer::Component
status :experimental

SIZE_DEFAULT = :medium
SIZE_MAPPINGS = {
SIZE_DEFAULT => nil,
:small => "ActionBar--small",
:large => "ActionBar--large"
}.freeze
SIZE_OPTIONS = SIZE_MAPPINGS.keys.freeze

renders_many :items, types: {
icon_button: lambda { |**system_arguments|
Primer::Experimental::ActionBar::Item.new(slot_type: :icon_button, size: @size, **system_arguments)
},
divider: lambda { |**system_arguments|
Primer::Experimental::ActionBar::Item.new(
slot_type: :divider,
tag: :hr,
classes: class_names(
system_arguments[:classes],
"ActionBar-divider"
),
**system_arguments
)
}
}

# @example Example goes here
#
# <%= render(Primer::Experimental::ActionBar.new) { "Example" } %>
#
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
def initialize(size: Primer::Beta::Button::DEFAULT_SIZE, **system_arguments)
@menu_id = "action-bar-overflow-menu-#{SecureRandom.hex(4)}"
@system_arguments = system_arguments
@system_arguments[:tag] = :"action-bar"

@size = fetch_or_fallback(Primer::Beta::Button::SIZE_OPTIONS, size, Primer::Beta::Button::DEFAULT_SIZE)

@system_arguments[:classes] = class_names(
system_arguments[:classes],
"ActionBar",
SIZE_MAPPINGS[@size]
)
@system_arguments[:role] = "toolbar"
end

def render?
items.any?
end

# :no_doc:
class Item < Primer::Component
status :experimental

SLOT_TYPES = [:icon_button, :divider].freeze
SLOT_TYPE_DEFAULT = :icon_button

attr_reader :icon, :label, :menu_arguments

def initialize(slot_type:, **system_arguments)
@item_type = fetch_or_fallback(SLOT_TYPES, slot_type, SLOT_TYPE_DEFAULT)
@system_arguments = system_arguments
@menu_arguments = system_arguments.dup
@menu_arguments.delete(:icon)
@menu_arguments.delete(:"aria-label")

return unless slot_type?(:icon_button)

@menu_arguments[:tag] = system_arguments[:tag] || :button
@menu_arguments[:classes] = "ActionList-content"
@icon = system_arguments[:icon]
@label = system_arguments[:"aria-label"]
end

def slot_type?(type)
@item_type == type
end

def call
if slot_type?(:icon_button)
render Primer::Beta::IconButton.new(wrapper_arguments: { "data-targets": "action-bar.items" }, scheme: :invisible, **@system_arguments)
else
render Primer::BaseComponent.new("data-targets": "action-bar.items", **@system_arguments)
end
end
end
end
end
end
Loading