mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
chore: tab and close btn
This commit is contained in:
@ -16,6 +16,8 @@ export type ITabHeaderProps = {
|
|||||||
items: Item[]
|
items: Item[]
|
||||||
value: string
|
value: string
|
||||||
itemClassName?: string
|
itemClassName?: string
|
||||||
|
itemWrapClassName?: string
|
||||||
|
activeItemClassName?: string
|
||||||
onChange: (value: string) => void
|
onChange: (value: string) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +25,8 @@ const TabHeader: FC<ITabHeaderProps> = ({
|
|||||||
items,
|
items,
|
||||||
value,
|
value,
|
||||||
itemClassName,
|
itemClassName,
|
||||||
|
itemWrapClassName,
|
||||||
|
activeItemClassName,
|
||||||
onChange,
|
onChange,
|
||||||
}) => {
|
}) => {
|
||||||
const renderItem = ({ id, name, icon, extra, disabled }: Item) => (
|
const renderItem = ({ id, name, icon, extra, disabled }: Item) => (
|
||||||
@ -30,8 +34,9 @@ const TabHeader: FC<ITabHeaderProps> = ({
|
|||||||
key={id}
|
key={id}
|
||||||
className={cn(
|
className={cn(
|
||||||
'system-md-semibold relative flex cursor-pointer items-center border-b-2 border-transparent pb-2 pt-2.5',
|
'system-md-semibold relative flex cursor-pointer items-center border-b-2 border-transparent pb-2 pt-2.5',
|
||||||
id === value ? 'border-components-tab-active text-text-primary' : 'text-text-tertiary',
|
id === value ? cn('border-components-tab-active text-text-primary', activeItemClassName) : 'text-text-tertiary',
|
||||||
disabled && 'cursor-not-allowed opacity-30',
|
disabled && 'cursor-not-allowed opacity-30',
|
||||||
|
itemWrapClassName,
|
||||||
)}
|
)}
|
||||||
onClick={() => !disabled && onChange(id)}
|
onClick={() => !disabled && onChange(id)}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -3,6 +3,8 @@ import type { FC } from 'react'
|
|||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import Modal from '@/app/components/base/modal/index'
|
import Modal from '@/app/components/base/modal/index'
|
||||||
import Tab, { TypeEnum } from './tab'
|
import Tab, { TypeEnum } from './tab'
|
||||||
|
import Button from '../../base/button'
|
||||||
|
import { RiCloseLine } from '@remixicon/react'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
appId: string
|
appId: string
|
||||||
@ -19,12 +21,23 @@ const TryApp: FC<Props> = ({
|
|||||||
<Modal
|
<Modal
|
||||||
isShow
|
isShow
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
className='h-[calc(100vh-32px)] max-w-[calc(100vw-32px)]'
|
className='h-[calc(100vh-32px)] max-w-[calc(100vw-32px)] p-2'
|
||||||
>
|
>
|
||||||
<Tab
|
<div className='flex items-center justify-between pl-4'>
|
||||||
value={type}
|
<Tab
|
||||||
onChange={setType}
|
value={type}
|
||||||
/>
|
onChange={setType}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
size='large'
|
||||||
|
variant='tertiary'
|
||||||
|
className='flex size-7 items-center justify-center rounded-[10px] p-0 text-components-button-tertiary-text'
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
|
<RiCloseLine className='size-5' onClick={onClose} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
{appId}
|
{appId}
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import TabHeader from '../../base/tab-header'
|
import TabHeader from '../../base/tab-header'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export enum TypeEnum {
|
export enum TypeEnum {
|
||||||
TRY = 'try',
|
TRY = 'try',
|
||||||
@ -17,18 +18,20 @@ const Tab: FC<Props> = ({
|
|||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ id: TypeEnum.TRY, name: 'Try App' },
|
{ id: TypeEnum.TRY, name: t('explore.tryApp.tabHeader.try') },
|
||||||
{ id: TypeEnum.DETAIL, name: 'App Details' },
|
{ id: TypeEnum.DETAIL, name: t('explore.tryApp.tabHeader.detail') },
|
||||||
]
|
]
|
||||||
return (
|
return (
|
||||||
<div>
|
<TabHeader
|
||||||
<TabHeader
|
items={tabs}
|
||||||
items={tabs}
|
value={value}
|
||||||
value={value}
|
onChange={onChange as (value: string) => void}
|
||||||
onChange={onChange as (value: string) => void}
|
itemClassName='ml-0 system-md-semibold-uppercase'
|
||||||
/>
|
itemWrapClassName='pt-2'
|
||||||
</div>
|
activeItemClassName='border-util-colors-blue-brand-blue-brand-500'
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
export default React.memo(Tab)
|
export default React.memo(Tab)
|
||||||
|
|||||||
@ -30,6 +30,12 @@ const translation = {
|
|||||||
addToWorkspace: 'Use template',
|
addToWorkspace: 'Use template',
|
||||||
try: 'Details',
|
try: 'Details',
|
||||||
},
|
},
|
||||||
|
tryApp: {
|
||||||
|
tabHeader: {
|
||||||
|
try: 'Try it',
|
||||||
|
detail: 'Orchestration Details',
|
||||||
|
},
|
||||||
|
},
|
||||||
appCustomize: {
|
appCustomize: {
|
||||||
title: 'Create app from {{name}}',
|
title: 'Create app from {{name}}',
|
||||||
subTitle: 'App icon & name',
|
subTitle: 'App icon & name',
|
||||||
|
|||||||
@ -31,6 +31,12 @@ const translation = {
|
|||||||
try: '详情',
|
try: '详情',
|
||||||
customize: '自定义',
|
customize: '自定义',
|
||||||
},
|
},
|
||||||
|
tryApp: {
|
||||||
|
tabHeader: {
|
||||||
|
try: '试用',
|
||||||
|
detail: '编排详情',
|
||||||
|
},
|
||||||
|
},
|
||||||
appCustomize: {
|
appCustomize: {
|
||||||
title: '从 {{name}} 创建应用程序',
|
title: '从 {{name}} 创建应用程序',
|
||||||
subTitle: '应用程序图标和名称',
|
subTitle: '应用程序图标和名称',
|
||||||
|
|||||||
Reference in New Issue
Block a user