mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-27 12:34:11 +00:00
feat: header component
feat: dropdown component feat: avatar component
This commit is contained in:
4
src/components/ui/avatar/avatar.module.scss
Normal file
4
src/components/ui/avatar/avatar.module.scss
Normal file
@@ -0,0 +1,4 @@
|
||||
.avatar {
|
||||
object-fit: cover;
|
||||
border-radius: 9999px;
|
||||
}
|
||||
18
src/components/ui/avatar/avatar.stories.tsx
Normal file
18
src/components/ui/avatar/avatar.stories.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react'
|
||||
|
||||
import { Avatar } from './'
|
||||
|
||||
const meta = {
|
||||
component: Avatar,
|
||||
tags: ['autodocs'],
|
||||
title: 'Components/Avatar',
|
||||
} satisfies Meta<typeof Avatar>
|
||||
|
||||
export default meta
|
||||
type Story = StoryObj<typeof meta>
|
||||
|
||||
export const Default: Story = {
|
||||
args: {
|
||||
src: 'https://avatars.githubusercontent.com/u/1196870?v=4',
|
||||
},
|
||||
}
|
||||
23
src/components/ui/avatar/avatar.tsx
Normal file
23
src/components/ui/avatar/avatar.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { CSSProperties, ComponentPropsWithoutRef } from 'react'
|
||||
|
||||
import clsx from 'clsx'
|
||||
|
||||
import s from './avatar.module.scss'
|
||||
|
||||
export type AvatarProps = ComponentPropsWithoutRef<'img'> & {
|
||||
size?: CSSProperties['width']
|
||||
}
|
||||
|
||||
export const Avatar = ({ className, size = '36px', style, ...rest }: AvatarProps) => {
|
||||
return (
|
||||
<img
|
||||
className={clsx(className, s.avatar)}
|
||||
style={{
|
||||
...style,
|
||||
height: size,
|
||||
width: size,
|
||||
}}
|
||||
{...rest}
|
||||
/>
|
||||
)
|
||||
}
|
||||
1
src/components/ui/avatar/index.ts
Normal file
1
src/components/ui/avatar/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './avatar'
|
||||
Reference in New Issue
Block a user