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

Uh oh!
There was an error while loading. Please reload this page.
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.
This increases the touch target for
.Button--iconOnlyto44x44px. There is some small risk that it will overlap something else next to it, but maybe still ok to enable this by default.For
ActionBarthere is some additional spacing added between each.Button--iconOnlyto avoid overlapping./cc @langermank
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.
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.