Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NA - Added tag component #16

Merged
merged 8 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
},
};
28 changes: 28 additions & 0 deletions apps/frontend/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import vector from '../../assets/icons/vector.svg';
nagarajnetcentric marked this conversation as resolved.
Show resolved Hide resolved
import clsx from 'clsx';

interface TagProps {
label: string;
isSelected?: boolean;
}

export const Tag = ({ label, isSelected }: TagProps) => {
nagarajnetcentric marked this conversation as resolved.
Show resolved Hide resolved
const [selected, setSelected] = React.useState<boolean>(isSelected || false);

const commonClasses = 'rounded-[2.5rem] font-gellix font-semibold text-[1.25rem] leading-5 px-[1.875rem] py-[0.938rem] border ';

const handleClick = ()=> {
setSelected(!selected);
nagarajnetcentric marked this conversation as resolved.
Show resolved Hide resolved
}

return (
<div className={clsx(commonClasses,{
'flex bg-midnight-blue text-white': selected === true,
'text-midnight-blue border-midnight-blue hover:bg-midnight-blue hover:text-white': selected === false
})} onClick={handleClick}>
{label}
{selected && <img className='pl-[1.125rem]' src={vector} alt="logo" />}
</div>
);
};