Commit f4702d60 authored by Joel's avatar Joel

feat: tab header to new ui

parent d2bceb97
...@@ -5,12 +5,15 @@ import cn from 'classnames' ...@@ -5,12 +5,15 @@ import cn from 'classnames'
import s from './style.module.css' import s from './style.module.css'
type Item = {
id: string
name: string
isRight?: boolean
extra?: React.ReactNode
}
export type ITabHeaderProps = { export type ITabHeaderProps = {
items: { items: Item[]
id: string
name: string
extra?: React.ReactNode
}[]
value: string value: string
onChange: (value: string) => void onChange: (value: string) => void
} }
...@@ -20,18 +23,24 @@ const TabHeader: FC<ITabHeaderProps> = ({ ...@@ -20,18 +23,24 @@ const TabHeader: FC<ITabHeaderProps> = ({
value, value,
onChange, onChange,
}) => { }) => {
const renderItem = ({ id, name, extra }: Item) => (
<div
key={id}
className={cn(id === value ? `${s.itemActive} text-gray-900` : 'text-gray-500', 'relative flex items-center pb-1.5 leading-6 cursor-pointer')}
onClick={() => onChange(id)}
>
<div className='text-base font-semibold'>{name}</div>
{extra || ''}
</div>
)
return ( return (
<div className='flex space-x-4 border-b border-gray-200 '> <div className='flex justify-between border-b border-gray-200 '>
{items.map(({ id, name, extra }) => ( <div className='flex space-x-4'>
<div {items.filter(item => !item.isRight).map(renderItem)}
key={id} </div>
className={cn(id === value ? `${s.itemActive} text-gray-900` : 'text-gray-500', 'relative flex items-center pb-1.5 leading-6 cursor-pointer')} <div className='flex space-x-4'>
onClick={() => onChange(id)} {items.filter(item => item.isRight).map(renderItem)}
> </div>
<div className='text-base font-semibold'>{name}</div>
{extra || ''}
</div>
))}
</div> </div>
) )
} }
......
...@@ -316,6 +316,7 @@ const TextGeneration: FC<IMainProps> = ({ ...@@ -316,6 +316,7 @@ const TextGeneration: FC<IMainProps> = ({
{ {
id: 'saved', id: 'saved',
name: t('share.generation.tabs.saved'), name: t('share.generation.tabs.saved'),
isRight: true,
extra: savedMessages.length > 0 extra: savedMessages.length > 0
? ( ? (
<div className='ml-1 flext items-center h-5 px-1.5 rounded-md border border-gray-200 text-gray-500 text-xs font-medium'> <div className='ml-1 flext items-center h-5 px-1.5 rounded-md border border-gray-200 text-gray-500 text-xs font-medium'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment