generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b3bfc5
commit c51dfa0
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |