Skip to content

Commit

Permalink
More ImageIcon options
Browse files Browse the repository at this point in the history
  • Loading branch information
calebjacob committed Feb 23, 2025
1 parent fa6ad47 commit 00b117f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-pagoda/ui",
"version": "3.1.10",
"version": "3.1.11",
"description": "A React component library that implements the official NEAR design system.",
"license": "MIT",
"repository": {
Expand Down
22 changes: 19 additions & 3 deletions src/components/ImageIcon.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.imageIcon {
border-radius: 100%;
overflow: hidden;
flex-shrink: 0;
background: #fff;
Expand All @@ -13,8 +12,21 @@
width: 100%;
height: 100%;
object-fit: cover;
fill: #000 !important;
stroke: #000 !important;
}

&[data-rounded='true'] {
border-radius: 100%;
}

&[data-transparent='true'] {
background: transparent;
}

&:not([data-transparent='true']) {
svg {
fill: #000 !important;
stroke: #000 !important;
}
}

&[data-size='2xs'] {
Expand Down Expand Up @@ -68,4 +80,8 @@
transform: scale(1.15, 1.15);
}
}

&[data-no-padding='true'] {
padding: 0 !important;
}
}
11 changes: 11 additions & 0 deletions src/components/ImageIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ type Props = {
className?: string;
fallbackIcon?: ReactNode;
indicateParentClickable?: boolean;
padding?: boolean;
paddingFallbackIcon?: boolean;
rounded?: boolean;
transparent?: boolean;
size?: ThemeIconSize;
src: string | undefined;
style?: CSSProperties;
Expand All @@ -18,6 +22,10 @@ export const ImageIcon = ({
className = '',
fallbackIcon,
indicateParentClickable,
padding = true,
paddingFallbackIcon = true,
rounded = true,
transparent,
size = 'm',
src,
...props
Expand All @@ -27,6 +35,9 @@ export const ImageIcon = ({
className={`${s.imageIcon} ${className} image-icon`}
data-parent-clickable={indicateParentClickable}
data-size={size}
data-no-padding={(!padding && !!src) || (!paddingFallbackIcon && !src)}
data-rounded={rounded}
data-transparent={transparent}
{...props}
>
{src ? <img src={src} alt={alt} /> : fallbackIcon}
Expand Down

0 comments on commit 00b117f

Please sign in to comment.