Commit e6a4af75 authored by Joel's avatar Joel

feat: tab header to new ui

parent 0518ee79
...@@ -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'
export type ITabHeaderProps = { type Item = {
items: {
id: string id: string
name: string name: string
isRight?: boolean
extra?: React.ReactNode extra?: React.ReactNode
}[] }
export type ITabHeaderProps = {
items: Item[]
value: string value: string
onChange: (value: string) => void onChange: (value: string) => void
} }
...@@ -20,9 +23,7 @@ const TabHeader: FC<ITabHeaderProps> = ({ ...@@ -20,9 +23,7 @@ const TabHeader: FC<ITabHeaderProps> = ({
value, value,
onChange, onChange,
}) => { }) => {
return ( const renderItem = ({ id, name, extra }: Item) => (
<div className='flex space-x-4 border-b border-gray-200 '>
{items.map(({ id, name, extra }) => (
<div <div
key={id} 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')} className={cn(id === value ? `${s.itemActive} text-gray-900` : 'text-gray-500', 'relative flex items-center pb-1.5 leading-6 cursor-pointer')}
...@@ -31,7 +32,15 @@ const TabHeader: FC<ITabHeaderProps> = ({ ...@@ -31,7 +32,15 @@ const TabHeader: FC<ITabHeaderProps> = ({
<div className='text-base font-semibold'>{name}</div> <div className='text-base font-semibold'>{name}</div>
{extra || ''} {extra || ''}
</div> </div>
))} )
return (
<div className='flex justify-between border-b border-gray-200 '>
<div className='flex space-x-4'>
{items.filter(item => !item.isRight).map(renderItem)}
</div>
<div className='flex space-x-4'>
{items.filter(item => item.isRight).map(renderItem)}
</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