Skip to content

Commit

Permalink
feat: 🎸 [IconButton] Added icon subpart
Browse files Browse the repository at this point in the history
Added "icon" subpart to allow retrieval of icon component
  • Loading branch information
luciobordonaro committed Jun 15, 2021
1 parent 8442bc0 commit cb5660d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/IconButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@ import MUIIconButton from "@material-ui/core/IconButton";

import { IconSize } from "../../types/Icon";
import { IIconButton } from "../../types/IconButton";
import { suppressEvent } from "../../utils";
import { getComposedDataCy, suppressEvent } from "../../utils";
import Icon from "../Icon";

export const DATA_CY_DEFAULT = "icon-button";

export const SUBPARTS_MAP = {
icon: {
label: "Icon",
},
};

const IconButton: FC<IIconButton> = ({
dataCy = DATA_CY_DEFAULT,
icon,
Expand All @@ -26,7 +32,7 @@ const IconButton: FC<IIconButton> = ({

return (
<MUIIconButton color="inherit" data-cy={dataCy} disabled={disabled} onClick={onClickHandler} style={style}>
<Icon dataCy={`${dataCy}-icon`} name={icon} size={size} />
<Icon dataCy={getComposedDataCy(dataCy, SUBPARTS_MAP.icon)} name={icon} size={size} />
</MUIIconButton>
);
};
Expand Down

0 comments on commit cb5660d

Please sign in to comment.