-
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.
Browse files
Browse the repository at this point in the history
* Feat #30 - Add toggle component, icon component, improved verified labels action
- Loading branch information
1 parent
cc4fdff
commit 2d9f4fe
Showing
21 changed files
with
519 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
name: Verify Labels | ||
|
||
name: Pull Request Labels | ||
on: | ||
pull_request: | ||
types: [opened, labeled, unlabeled, synchronize] | ||
|
||
jobs: | ||
check_pr_labels: | ||
name: Verify that the PR has the appropriate label(s) | ||
runs-on: ubuntu-latest | ||
name: Verify that the PR has a valid label | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Verify PR label action | ||
uses: jesusvasquez333/[email protected] | ||
- name: Check for version label | ||
if: ${{ github.base_ref == 'master' }} | ||
uses: mheap/github-action-required-labels@v1 | ||
with: | ||
github-token: '${{ secrets.GITHUB_TOKEN }}' | ||
valid-labels: 'fix, bug, bugfix, feature, enhancement, chore' | ||
mode: exactly | ||
count: 1 | ||
labels: 'patch, minor, major' | ||
- name: Check for issue type label | ||
uses: mheap/github-action-required-labels@v1 | ||
with: | ||
mode: minimum | ||
count: 1 | ||
labels: 'fix, bug, bugfix, feature, enhancement, chore' |
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
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
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,33 @@ | ||
import React from 'react' | ||
import Icon, { IconProps } from '.' | ||
import { Meta, Story } from '@storybook/react/types-6-0' | ||
|
||
export default { | ||
argTypes: { | ||
height: { defaultValue: 64 } | ||
}, | ||
component: Icon, | ||
title: 'Icon' | ||
} as Meta | ||
|
||
const Template: Story<IconProps> = args => <Icon {...args} /> | ||
|
||
export const Predefined = Template.bind({}) | ||
Predefined.argTypes = { | ||
icon: { | ||
control: { disable: true } | ||
} | ||
} | ||
Predefined.args = { | ||
iconKey: 'dassana-orange' | ||
} | ||
|
||
export const Custom = Template.bind({}) | ||
Custom.argTypes = { | ||
iconKey: { | ||
control: { disable: true } | ||
} | ||
} | ||
Custom.args = { | ||
icon: 'https://dummyimage.com/600x400/000/fff&text=Dassana' | ||
} |
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,65 @@ | ||
import React from 'react' | ||
import Icon, { IconProps } from '.' | ||
import { mount, ReactWrapper } from 'enzyme' | ||
|
||
let wrapper: ReactWrapper | ||
|
||
describe('Predefined Icon', () => { | ||
const mockProps: IconProps = { | ||
height: 64, | ||
iconKey: 'dassana-blue' | ||
} | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<Icon {...mockProps} />) | ||
}) | ||
|
||
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 height', () => { | ||
expect(wrapper.getDOMNode().getAttribute('height')).toBe('64') | ||
}) | ||
}) | ||
|
||
describe('Custom Icon', () => { | ||
const mockProps: IconProps = { | ||
height: 64, | ||
icon: 'https://dummyimage.com/600x400/000/fff&text=Dassana' | ||
} | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<Icon {...mockProps} />) | ||
}) | ||
|
||
it('renders', () => { | ||
expect(wrapper).toHaveLength(1) | ||
}) | ||
|
||
it('renders with correct src url', () => { | ||
expect(wrapper.getDOMNode().getAttribute('src')).toBe( | ||
'https://dummyimage.com/600x400/000/fff&text=Dassana' | ||
) | ||
}) | ||
|
||
it('has the correct alt attribute', () => { | ||
expect(wrapper.getDOMNode().getAttribute('alt')).toBe( | ||
'https://dummyimage.com/600x400/000/fff&text=Dassana' | ||
) | ||
}) | ||
|
||
it('has the correct height', () => { | ||
expect(wrapper.getDOMNode().getAttribute('height')).toBe('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,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 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,41 @@ | ||
import Icons, { IconName } from './IconsMap' | ||
import React, { FC } from 'react' | ||
|
||
export type { IconName } | ||
|
||
interface SharedIconProps { | ||
/** | ||
* The height of the icon, in pixels. Width will be calculated by default. | ||
*/ | ||
height?: number | ||
} | ||
|
||
interface IconPath extends SharedIconProps { | ||
/** | ||
* The url of the icon if rendering a custom icon. | ||
*/ | ||
icon: string | ||
/** | ||
* The name of the icon if using icons provided by Dassana. **Note**: Either an `icon` or `iconKey` is required. | ||
*/ | ||
iconKey?: never | ||
} | ||
|
||
interface IconKey extends SharedIconProps { | ||
iconKey: IconName | ||
icon?: never | ||
} | ||
|
||
export type IconProps = IconKey | IconPath | ||
|
||
const Icon: FC<IconProps> = ({ height = 32, ...props }: IconProps) => { | ||
const { icon } = props as IconPath | ||
const { iconKey } = props as IconKey | ||
|
||
const imgSrc = iconKey ? Icons[iconKey] : icon | ||
const imgAlt = iconKey ? iconKey : icon | ||
|
||
return <img alt={imgAlt} height={height} src={imgSrc} /> | ||
} | ||
|
||
export default Icon |
Oops, something went wrong.