From c51dfa00a014d3c9bc7776c4e811aa546d0bc74e Mon Sep 17 00:00:00 2001 From: Nagaraj Devendhiran Date: Wed, 31 Jan 2024 16:38:24 +0100 Subject: [PATCH] NA - Added tag component --- apps/frontend/src/assets/icons/vector.svg | 3 ++ .../src/components/Tag/Tag.stories.ts | 30 +++++++++++++++++++ apps/frontend/src/components/Tag/Tag.tsx | 26 ++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 apps/frontend/src/assets/icons/vector.svg create mode 100644 apps/frontend/src/components/Tag/Tag.stories.ts create mode 100644 apps/frontend/src/components/Tag/Tag.tsx diff --git a/apps/frontend/src/assets/icons/vector.svg b/apps/frontend/src/assets/icons/vector.svg new file mode 100644 index 0000000..912be4a --- /dev/null +++ b/apps/frontend/src/assets/icons/vector.svg @@ -0,0 +1,3 @@ + + + diff --git a/apps/frontend/src/components/Tag/Tag.stories.ts b/apps/frontend/src/components/Tag/Tag.stories.ts new file mode 100644 index 0000000..f10fd8e --- /dev/null +++ b/apps/frontend/src/components/Tag/Tag.stories.ts @@ -0,0 +1,30 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import { Tag } from './Tag'; + +const meta = { + title: 'Tag', + component: Tag, + parameters: { + layout: 'centered', + }, + tags: ['autodocs'], +} satisfies Meta; + +export default meta; +type Story = StoryObj; + + +export const Default: Story = { + args: { + label: 'intersteller collaboration', + isSelected: false + }, +}; + +export const Selected: Story = { + args: { + label: 'scientific research', + isSelected: true + }, + }; \ No newline at end of file diff --git a/apps/frontend/src/components/Tag/Tag.tsx b/apps/frontend/src/components/Tag/Tag.tsx new file mode 100644 index 0000000..0e078e6 --- /dev/null +++ b/apps/frontend/src/components/Tag/Tag.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import vector from '../../assets/icons/vector.svg'; + +interface TagProps { + label: string; + isSelected?: boolean; +} + +export const Tag = ({ label, isSelected }: TagProps) => { + const [selected, setSelected] = React.useState(isSelected || false); + + const classes = 'rounded-[40px] font-gellix text-[20px] leading-5 p-[30px] '.concat( + selected === true ? 'flex bg-midnight-blue text-white' : 'text-midnight-blue border border-midnight-blue hover:bg-midnight-blue hover:text-white', + ); + + const handleClick = ()=> { + setSelected(!selected); + } + + return ( +
+ {label} + {selected && logo} +
+ ); +};