Skip to content

Commit

Permalink
feat: Add utility icon to IconBadge (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed May 3, 2024
1 parent 39fc684 commit 6c3a2b9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/components/IconBadge/IconBadge.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
border-radius: 5px;
cursor: pointer;
background-color: #37333d;
min-height: 24px;
}

.dui-icon-badge .text {
Expand All @@ -16,13 +17,12 @@
.dui-icon-badge .dui-icon-badge__icon {
width: 13px;
height: 13px;
margin-right: 10px;
background-position: center;
background-repeat: no-repeat;
}

.dui-icon-badge .dui-icon-badge__custom-icon {
margin-right: 10px;
.dui-icon-badge > span:nth-child(2) {
margin-left: 10px;
}

/* Icons */
Expand Down Expand Up @@ -112,6 +112,10 @@
background-image: url(../../images/wearables/HandsIcon.svg);
}

.dui-icon-badge .utility {
background-image: url(../../images/wearables/utility.svg);
}

.dui-icon-badge .play-once {
background-image: url(../../images/emotes/play-once.svg);
width: 19px;
Expand Down
7 changes: 5 additions & 2 deletions src/components/IconBadge/IconBadge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { IconBadge } from './IconBadge'
storiesOf('IconBadge', module)
.add('With Icon', () => (
<IconBadge
icon="BaseMale"
text="Male Icon"
icon="utility"
text="Utility"
onClick={() => console.log('Clicked!')}
/>
))
Expand All @@ -15,6 +15,9 @@ storiesOf('IconBadge', module)
<div>Custom Icon Component</div>
</IconBadge>
))
.add('Without text', () => (
<IconBadge icon="BaseFemale" onClick={() => console.log('Clicked!')} />
))
.add('Without Icon', () => (
<IconBadge text="No Icon" onClick={() => console.log('Clicked!')} />
))
12 changes: 6 additions & 6 deletions src/components/IconBadge/IconBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ export const IconBadge = ({
const childrenInt = React.useMemo(
() => (
<>
{children ? (
{children && icon ? (
<span className="dui-icon-badge__custom-icon">{children}</span>
) : (
) : icon ? (
<span className={classNames(icon && 'dui-icon-badge__icon', icon)} />
)}
<span className="text">{text}</span>
) : null}
{text ? <span className="text">{text}</span> : null}
</>
),
[children, icon, text]
)

return (
<div className={classNames('dui-icon-badge', className)} onClick={onClick}>
<span className={classNames('dui-icon-badge', className)} onClick={onClick}>
{childrenInt}
</div>
</span>
)
}
3 changes: 2 additions & 1 deletion src/components/IconBadge/IconBadge.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export type Props = {
| 'props'
| 'sparkles'
| 'places'
text: string
| 'utility'
text?: string
onClick?: () => void
children?: React.ReactNode
}
10 changes: 10 additions & 0 deletions src/images/wearables/utility.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6c3a2b9

Please sign in to comment.