Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add address tag ui component LW-10061
- Loading branch information
1 parent
e8a9096
commit caa4c15
Showing
8 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/ui/src/design-system/address-tags/address-tag.component.tsx
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,25 @@ | ||
import type { PropsWithChildren, HTMLAttributes } from 'react'; | ||
import React from 'react'; | ||
|
||
import cs from 'classnames'; | ||
|
||
import * as cx from './address-tag.css'; | ||
|
||
import type { AddressTagScheme } from './types'; | ||
|
||
export type AddressBaseTageProps = PropsWithChildren< | ||
HTMLAttributes<HTMLDivElement> & { | ||
variant: AddressTagScheme; | ||
} | ||
>; | ||
|
||
export const AddressTag = ({ | ||
children, | ||
className, | ||
variant, | ||
...restProps | ||
}: Readonly<AddressBaseTageProps>): JSX.Element => ( | ||
<div {...restProps} className={cs(className, cx.card({ scheme: variant }))}> | ||
{children} | ||
</div> | ||
); |
30 changes: 30 additions & 0 deletions
30
packages/ui/src/design-system/address-tags/address-tag.css.ts
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,30 @@ | ||
import { recipe } from '@vanilla-extract/recipes'; | ||
|
||
import { vars } from '../../design-tokens'; | ||
|
||
import { AddressTagScheme } from './types'; | ||
|
||
export const card = recipe({ | ||
base: { | ||
fontSize: vars.fontSizes.$12, | ||
fontWeight: vars.fontWeights.$medium, | ||
borderRadius: vars.radius.$medium, | ||
padding: [vars.spacing.$4, vars.spacing.$8], | ||
}, | ||
variants: { | ||
scheme: { | ||
[AddressTagScheme.Own]: { | ||
color: vars.colors.$address_tag_own_color, | ||
backgroundColor: vars.colors.$address_tag_own_bgColor, | ||
}, | ||
[AddressTagScheme.Handle]: { | ||
color: vars.colors.$address_tag_handle_color, | ||
backgroundColor: vars.colors.$address_tag_handle_bgColor, | ||
}, | ||
[AddressTagScheme.Foreign]: { | ||
color: vars.colors.$address_tag_foreign_color, | ||
backgroundColor: vars.colors.$address_tag_foreign_bgColor, | ||
}, | ||
}, | ||
}, | ||
}); |
65 changes: 65 additions & 0 deletions
65
packages/ui/src/design-system/address-tags/address-tags.stories.tsx
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 type { Meta } from '@storybook/react'; | ||
|
||
import { ThemeColorScheme, LocalThemeProvider } from '../../design-tokens'; | ||
import { page, Section, Variants } from '../decorators'; | ||
import { Cell, Grid } from '../grid'; | ||
|
||
import { AddressTag } from './address-tag.component'; | ||
import { AddressTagScheme } from './types'; | ||
|
||
export default { | ||
title: 'AddressTag', | ||
decorators: [ | ||
page({ | ||
title: 'Address Tag', | ||
subtitle: 'Simple component to flag addresses as own, handle or foreign.', | ||
}), | ||
], | ||
} as Meta; | ||
|
||
export const Overview = (): JSX.Element => { | ||
const variantsData = [ | ||
{ | ||
Component: AddressTag, | ||
variant: AddressTagScheme.Own, | ||
}, | ||
{ | ||
Component: AddressTag, | ||
variant: AddressTagScheme.Handle, | ||
}, | ||
{ | ||
Component: AddressTag, | ||
variant: AddressTagScheme.Foreign, | ||
}, | ||
]; | ||
const renderTable = (showHeader = false): JSX.Element => ( | ||
<Variants.Table | ||
headers={showHeader ? variantsData.map(v => v.variant) : []} | ||
> | ||
<Variants.Row> | ||
{variantsData.map(({ Component, variant }) => ( | ||
<Variants.Cell key={variant}> | ||
<Component variant={variant}>{variant}</Component> | ||
</Variants.Cell> | ||
))} | ||
</Variants.Row> | ||
</Variants.Table> | ||
); | ||
|
||
return ( | ||
<Grid columns="$1"> | ||
<Cell> | ||
<Section title="Main components"> | ||
<> | ||
{renderTable(true)} | ||
<LocalThemeProvider colorScheme={ThemeColorScheme.Dark}> | ||
<div style={{ color: 'white' }}>{renderTable()}</div> | ||
</LocalThemeProvider> | ||
</> | ||
</Section> | ||
</Cell> | ||
</Grid> | ||
); | ||
}; |
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 @@ | ||
export { AddressTag } from './address-tag.component'; |
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,5 @@ | ||
export enum AddressTagScheme { | ||
Own = 'Own', | ||
Handle = 'Handle', | ||
Foreign = 'Foreign', | ||
} |
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