-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c5e5f9
commit 9a48102
Showing
8 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
File renamed without changes
File renamed without changes
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import AWS from '../../assets/icons/aws.svg' | ||
import DASSANA_BLUE from '../../assets/icons/dassana-blue.png' | ||
import DASSANA_ORANGE from '../../assets/icons/dassana-orange.png' | ||
|
||
const Icons = { | ||
'aws-logo': AWS, | ||
'dassana-blue': DASSANA_BLUE, | ||
'dassana-orange': DASSANA_ORANGE | ||
} | ||
|
||
export type IconName = keyof typeof Icons | ||
|
||
export default Icons |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,31 @@ | ||
import Icons, { IconName } from './icons' | ||
import Icons, { IconName } from './IconsMap' | ||
import React, { FC } from 'react' | ||
|
||
export type { IconName } | ||
|
||
export interface IconProps { | ||
/** | ||
* The name of the icon. | ||
* The url of the icon if you want Icon to render a custom icon. | ||
*/ | ||
icon?: string | ||
/** | ||
* The name of the icon if using icons provided by Dassana. | ||
*/ | ||
icon: IconName | ||
iconKey?: IconName | ||
/** | ||
* The width and height of the icon, in pixels. | ||
*/ | ||
size?: number | ||
} | ||
|
||
const Icon: FC<IconProps> = ({ icon, size = 32 }: IconProps) => { | ||
return <img alt={icon} height={size} src={Icons[icon]} width={size} /> | ||
const Icon: FC<IconProps> = ({ icon, iconKey, size = 32 }: IconProps) => { | ||
if (!icon && !iconKey) | ||
throw new Error('Icon requires either an iconKey or icon prop.') | ||
|
||
const imgSrc = iconKey ? Icons[iconKey] : icon | ||
const imgAlt = iconKey ? iconKey : icon | ||
|
||
return <img alt={imgAlt} height={size} src={imgSrc} width={size} /> | ||
} | ||
|
||
export default Icon |