Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add utility icon to IconBadge #534

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading