Skip to content

Commit

Permalink
Merge pull request #162 from web3ui/feature/tag/widthProp
Browse files Browse the repository at this point in the history
feat(tag): width prop
  • Loading branch information
locothedev authored Feb 27, 2022
2 parents c75c7e9 + 930b5e3 commit 1647ee6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/Tag/Tag.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
coloredYellowDark,
} from './styles/colors';

type TStyleProps = Pick<TagProps, 'active' | 'theme' | 'tone'>;
type TStyleProps = Pick<TagProps, 'active' | 'theme' | 'tone' | 'width'>;

const getTheme = (theme: string, active?: boolean) => {
switch (theme) {
Expand Down Expand Up @@ -60,6 +60,8 @@ const getColors = (color?: string, tone?: Tone) => {

export const TagStyled = styled.div<TStyleProps>`
${initialStyles}
${(p) => getTheme(p.theme, p.active)}
${(p) => p.theme !== 'status' && p.color && getColors(p.color, p.tone)}
${({ active, theme }) => getTheme(theme, active)}
${({ color, theme, tone }) =>
theme !== 'status' && color && getColors(color, tone)}
width: ${({ width }) => width};
`;
2 changes: 2 additions & 0 deletions src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Tag: React.FC<TagProps> = ({
text = 'Tag',
theme = 'regular',
tone = 'light',
width = 'fit-content',
}: TagProps) => {
return (
<TagStyled
Expand All @@ -21,6 +22,7 @@ const Tag: React.FC<TagProps> = ({
id={id}
theme={theme}
tone={tone}
width={width}
>
{theme === 'status' && active && (
<Icon fill="inherit" size={16} svg={iconTypes.checkmark} />
Expand Down
5 changes: 5 additions & 0 deletions src/components/Tag/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ export interface TagProps {
* choose a tone for the selected color
*/
tone?: Tone;

/**
* set width of tag
*/
width?: string;
}

0 comments on commit 1647ee6

Please sign in to comment.