Commit 3af9fd80 authored by tom's avatar tom

tag refactor

parent c04ffce2
import { defineStyle, defineStyleConfig } from '@chakra-ui/styled-system';
import { mode, transparentize } from '@chakra-ui/theme-tools';
const baseStyle = defineStyle({
fontSize: 'xs',
borderRadius: 'sm',
fontWeight: 'bold',
});
const variantSubtle = defineStyle((props) => {
const { colorScheme: c, theme } = props;
const darkBg = transparentize(`${ c }.200`, 0.16)(theme);
if (c === 'gray') {
return {
bg: mode('blackAlpha.100', 'whiteAlpha.400')(props),
color: mode('gray.600', 'gray.50')(props),
};
}
return {
bg: mode(`${ c }.50`, darkBg)(props),
color: mode(`${ c }.500`, `${ c }.200`)(props),
};
});
const variants = {
subtle: variantSubtle,
};
const Badge = defineStyleConfig({
baseStyle,
variants,
defaultProps: {
variant: 'subtle',
colorScheme: 'gray',
},
});
export default Badge;
...@@ -3,34 +3,41 @@ import { ...@@ -3,34 +3,41 @@ import {
createMultiStyleConfigHelpers, createMultiStyleConfigHelpers,
defineStyle, defineStyle,
} from '@chakra-ui/styled-system'; } from '@chakra-ui/styled-system';
import { mode } from '@chakra-ui/theme-tools';
import getDefaultTransitionProps from '../utils/getDefaultTransitionProps';
import Badge from './Badge';
const transitionProps = getDefaultTransitionProps();
const { defineMultiStyleConfig, definePartsStyle } = const { defineMultiStyleConfig, definePartsStyle } =
createMultiStyleConfigHelpers(parts.keys); createMultiStyleConfigHelpers(parts.keys);
import getDefaultTransitionProps from '../utils/getDefaultTransitionProps'; const variants = {
subtle: definePartsStyle((props) => ({
const variantGray = definePartsStyle((props) => { container: Badge.variants?.subtle(props),
const transitionProps = getDefaultTransitionProps(); })),
};
return { const sizes = {
md: definePartsStyle({
container: { container: {
bg: mode('blackAlpha.100', 'whiteAlpha.400')(props), minH: 6,
color: mode('gray.600', 'gray.50')(props), minW: 6,
...transitionProps, fontSize: 'sm',
px: 2,
py: '2px',
}, },
}; label: {
}); lineHeight: 5,
},
const variants = { }),
gray: variantGray,
}; };
const baseStyleContainer = defineStyle({ const baseStyleContainer = defineStyle({
display: 'inline-block', display: 'inline-flex',
overflow: 'hidden', overflow: 'hidden',
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
borderRadius: 'sm', borderRadius: 'sm',
...transitionProps,
}); });
const baseStyle = definePartsStyle({ const baseStyle = definePartsStyle({
...@@ -40,6 +47,12 @@ const baseStyle = definePartsStyle({ ...@@ -40,6 +47,12 @@ const baseStyle = definePartsStyle({
const Tag = defineMultiStyleConfig({ const Tag = defineMultiStyleConfig({
baseStyle, baseStyle,
variants, variants,
sizes,
defaultProps: {
size: 'md',
variant: 'subtle',
colorScheme: 'gray',
},
}); });
export default Tag; export default Tag;
import Alert from './Alert'; import Alert from './Alert';
import Badge from './Badge';
import Button from './Button'; import Button from './Button';
import Checkbox from './Checkbox'; import Checkbox from './Checkbox';
import Drawer from './Drawer'; import Drawer from './Drawer';
...@@ -19,6 +20,7 @@ import Tooltip from './Tooltip'; ...@@ -19,6 +20,7 @@ import Tooltip from './Tooltip';
const components = { const components = {
Alert, Alert,
Badge,
Button, Button,
Checkbox, Checkbox,
Drawer, Drawer,
......
...@@ -28,7 +28,7 @@ const AddressTagListItem = ({ item, onEditClick, onDeleteClick }: Props) => { ...@@ -28,7 +28,7 @@ const AddressTagListItem = ({ item, onEditClick, onDeleteClick }: Props) => {
<AddressSnippet address={ item.address_hash }/> <AddressSnippet address={ item.address_hash }/>
<HStack spacing={ 3 } mt={ 4 }> <HStack spacing={ 3 } mt={ 4 }>
<Text fontSize="sm" fontWeight={ 500 }>Private tag</Text> <Text fontSize="sm" fontWeight={ 500 }>Private tag</Text>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ item.name } { item.name }
</Tag> </Tag>
</HStack> </HStack>
......
...@@ -33,7 +33,7 @@ const AddressTagTableItem = ({ item, onEditClick, onDeleteClick }: Props) => { ...@@ -33,7 +33,7 @@ const AddressTagTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
</Td> </Td>
<Td> <Td>
<TruncatedTextTooltip label={ item.name }> <TruncatedTextTooltip label={ item.name }>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ item.name } { item.name }
</Tag> </Tag>
</TruncatedTextTooltip> </TruncatedTextTooltip>
......
...@@ -28,7 +28,7 @@ const TransactionTagListItem = ({ item, onEditClick, onDeleteClick }: Props) => ...@@ -28,7 +28,7 @@ const TransactionTagListItem = ({ item, onEditClick, onDeleteClick }: Props) =>
<TransactionSnippet hash={ item.transaction_hash }/> <TransactionSnippet hash={ item.transaction_hash }/>
<HStack spacing={ 3 } mt={ 4 }> <HStack spacing={ 3 } mt={ 4 }>
<Text fontSize="sm" fontWeight={ 500 }>Private tag</Text> <Text fontSize="sm" fontWeight={ 500 }>Private tag</Text>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ item.name } { item.name }
</Tag> </Tag>
</HStack> </HStack>
......
...@@ -33,7 +33,7 @@ const TransactionTagTableItem = ({ item, onEditClick, onDeleteClick }: Props) => ...@@ -33,7 +33,7 @@ const TransactionTagTableItem = ({ item, onEditClick, onDeleteClick }: Props) =>
</Td> </Td>
<Td> <Td>
<Tooltip label={ item.name }> <Tooltip label={ item.name }>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ item.name } { item.name }
</Tag> </Tag>
</Tooltip> </Tooltip>
......
...@@ -35,7 +35,7 @@ const PublicTagListItem = ({ item, onEditClick, onDeleteClick }: Props) => { ...@@ -35,7 +35,7 @@ const PublicTagListItem = ({ item, onEditClick, onDeleteClick }: Props) => {
{ item.tags.split(';').map((tag) => { { item.tags.split(';').map((tag) => {
return ( return (
<TruncatedTextTooltip label={ tag } key={ tag }> <TruncatedTextTooltip label={ tag } key={ tag }>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ tag } { tag }
</Tag> </Tag>
</TruncatedTextTooltip> </TruncatedTextTooltip>
......
...@@ -40,7 +40,7 @@ const PublicTagTableItem = ({ item, onEditClick, onDeleteClick }: Props) => { ...@@ -40,7 +40,7 @@ const PublicTagTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
{ item.tags.split(';').map((tag) => { { item.tags.split(';').map((tag) => {
return ( return (
<TruncatedTextTooltip label={ tag } key={ tag }> <TruncatedTextTooltip label={ tag } key={ tag }>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ tag } { tag }
</Tag> </Tag>
</TruncatedTextTooltip> </TruncatedTextTooltip>
......
...@@ -48,7 +48,7 @@ const WatchListItem = ({ item, onEditClick, onDeleteClick }: Props) => { ...@@ -48,7 +48,7 @@ const WatchListItem = ({ item, onEditClick, onDeleteClick }: Props) => {
<WatchListAddressItem item={ item }/> <WatchListAddressItem item={ item }/>
<HStack spacing={ 3 } mt={ 6 }> <HStack spacing={ 3 } mt={ 6 }>
<Text fontSize="sm" fontWeight={ 500 }>Private tag</Text> <Text fontSize="sm" fontWeight={ 500 }>Private tag</Text>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ item.name } { item.name }
</Tag> </Tag>
</HStack> </HStack>
......
...@@ -72,7 +72,7 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => { ...@@ -72,7 +72,7 @@ const WatchlistTableItem = ({ item, onEditClick, onDeleteClick }: Props) => {
<Td><WatchListAddressItem item={ item }/></Td> <Td><WatchListAddressItem item={ item }/></Td>
<Td> <Td>
<TruncatedTextTooltip label={ item.name }> <TruncatedTextTooltip label={ item.name }>
<Tag variant="gray" lineHeight="24px"> <Tag>
{ item.name } { item.name }
</Tag> </Tag>
</TruncatedTextTooltip> </TruncatedTextTooltip>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment