dify
This commit is contained in:
27
dify/web/app/components/datasets/create/stepper/index.tsx
Normal file
27
dify/web/app/components/datasets/create/stepper/index.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { type FC, Fragment } from 'react'
|
||||
import type { Step } from './step'
|
||||
import { StepperStep } from './step'
|
||||
|
||||
export type StepperProps = {
|
||||
steps: Step[]
|
||||
activeIndex: number
|
||||
}
|
||||
|
||||
export const Stepper: FC<StepperProps> = (props) => {
|
||||
const { steps, activeIndex } = props
|
||||
return <div className='flex items-center gap-3'>
|
||||
{steps.map((step, index) => {
|
||||
const isLast = index === steps.length - 1
|
||||
return (
|
||||
<Fragment key={index}>
|
||||
<StepperStep
|
||||
{...step}
|
||||
activeIndex={activeIndex}
|
||||
index={index}
|
||||
/>
|
||||
{!isLast && <div className='h-px w-4 bg-divider-deep' />}
|
||||
</Fragment>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
}
|
||||
46
dify/web/app/components/datasets/create/stepper/step.tsx
Normal file
46
dify/web/app/components/datasets/create/stepper/step.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import type { FC } from 'react'
|
||||
import classNames from '@/utils/classnames'
|
||||
|
||||
export type Step = {
|
||||
name: string
|
||||
}
|
||||
|
||||
export type StepperStepProps = Step & {
|
||||
index: number
|
||||
activeIndex: number
|
||||
}
|
||||
|
||||
export const StepperStep: FC<StepperStepProps> = (props) => {
|
||||
const { name, activeIndex, index } = props
|
||||
const isActive = index === activeIndex
|
||||
const isDisabled = activeIndex < index
|
||||
const label = isActive ? `STEP ${index + 1}` : `${index + 1}`
|
||||
return <div className='flex items-center gap-2'>
|
||||
<div className={classNames(
|
||||
'inline-flex h-5 flex-col items-center justify-center gap-2 rounded-3xl py-1',
|
||||
isActive
|
||||
? 'bg-state-accent-solid px-2'
|
||||
: !isDisabled
|
||||
? 'w-5 border border-text-quaternary'
|
||||
: 'w-5 border border-divider-deep',
|
||||
)}>
|
||||
<div className={classNames(
|
||||
'system-2xs-semibold-uppercase text-center',
|
||||
isActive
|
||||
? 'text-text-primary-on-surface'
|
||||
: !isDisabled
|
||||
? 'text-text-tertiary'
|
||||
: 'text-text-quaternary',
|
||||
)}>
|
||||
{label}
|
||||
</div>
|
||||
</div>
|
||||
<div className={classNames('system-xs-medium-uppercase',
|
||||
isActive
|
||||
? 'system-xs-semibold-uppercase text-text-accent'
|
||||
: !isDisabled
|
||||
? 'text-text-tertiary'
|
||||
: 'text-text-quaternary',
|
||||
)}>{name}</div>
|
||||
</div>
|
||||
}
|
||||
Reference in New Issue
Block a user