-
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
799b1fa
commit 6c5e5f9
Showing
8 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
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,27 @@ | ||
import React from 'react' | ||
import Icon, { IconProps } from '.' | ||
import { Meta, Story } from '@storybook/react/types-6-0' | ||
|
||
export default { | ||
component: Icon, | ||
title: 'Icon' | ||
} as Meta | ||
|
||
const Template: Story<IconProps> = args => <Icon {...args} /> | ||
|
||
export const DassanaBlue = Template.bind({}) | ||
DassanaBlue.args = { | ||
icon: 'dassana-blue', | ||
size: 64 | ||
} | ||
|
||
export const DassanaOrange = Template.bind({}) | ||
DassanaOrange.args = { | ||
icon: 'dassana-orange' | ||
} | ||
|
||
export const AWS = Template.bind({}) | ||
AWS.args = { | ||
icon: 'aws-logo', | ||
size: 64 | ||
} |
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,34 @@ | ||
import React from 'react' | ||
import Icon, { IconProps } from '.' | ||
import { mount, ReactWrapper } from 'enzyme' | ||
|
||
let wrapper: ReactWrapper | ||
const mockProps: IconProps = { | ||
icon: 'dassana-blue', | ||
size: 64 | ||
} | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<Icon {...mockProps} />) | ||
}) | ||
|
||
describe('Icon', () => { | ||
it('renders', () => { | ||
expect(wrapper).toHaveLength(1) | ||
}) | ||
|
||
it('renders with correct src url', () => { | ||
expect(wrapper.getDOMNode().getAttribute('src')).toContain( | ||
'dassana-blue' | ||
) | ||
}) | ||
|
||
it('has the correct alt attribute', () => { | ||
expect(wrapper.getDOMNode().getAttribute('alt')).toBe('dassana-blue') | ||
}) | ||
|
||
it('has the correct size', () => { | ||
expect(wrapper.getDOMNode().getAttribute('height')).toBe('64') | ||
expect(wrapper.getDOMNode().getAttribute('width')).toBe('64') | ||
}) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 './aws.svg' | ||
import DASSANA_BLUE from './dassana-blue.png' | ||
import DASSANA_ORANGE from './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 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,19 @@ | ||
import Icons, { IconName } from './icons' | ||
import React, { FC } from 'react' | ||
|
||
export interface IconProps { | ||
/** | ||
* The name of the icon. | ||
*/ | ||
icon: 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} /> | ||
} | ||
|
||
export default Icon |