Skip to content

Commit

Permalink
feat #322 - Update Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-dassana committed May 13, 2021
1 parent 47c692c commit b2a4b75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/__snapshots__/storybook.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ exports[`Storyshots Avatar Icon 1`] = `
className=""
fill="#7E7F86"
height={32}
width={32}
>
dassana.svg
</svg>
Expand Down Expand Up @@ -3879,6 +3880,7 @@ exports[`Storyshots Popover Default 1`] = `
className=""
fill="#7E7F86"
height={32}
width={32}
>
dassana.svg
</svg>
Expand Down Expand Up @@ -3909,6 +3911,7 @@ exports[`Storyshots Popover Title 1`] = `
className=""
fill="#7E7F86"
height={32}
width={32}
>
dassana.svg
</svg>
Expand Down Expand Up @@ -6130,6 +6133,7 @@ exports[`Storyshots Tooltip Default 1`] = `
className=""
fill="#7E7F86"
height={32}
width={32}
>
dassana.svg
</svg>
Expand Down
8 changes: 6 additions & 2 deletions src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ export type IconProps = IconKey | IconPath
export const Icon: FC<IconProps> = ({ height, width, ...props }: IconProps) => {
const { classes = [] } = props

const areDimensionsUndefined = isUndefined(height) && isUndefined(width)

const commonProps = {
className: cn(classes),
height: isUndefined(height) && isUndefined(width) ? 32 : height,
width
// if both width and height are undefined, default both to 32.
// otherwise, let user control the dimensions with either just the height, width or both
height: areDimensionsUndefined ? 32 : height,
width: areDimensionsUndefined ? 32 : width
}

if (props.iconKey) {
Expand Down

0 comments on commit b2a4b75

Please sign in to comment.