feat: create top bar
parent
13c62f83f4
commit
fdcee1cd45
@ -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>
|
||||
}
|
||||
@ -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>
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
import type { FC } from 'react'
|
||||
import { RiArrowLeftLine } from '@remixicon/react'
|
||||
import { Stepper, type StepperProps } from '../stepper'
|
||||
import classNames from '@/utils/classnames'
|
||||
|
||||
export type TopbarProps = Pick<StepperProps, 'activeStepIndex'> & {
|
||||
className?: string
|
||||
}
|
||||
|
||||
export const Topbar: FC<TopbarProps> = (props) => {
|
||||
const { className, ...rest } = props
|
||||
return <div className={classNames('flex items-center justify-between relative', className)}>
|
||||
<div className="h-12 pl-2 pr-6 py-2 justify-start items-center gap-1 inline-flex">
|
||||
<RiArrowLeftLine className='size-4 mr-2' />
|
||||
<div className="text-[#101827] text-[13px] font-semibold uppercase leading-none">
|
||||
Create Knowledge
|
||||
</div>
|
||||
</div>
|
||||
<div className={
|
||||
'top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 absolute'
|
||||
}>
|
||||
<Stepper
|
||||
steps={[
|
||||
{ name: 'Data Source' },
|
||||
{ name: 'Document Processing' },
|
||||
{ name: 'Execute & Finish' },
|
||||
]}
|
||||
{...rest}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@ -1,25 +1,16 @@
|
||||
'use client'
|
||||
|
||||
import Input from '../components/base/input'
|
||||
import { OptionCard } from '../components/datasets/create/step-two/option-card'
|
||||
import { Stepper } from '../components/datasets/create/stepper'
|
||||
|
||||
export default function Page() {
|
||||
return <div className='p-4'>
|
||||
<OptionCard
|
||||
icon={undefined}
|
||||
title={'General'}
|
||||
description={
|
||||
'General text chunking mode, the chunks retrieved and recalled are the same.'
|
||||
}
|
||||
className='w-[600px]'
|
||||
activeHeaderClassName='bg-gradient-to-r from-[#EFF0F9] to-[#F9FAFB]'
|
||||
isActive={true}>
|
||||
<p
|
||||
className='text-[#354052] text-sm font-semibold leading-tight'
|
||||
>
|
||||
Lorem ipsum
|
||||
</p>
|
||||
<Input className='mt-2' />
|
||||
</OptionCard>
|
||||
<Stepper
|
||||
steps={[
|
||||
{ name: 'Data Source' },
|
||||
{ name: 'Document Processing' },
|
||||
{ name: 'Execute & Finish' },
|
||||
]}
|
||||
activeStepIndex={1}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue