Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
fix: add iconOnly prop to button, #noissue
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahHouben committed Nov 24, 2021
1 parent 2d9185f commit 8174087
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
19 changes: 14 additions & 5 deletions src/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {alignMap} from '../styleProps/flexProps';

import ButtonCore from '../ButtonCore';
import Icon from '../Icon';
import VisuallyHidden from '../VisuallyHidden';

import 'focus-visible';

Expand Down Expand Up @@ -254,6 +255,7 @@ const ButtonText = styled.span.withConfig({

const Button = forwardRef((props, ref) => {
const {
iconOnly,
align,
as,
children,
Expand Down Expand Up @@ -285,11 +287,14 @@ const Button = forwardRef((props, ref) => {
{icon && iconRight !== true && (
<Icon disablePointerEvents name={icon} />
)}
{children && (
<ButtonText textOverflow={textOverflow}>
{children}
</ButtonText>
)}
{children &&
(iconOnly ? (
<VisuallyHidden>{children}</VisuallyHidden>
) : (
<ButtonText textOverflow={textOverflow}>
{children}
</ButtonText>
))}
{iconRight && (
<Icon
disablePointerEvents
Expand All @@ -314,6 +319,10 @@ Button.propTypes = {
* Adds the ARIA attribute `aria-pressed="true"`
*/
isActive: PropTypes.bool,
/**
* Visually hides the label but uses it for accessibility.
*/
iconOnly: PropTypes.bool,
/**
* Renders the button in its disabled state. Uses
* `aria-disabled` to make sure the button label
Expand Down
1 change: 1 addition & 0 deletions src/CenterContent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ CenterContent.propTypes = {
PropTypes.number,
PropTypes.string,
PropTypes.array,
PropTypes.func,
]),
/**
* In IE11, content will be aligned to the top of the screen by default.
Expand Down
9 changes: 6 additions & 3 deletions src/Pill/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,18 @@ const Pill = forwardRef((props, ref) => {
</Wrapper>
{hasSideButton && (
<SideButton
iconOnly
round
icon="x"
id={sideButtonId}
icon="x"
size="small"
color="shaded"
background={background}
onClick={onDelete}
aria-label={`${deleteLabel} ${children}`}
/>
aria-labelledby={[sideButtonId, wrapperId].join(' ')}
>
{deleteLabel}
</SideButton>
)}
</ConditionalFlexWrapper>
);
Expand Down

0 comments on commit 8174087

Please sign in to comment.