forked from asyncapi/website
-
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.
feat: created tags and avatar components and added stories for them (a…
…syncapi#3081) Co-authored-by: Akshat Nema <[email protected]>
- Loading branch information
1 parent
40a5797
commit e764ea1
Showing
5 changed files
with
110 additions
and
29 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import Avatar from './Avatar'; | ||
|
||
const meta: Meta<typeof Avatar> = { | ||
title: 'Components/Avatar', | ||
component: Avatar | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Avatar>; | ||
|
||
export const DefaultAvatar: Story = { | ||
args: { | ||
name: 'Avatar', | ||
link: 'https://www.asyncapi.com/', | ||
photo: '/favicon-32x32.png' | ||
} | ||
}; |
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,41 @@ | ||
import React from 'react'; | ||
|
||
interface AvatarProps { | ||
// eslint-disable-next-line prettier/prettier | ||
|
||
/** The name of the avatar. */ | ||
name: string; | ||
|
||
/** The photo of the avatar. */ | ||
photo: string; | ||
|
||
/** The link of the avatar. */ | ||
link?: string; | ||
|
||
/** The class name to be applied to the avatar. */ | ||
className: string; | ||
} | ||
|
||
/** | ||
* This component renders avatar. | ||
*/ | ||
export default function Avatar({ name, photo, link, className }: AvatarProps) { | ||
const avatar = ( | ||
<img | ||
title={name} | ||
className={`size-10 rounded-full border-2 border-white object-cover hover:z-50 ${className}`} | ||
src={photo} | ||
loading='lazy' | ||
data-testid='Avatars-img' | ||
alt={name} | ||
/> | ||
); | ||
|
||
return link ? ( | ||
<a href={link} data-testid='Avatars-link'> | ||
{avatar} | ||
</a> | ||
) : ( | ||
<React.Fragment>{avatar}</React.Fragment> | ||
); | ||
} |
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,31 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import SelectTags from './Tags'; | ||
|
||
const meta: Meta<typeof SelectTags> = { | ||
title: 'Components/Tags', | ||
component: SelectTags, | ||
argTypes: { | ||
name: { | ||
control: { type: 'text' } | ||
}, | ||
bgColor: { | ||
control: { type: 'text' } | ||
}, | ||
borderColor: { | ||
control: { type: 'text' } | ||
} | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof SelectTags>; | ||
|
||
export const DefaultTag: Story = { | ||
args: { | ||
name: 'Default', | ||
bgColor: 'bg-gray-200', | ||
borderColor: 'border-gray-200' | ||
} | ||
}; |
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