Skip to content

Commit

Permalink
Updated: Empty component updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arifulislam5577 committed Mar 1, 2024
1 parent 7efdcc8 commit a057f18
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 38 deletions.
21 changes: 12 additions & 9 deletions app/src/components/Empty/Description.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
'use client'
import { FC, ReactNode } from 'react'
import { forwardRef, HTMLProps } from 'react'
import { cn } from '../../helpers/cn'
import { emptyTheme } from './theme'

export interface DescriptionProps {
className?: string
children?: ReactNode
}
export const Description = forwardRef<HTMLParagraphElement, HTMLProps<HTMLParagraphElement>>(
({ children, ...props }, ref) => {
const { description } = emptyTheme
return (
<p {...props} ref={ref} className={cn(description.base, props.className)}>
{children}
</p>
)
},
)

export const Description: FC<DescriptionProps> = ({ children, className }) => {
const { description } = emptyTheme
return <p className={cn(description.base, className)}>{children}</p>
}
Description.displayName = 'Empty.Description'
21 changes: 9 additions & 12 deletions app/src/components/Empty/Empty.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
'use client'
import { FC, ReactNode } from 'react'
import { HTMLProps, forwardRef } from 'react'
import { cn } from '../../helpers/cn'
import { Description } from './Description'
import { Image } from './Image'
import { Title } from './Title'
import { emptyTheme } from './theme'

interface EmptyProps {
className?: string
children?: ReactNode
}
const EmptyComponent: FC<EmptyProps> = ({ children, className }) => {
const EmptyComponent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>(({ children, ...props }, ref) => {
const { root } = emptyTheme
return <section className={cn(root.base, className)}>{children}</section>
}

Title.displayName = 'Empty.Title'
Description.displayName = 'Empty.Description'
Image.displayName = 'Empty.Image'
return (
<div {...props} ref={ref} className={cn(root.base, props.className)}>
{children}
</div>
)
})

EmptyComponent.displayName = 'Empty'
export const Empty = Object.assign(EmptyComponent, {
Title,
Description,
Expand Down
17 changes: 9 additions & 8 deletions app/src/components/Empty/Image.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use client'
import { FC, ReactNode } from 'react'
import { forwardRef, HTMLProps } from 'react'
import { cn } from '../../helpers/cn'

export interface ImageProps {
className?: string
children?: ReactNode
}
export const Image = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>(({ children, ...props }, ref) => {
return (
<div {...props} ref={ref} className={cn(props.className)}>
{children}
</div>
)
})

export const Image: FC<ImageProps> = ({ children, className }) => {
return <div className={cn(className)}>{children}</div>
}
Image.displayName = 'Empty.Image'
19 changes: 10 additions & 9 deletions app/src/components/Empty/Title.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use client'
import { FC, ReactNode } from 'react'
import { forwardRef, HTMLProps } from 'react'
import { cn } from '../../helpers/cn'
import { emptyTheme } from './theme'

export interface TitleProps {
className?: string
children?: ReactNode
}

export const Title: FC<TitleProps> = ({ children, className }) => {
export const Title = forwardRef<HTMLHeadingElement, HTMLProps<HTMLHeadingElement>>(({ children, ...props }, ref) => {
const { title } = emptyTheme
return <h1 className={cn(title.base, className)}>{children}</h1>
}
return (
<h1 {...props} ref={ref} className={cn(title.base, props.className)}>
{children}
</h1>
)
})

Title.displayName = 'Empty.Title'

0 comments on commit a057f18

Please sign in to comment.