Skip to content

Commit

Permalink
chore: Refactored ListTags
Browse files Browse the repository at this point in the history
  • Loading branch information
ape-fede committed Jan 11, 2023
1 parent e17593d commit 2255453
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 33 deletions.
15 changes: 15 additions & 0 deletions src/components/Tag/ListTag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";
import { StyledListTag, StyledTagText } from "./styles";
import { ListTagProps } from "./types";

const ListTag: React.FC<ListTagProps> = ({ variant, ...props }) => {
return (
<StyledListTag variant={variant} {...props}>
<StyledTagText>
{variant} {variant === "new" || variant === "hot" ? null : "LP"}
</StyledTagText>
</StyledListTag>
);
};

export default ListTag;
13 changes: 0 additions & 13 deletions src/components/Tag/LpTag.tsx

This file was deleted.

10 changes: 5 additions & 5 deletions src/components/Tag/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import styled from "styled-components";
import { Meta } from "@storybook/react/types-6-0";
import { CommunityIcon, RemoveIcon } from "../Svg";
import Tag from "./Tag";
import { variants } from "./types";
import LpTag from "./LpTag";
import { ListTagVariants, listTagVariants, variants } from "./types";
import ListTag from "./ListTag";

const Row = styled.div`
display: flex;
Expand Down Expand Up @@ -39,9 +39,9 @@ export const Default: React.FC = () => {
))}
</Row>
<Row>
<LpTag variant="ape" />
<LpTag variant="uni" />
<LpTag variant="ark" />
{Object.values(listTagVariants).map((variant: ListTagVariants) => {
return <ListTag variant={variant} />;
})}
</Row>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/Tag/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default as Tag } from "./Tag";
export { default as LpTag } from "./LpTag";
export { default as ListTag } from "./ListTag";
export type { TagProps, Variants as TagVariants } from "./types";
export type { LpTagVariants } from "./types";
export type { ListTagVariants } from "./types";
12 changes: 6 additions & 6 deletions src/components/Tag/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled, { DefaultTheme } from "styled-components";
import getColor from "../../util/getColor";
import { LpTagProps, TagProps } from "./types";
import { ListTagProps, TagProps } from "./types";

interface ThemedProps extends TagProps {
theme: DefaultTheme;
Expand Down Expand Up @@ -29,20 +29,20 @@ export const StyledTag = styled.div<ThemedProps>`
}
`;

interface CustomProps extends LpTagProps {
interface CustomProps extends ListTagProps {
theme: DefaultTheme;
}

export const StyledLpTag = styled.div<CustomProps>`
export const StyledListTag = styled.div<CustomProps>`
align-items: center;
background: ${({ theme, variant = "ape" }) => theme?.colors?.lpTagBg?.[variant]};
border-radius: 6px;
background: ${({ theme, variant = "ape" }) => theme?.colors?.listTagBg?.[variant]};
border-radius: 16px;
display: inline-flex;
height: 15px;
padding: 0 5px;
`;

export const StyledLPText = styled.div<{ theme: DefaultTheme }>`
export const StyledTagText = styled.div<{ theme: DefaultTheme }>`
color: ${({ theme }) => theme?.colors?.primaryBright};
text-transform: uppercase;
font-size: 10px;
Expand Down
10 changes: 6 additions & 4 deletions src/components/Tag/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ export interface TagProps extends SpaceProps {
outline?: boolean;
}

export const lpTagVariants = {
export const listTagVariants = {
APE: "ape",
UNI: "uni",
ARK: "ark",
NEW: "new",
HOT: "hot",
} as const;

export type LpTagVariants = typeof lpTagVariants[keyof typeof lpTagVariants];
export type ListTagVariants = typeof listTagVariants[keyof typeof listTagVariants];

export interface LpTagProps extends SpaceProps {
variant: LpTagVariants;
export interface ListTagProps extends SpaceProps {
variant: ListTagVariants;
}
4 changes: 3 additions & 1 deletion src/theme/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export const baseColors = {
inputBorder: "#E6DECB",
brown: "#A16552",
smartGradient: "linear-gradient(94.44deg, #BA801E -9.73%, #E7CF67 40.14%, #BA801E 93.01%)",
lpTagBg: {
listTagBg: {
ape: "linear-gradient(99.09deg, rgba(161, 101, 82, 0.8) 0%, rgba(255, 179, 0, 0.8) 106.96%)",
uni: "rgba(213, 49, 113, 0.8)",
ark: "rgba(208, 126, 90, 0.8)",
hot: "#DF4141",
new: "#38A611",
},
};

Expand Down
6 changes: 4 additions & 2 deletions src/theme/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type Colors = {
smartGradient: string;
yellowHover: string;
input: string;
lpTagBg: LpTagColors;
listTagBg: ListTagColors;

// Gradients
gradients?: Gradients;
Expand All @@ -79,8 +79,10 @@ export type FontFamily = {
poppins: string;
};

export type LpTagColors = {
export type ListTagColors = {
ape: string;
uni: string;
ark: string;
hot: string;
new: string;
};

0 comments on commit 2255453

Please sign in to comment.