Skip to content

Commit

Permalink
react-common: support for button children (#9719)
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms authored Oct 12, 2023
1 parent 20dbfdd commit 5bb757a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions react-common/components/controls/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react";
import { classList, ControlProps, fireClickOnEnter } from "../util";
import { classList, ContainerProps, fireClickOnEnter } from "../util";

export interface ButtonViewProps extends ControlProps {
export interface ButtonViewProps extends ContainerProps {
buttonRef?: (ref: HTMLButtonElement) => void;
title: string;
label?: string | JSX.Element;
Expand Down Expand Up @@ -56,7 +56,8 @@ export const Button = (props: ButtonProps) => {
hardDisabled,
href,
target,
tabIndex
tabIndex,
children
} = props;

let {
Expand Down Expand Up @@ -101,13 +102,15 @@ export const Button = (props: ButtonProps) => {
aria-setsize={ariaSetSize}
aria-describedby={ariaDescribedBy}
aria-selected={ariaSelected}>
<span className="common-button-flex">
{leftIcon && <i className={leftIcon} aria-hidden={true}/>}
<span className="common-button-label">
{label}
</span>
{rightIcon && <i className={"right " + rightIcon} aria-hidden={true}/>}
</span>
{(leftIcon || rightIcon || label) && (
<span className="common-button-flex">
{leftIcon && <i className={leftIcon} aria-hidden={true}/>}
<span className="common-button-label">
{label}
</span>
{rightIcon && <i className={"right " + rightIcon} aria-hidden={true}/>}
</span>)}
{children}
</button>
);
}

0 comments on commit 5bb757a

Please sign in to comment.