-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 [IconWrapper] Added component to centralize Icon usage
✅ Closes: 166
- Loading branch information
luciobordonaro
committed
Jun 24, 2021
1 parent
cb01637
commit c8d6359
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
import React, { FC } from "react"; | ||
|
||
import { IconSize } from "../../types/Icon"; | ||
import { IIconWrapper } from "../../types/IconWrapper"; | ||
import { logWarn } from "../../utils/logger"; | ||
import Icon from "../Icon"; | ||
|
||
export const DATA_CY_DEFAULT = "icon-wrapper"; | ||
|
||
const IconWrapper: FC<IIconWrapper> = ({ | ||
dataCy = DATA_CY_DEFAULT, | ||
forwarded, | ||
icon, | ||
loading = false, | ||
rotate = false, | ||
size = IconSize.default, | ||
style, | ||
}) => { | ||
if (!icon) { | ||
logWarn("IconWrapper", "Skip rendering, both children and name are not set"); | ||
return null; | ||
} | ||
|
||
return ( | ||
<Icon | ||
dataCy={dataCy} | ||
forwarded={forwarded} | ||
loading={loading} | ||
name={icon} | ||
rotate={rotate} | ||
size={size} | ||
style={style} | ||
/> | ||
); | ||
}; | ||
|
||
export default IconWrapper; |
This file contains 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,4 @@ | ||
import { IBase } from "./Base"; | ||
import { IIcon, IPartialIconUtilizer } from "./Icon"; | ||
|
||
export type IIconWrapper = IBase & IPartialIconUtilizer & Omit<IIcon, "name">; |