mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 08:28:03 +08:00
feat: create top bar
This commit is contained in:
34
web/app/components/datasets/create/stepper/index.tsx
Normal file
34
web/app/components/datasets/create/stepper/index.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
import type { FC } from 'react'
|
||||
import type { Step } from './step'
|
||||
import { StepperStep } from './step'
|
||||
|
||||
export type StepperProps = {
|
||||
steps: Step[]
|
||||
activeStepIndex: number
|
||||
}
|
||||
|
||||
function join<T, R = T>(array: T[], sep: R): Array<T | R> {
|
||||
return array.reduce((acc, item, index) => {
|
||||
if (index === 0)
|
||||
return [item]
|
||||
|
||||
return acc.concat([sep, item])
|
||||
}, [] as Array<T | R>)
|
||||
}
|
||||
|
||||
export const Stepper: FC<StepperProps> = (props) => {
|
||||
const { steps, activeStepIndex } = props
|
||||
return <div className='flex items-center gap-3'>
|
||||
{join(
|
||||
steps.map((step, index) => (
|
||||
<StepperStep
|
||||
key={index}
|
||||
{...step}
|
||||
isActive={index === activeStepIndex}
|
||||
index={index}
|
||||
/>
|
||||
)),
|
||||
<div className="w-4 h-px bg-[#101828]/30" />,
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
33
web/app/components/datasets/create/stepper/step.tsx
Normal file
33
web/app/components/datasets/create/stepper/step.tsx
Normal file
@ -0,0 +1,33 @@
|
||||
import type { FC } from 'react'
|
||||
import classNames from '@/utils/classnames'
|
||||
|
||||
export type Step = {
|
||||
name: string
|
||||
}
|
||||
|
||||
export type StepperStepProps = Step & {
|
||||
index: number
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
export const StepperStep: FC<StepperStepProps> = (props) => {
|
||||
const { name, isActive, index } = props
|
||||
const label = isActive ? `STEP ${index + 1}` : `${index + 1}`
|
||||
return <div className='flex items-center gap-2'>
|
||||
<div className={classNames(
|
||||
'h-5 px-2 py-1 rounded-3xl flex-col justify-center items-center gap-2 inline-flex',
|
||||
isActive ? 'bg-[#296cff]' : 'border border-[#101828]/30',
|
||||
)}>
|
||||
<div className={classNames(
|
||||
'text-center text-[10px] font-semibold uppercase leading-3',
|
||||
isActive ? 'text-white' : 'text-[#676f83]',
|
||||
)}>
|
||||
{label}
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames(
|
||||
' text-xs font-medium uppercase leading-none',
|
||||
isActive ? 'text-[#155aef]' : 'text-[#676f83]',
|
||||
)}>{name}</div>
|
||||
</div>
|
||||
}
|
||||
Reference in New Issue
Block a user