Skip to content

Commit

Permalink
Update dropdown-menu and button to allow text buttons (#26425)
Browse files Browse the repository at this point in the history
* Add text prop for button and dropdownmenu

Adds a new text property for button and dropdownmenu, if specified it
will show the text in the button field. You could specify icon={ null }
to have a text-only button.

Used to support social links size menu in #25921

* Update text rendering for both icon & text

- Show text if specified regardless of icon, allows for icon & text

- Switch text rendering, don't need a span tag, just use a fragment
  • Loading branch information
mkaz authored Oct 30, 2020
1 parent 5209577 commit 336ab24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/components/src/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function Button( props, ref ) {
shortcut,
label,
children,
text,
__experimentalIsFocusable: isFocusable,
...additionalProps
} = props;
Expand Down Expand Up @@ -111,6 +112,7 @@ export function Button( props, ref ) {
ref={ ref }
>
{ icon && <Icon icon={ icon } size={ iconSize } /> }
{ text && <>{ text }</> }
{ children }
</Tag>
);
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/dropdown-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function DropdownMenu( {
toggleProps,
menuProps,
disableOpenOnArrowDown = false,
text,
// The following props exist for backward compatibility.
menuLabel,
position,
Expand Down Expand Up @@ -129,6 +130,7 @@ function DropdownMenu( {
aria-haspopup="true"
aria-expanded={ isOpen }
label={ label }
text={ text }
showTooltip={ toggleProps?.showTooltip ?? true }
>
{ mergedToggleProps.children }
Expand Down

0 comments on commit 336ab24

Please sign in to comment.