-
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.
Merge pull request #51 from PxTools/feature/PXWEB2-54-Tag-component-T…
…ake2 Tag component with nx migrations
- Loading branch information
Showing
8 changed files
with
231 additions
and
12 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
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,6 +1,7 @@ | ||
export * from './lib/components/Tag/Tag'; | ||
export * from './lib/components/Typography/Label/Label'; | ||
export * from './lib/components/Typography/BodyShort/BodyShort'; | ||
export * from './lib/components/Button/Button'; | ||
export * from './lib/components/Typography/Ingress/Ingress' | ||
export * from './lib/components/Typography/Ingress/Ingress'; | ||
export * from './lib/components/Typography/Heading/Heading'; | ||
export * from './lib/components/Typography/BodyLong/BodyLong'; |
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,79 @@ | ||
@use '../../../../style-dictionary/dist/scss/fixed-variables.scss' as fixed; | ||
|
||
.tag { | ||
display: inline-flex; | ||
font-family: PxWeb-font-500; | ||
font-weight: 500; | ||
color: var(--px-color-text-default); | ||
align-items: center; | ||
} | ||
|
||
.medium { | ||
padding: 4px 8px; | ||
border-radius: var(--px-border-radius-small); | ||
font-size: 16px; | ||
line-height: 24px; | ||
} | ||
|
||
.small { | ||
padding: 1px 6px 2px 6px; | ||
border-radius: var(--px-border-radius-xsmall); | ||
font-size: 14px; | ||
line-height: 20px; | ||
} | ||
|
||
.xsmall { | ||
padding: 0px 4px; | ||
border-radius: var(--px-border-radius-xsmall); | ||
font-size: 14px; | ||
line-height: 20px; | ||
} | ||
|
||
.neutral { | ||
background-color: var(--px-color-surface-moderate); | ||
&.border { | ||
background-color: var(--px-color-surface-subtle); | ||
outline: 1px solid var(--px-color-border-moderate); | ||
outline-offset: -1px; | ||
} | ||
} | ||
|
||
.info { | ||
background-color: var(--px-color-surface-info-moderate); | ||
&.border { | ||
background-color: var(--px-color-surface-info-subtle); | ||
outline: 1px solid var(--px-color-border-info); | ||
outline-offset: -1px; | ||
} | ||
} | ||
|
||
.success { | ||
background-color: var(--px-color-surface-success-moderate); | ||
&.border { | ||
background-color: var(--px-color-surface-success-subtle); | ||
outline: 1px solid var(--px-color-border-success); | ||
outline-offset: -1px; | ||
} | ||
} | ||
|
||
.warning { | ||
background-color: var(--px-color-surface-warning-moderate); | ||
&.border { | ||
background-color: var(--px-color-surface-warning-subtle); | ||
outline: 1px solid var(--px-color-border-warning); | ||
outline-offset: -1px; | ||
} | ||
} | ||
|
||
.error { | ||
background-color: var(--px-color-surface-error-moderate); | ||
&.border { | ||
background-color: var(--px-color-surface-error-subtle); | ||
outline: 1px solid var(--px-color-border-error); | ||
outline-offset: -1px; | ||
} | ||
} | ||
|
||
.default { | ||
border: none; | ||
} |
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,10 @@ | ||
import { render } from '@testing-library/react'; | ||
|
||
import Tag from './Tag'; | ||
|
||
describe('Tag', () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render(<Tag />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
}); |
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,93 @@ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
import { Tag } from './Tag'; | ||
|
||
const meta: Meta<typeof Tag> = { | ||
component: Tag, | ||
title: 'Components/Tag', | ||
}; | ||
export default meta; | ||
|
||
const text = 'Tag'; | ||
|
||
export const Default = { | ||
args: { | ||
size: 'medium', | ||
variant: 'neutral', | ||
type: 'default', | ||
children: text | ||
}, | ||
argTypes: { | ||
size: { | ||
options: ['medium', 'small', 'xsmall'], | ||
control: { type: 'radio' }, | ||
}, | ||
variant: { | ||
options: ['neutral', 'info', 'success', 'warning', 'error'], | ||
control: { type: 'radio' }, | ||
}, | ||
type: { | ||
options: ['default', 'border'], | ||
control: { type: 'radio' }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Size: StoryFn<typeof Tag> = () => { | ||
return ( | ||
<> | ||
<h1>Size</h1> | ||
|
||
<h2>default:</h2> | ||
<Tag>{text}</Tag> | ||
|
||
<h2>medium:</h2> | ||
<Tag size="medium">{text}</Tag> | ||
|
||
<h2>small:</h2> | ||
<Tag size="small">{text}</Tag> | ||
|
||
<h2>xsmall:</h2> | ||
<Tag size="xsmall">{text}</Tag> | ||
</> | ||
); | ||
}; | ||
|
||
export const Variant: StoryFn<typeof Tag> = () => { | ||
return ( | ||
<> | ||
<h1>Variant</h1> | ||
|
||
<h2>default:</h2> | ||
<Tag>{text}</Tag> | ||
|
||
<h2>neutral:</h2> | ||
<Tag variant='neutral'>{text}</Tag> | ||
|
||
<h2>info:</h2> | ||
<Tag variant='info'>{text}</Tag> | ||
|
||
<h2>success:</h2> | ||
<Tag variant='success'>{text}</Tag> | ||
|
||
<h2>warning:</h2> | ||
<Tag variant='warning'>{text}</Tag> | ||
|
||
<h2>error:</h2> | ||
<Tag variant='error'>{text}</Tag> | ||
</> | ||
); | ||
}; | ||
|
||
export const Type: StoryFn<typeof Tag> = () => { | ||
return ( | ||
<> | ||
<h1>Type</h1> | ||
|
||
<h2>default:</h2> | ||
<Tag type='default'>{text}</Tag> | ||
|
||
<h2>border:</h2> | ||
<Tag type='border'>{text}</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import cl from 'clsx'; | ||
import classes from './Tag.module.scss'; | ||
|
||
export interface TagProps extends React.HTMLAttributes<HTMLSpanElement> { | ||
size?: 'medium' | 'small' | 'xsmall'; | ||
variant?: 'neutral' | 'info' | 'success'| 'warning'| 'error'; | ||
type?: 'default' | 'border'; | ||
children?: React.ReactNode; | ||
} | ||
|
||
export function Tag({ | ||
size = 'medium', | ||
variant = 'neutral', | ||
type = 'default', | ||
children, | ||
...rest | ||
}: TagProps) { | ||
return ( | ||
<span | ||
className={cl( | ||
classes.tag, | ||
classes[size], | ||
classes[variant], | ||
classes[type] | ||
)} | ||
> | ||
{children} | ||
</span> | ||
); | ||
} | ||
|
||
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