-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create TextWithIcon component (#3590)
- Loading branch information
Showing
9 changed files
with
160 additions
and
131 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
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,5 @@ | ||
.infoIcon { | ||
min-width: 26px; | ||
justify-content: center; | ||
padding-right: 0.2em; | ||
} |
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,48 @@ | ||
import Icon from '../Icon'; | ||
import { Flex } from '../Layout'; | ||
import Tooltip from '../Tooltip'; | ||
import styles from './TextWithIcon.css'; | ||
import type { ReactElement } from 'react'; | ||
|
||
type Props = { | ||
iconName: string; | ||
className?: string; | ||
content: ReactElement | string; | ||
tooltipContentIcon?: ReactElement; | ||
iconRight?: boolean; | ||
size?: number; | ||
}; | ||
|
||
const TextWithIcon = ({ | ||
iconName, | ||
className, | ||
content, | ||
tooltipContentIcon, | ||
iconRight = false, | ||
size, | ||
}: Props) => { | ||
return ( | ||
<Flex alignItems="center" className={className}> | ||
{iconRight ? <>{content}</> : <></>} | ||
{tooltipContentIcon ? ( | ||
<Tooltip content={tooltipContentIcon}> | ||
<Icon | ||
name={iconName} | ||
className={styles.infoIcon} | ||
size={size ? size : undefined} | ||
/> | ||
</Tooltip> | ||
) : ( | ||
<Icon | ||
name={iconName} | ||
className={styles.infoIcon} | ||
size={size ? size : undefined} | ||
/> | ||
)} | ||
|
||
{iconRight ? <></> : <>{content}</>} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default TextWithIcon; |
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
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
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
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
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
Oops, something went wrong.