-
Notifications
You must be signed in to change notification settings - Fork 3
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
a48f39a
commit 32000bc
Showing
10 changed files
with
152 additions
and
8 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
node_modules | ||
.cache | ||
dist | ||
package-lock.json |
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,65 @@ | ||
import React from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
const TagWrapper = styled.span` | ||
display: inline-block; | ||
border: 2px solid var(--green, hsl(186, 62%, 59%)); | ||
border-radius: 999px; | ||
background-color: var(--green, hsl(186, 62%, 59%)); | ||
max-width: 150px; | ||
padding: 2px 10px; | ||
font-size: 0.85rem; | ||
color: var(--white, hsl(0, 0%, 100%)); | ||
text-transform: lowercase; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
&:not(:first-child) { | ||
margin-left: 5px; | ||
} | ||
${(props) => | ||
props.color === 'orange' && | ||
css` | ||
border-color: var(--orange, hsl(36, 100%, 57%)); | ||
background-color: var(--orange, hsl(36, 100%, 57%)); | ||
`} | ||
${(props) => | ||
props.color === 'danger' && | ||
css` | ||
border-color: var(--red, hsl(354, 83%, 64%)); | ||
background-color: var(--red, hsl(354, 83%, 64%)); | ||
`} | ||
${(props) => | ||
props.color === 'info' && | ||
css` | ||
border-color: var(--grey, hsl(0, 0%, 85%)); | ||
background-color: var(--lightGrey, hsl(0, 0%, 98%)); | ||
color: var(--default, hsl(0, 0%, 16%)); | ||
`} | ||
${(props) => | ||
props.color === 'outline' && | ||
css` | ||
border-color: var(--default, hsl(0, 0%, 16%)); | ||
background-color: transparent; | ||
color: var(--default, hsl(0, 0%, 16%)); | ||
`} | ||
`; | ||
|
||
type Color = 'primary' | 'orange' | 'danger' | 'info' | 'outline'; | ||
|
||
interface TagProps { | ||
color?: Color; | ||
value: string; | ||
} | ||
|
||
const Tag = (props: TagProps) => { | ||
const { color = 'primary', value } = props; | ||
return <TagWrapper color={color}>{value}</TagWrapper>; | ||
}; | ||
|
||
export default Tag; |
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,42 @@ | ||
import React from 'react'; | ||
import { Tag } from '../src'; | ||
|
||
export default { | ||
title: 'Design System|Atoms/Tags', | ||
component: Tag, | ||
}; | ||
|
||
export const TagPrimaryComponent = (args) => <Tag {...args} />; | ||
|
||
TagPrimaryComponent.args = { | ||
color: 'primary', | ||
value: 'Burgdoggen', | ||
}; | ||
|
||
export const TagOrangeComponent = (args) => <Tag color="orange" {...args} />; | ||
|
||
TagOrangeComponent.args = { | ||
color: 'orange', | ||
value: 'Burgdoggen', | ||
}; | ||
|
||
export const TagDangerComponent = (args) => <Tag {...args} />; | ||
|
||
TagDangerComponent.args = { | ||
color: 'danger', | ||
value: 'Burgdoggen', | ||
}; | ||
|
||
export const TagInfoComponent = (args) => <Tag {...args} />; | ||
|
||
TagInfoComponent.args = { | ||
color: 'info', | ||
value: 'Burgdoggen', | ||
}; | ||
|
||
export const TagOutlineComponent = (args) => <Tag {...args} />; | ||
|
||
TagOutlineComponent.args = { | ||
color: 'outline', | ||
value: 'Burgdoggen', | ||
}; |
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,12 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Tag renders 1`] = ` | ||
<DocumentFragment> | ||
<span | ||
class="sc-jSgupP iIWTSr" | ||
color="danger" | ||
> | ||
hello | ||
</span> | ||
</DocumentFragment> | ||
`; |
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,13 +1,12 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { render } from '@testing-library/react'; | ||
import { Checkbox } from '../src'; | ||
|
||
describe('Checkbox', () => { | ||
it('renders', () => { | ||
const { asFragment } = render( | ||
<Checkbox value={'check'} label={'ola'} checked={true} /> | ||
<Checkbox value={'check'} label={'hello'} checked={true} /> | ||
); | ||
screen.logTestingPlaygroundURL(); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
}); |
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,18 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { Tag } from '../src'; | ||
|
||
describe('Tag', () => { | ||
it('renders', () => { | ||
const { asFragment } = render(<Tag color={'danger'} value={'hello'} />); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it('Tag has correct value', async () => { | ||
const tagValue = 'This is my tag'; | ||
render(<Tag color={'danger'} value={tagValue} />); | ||
|
||
const foundText = await screen.getByText(tagValue); | ||
expect(foundText).toBeTruthy(); | ||
}); | ||
}); |