Skip to content

Commit

Permalink
NA - Added tag component
Browse files Browse the repository at this point in the history
  • Loading branch information
nagarajnetcentric committed Jan 31, 2024
1 parent 5b3bfc5 commit c51dfa0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/frontend/src/assets/icons/vector.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions apps/frontend/src/components/Tag/Tag.stories.ts
Original file line number Diff line number Diff line change
@@ -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<typeof Tag>;

export default meta;
type Story = StoryObj<typeof meta>;


export const Default: Story = {
args: {
label: 'intersteller collaboration',
isSelected: false
},
};

export const Selected: Story = {
args: {
label: 'scientific research',
isSelected: true
},
};
26 changes: 26 additions & 0 deletions apps/frontend/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -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<boolean>(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 (
<div className={classes} onClick={handleClick}>
{label}
{selected && <img className='pl-[18px]' src={vector} alt="logo" />}
</div>
);
};

0 comments on commit c51dfa0

Please sign in to comment.