Commit 6caca3aa authored by StyleZhang's avatar StyleZhang

base panel

parent 3d3bc4c5
...@@ -2,36 +2,20 @@ import type { ...@@ -2,36 +2,20 @@ import type {
FC, FC,
ReactNode, ReactNode,
} from 'react' } from 'react'
import { useState } from 'react'
import { useWorkflowContext } from '../../context' import { useWorkflowContext } from '../../context'
import BlockIcon from '../../block-icon' import BlockIcon from '../../block-icon'
import { getBlockByType } from '../../block-selector/utils' import { getBlockByType } from '../../block-selector/utils'
import NextStep from './components/next-step' import NextStep from './components/next-step'
import { import { XClose } from '@/app/components/base/icons/src/vender/line/general'
LogIn04,
LogOut04,
XClose,
} from '@/app/components/base/icons/src/vender/line/general'
import { GitBranch01 } from '@/app/components/base/icons/src/vender/line/development' import { GitBranch01 } from '@/app/components/base/icons/src/vender/line/development'
enum TabEnum {
Inputs = 'inputs',
Outputs = 'outputs',
}
type BasePanelProps = { type BasePanelProps = {
defaultElement?: ReactNode children?: ReactNode
inputsElement?: ReactNode
outputsElement?: ReactNode
} }
const BasePanel: FC<BasePanelProps> = ({ const BasePanel: FC<BasePanelProps> = ({
defaultElement, children,
inputsElement,
outputsElement,
}) => { }) => {
const initialActiveTab = inputsElement ? TabEnum.Inputs : outputsElement ? TabEnum.Outputs : ''
const [activeTab, setActiveTab] = useState(initialActiveTab)
const { const {
handleSelectedNodeIdChange, handleSelectedNodeIdChange,
selectedNode, selectedNode,
...@@ -61,45 +45,9 @@ const BasePanel: FC<BasePanelProps> = ({ ...@@ -61,45 +45,9 @@ const BasePanel: FC<BasePanelProps> = ({
Add description... Add description...
</div> </div>
</div> </div>
{
(inputsElement || outputsElement) && (
<div className='flex items-center px-4 h-[42px] text-[13px] font-semibold text-gray-400'>
{
inputsElement && (
<div
className={`relative flex items-center h-full cursor-pointer ${activeTab === TabEnum.Inputs && 'text-gray-700'}`}
onClick={() => setActiveTab(TabEnum.Inputs)}
>
<LogIn04 className='mr-1 w-4 h-4' />
INPUTS
{
activeTab === TabEnum.Inputs && <div className='absolute left-0 bottom-0 w-full h-0.5 bg-primary-600' />
}
</div>
)
}
{
outputsElement && (
<div
className={`relative flex items-center ml-4 h-full cursor-pointer ${activeTab === TabEnum.Outputs && 'text-gray-700'}`}
onClick={() => setActiveTab(TabEnum.Outputs)}
>
<LogOut04 className='mr-1 w-4 h-4' />
OUTPUTS
{
activeTab === TabEnum.Outputs && <div className='absolute left-0 bottom-0 w-full h-0.5 bg-primary-600' />
}
</div>
)
}
</div>
)
}
</div> </div>
<div className='py-2 border-b-[0.5px] border-black/5'> <div className='py-2 border-b-[0.5px] border-black/5'>
{defaultElement} {children}
{activeTab === TabEnum.Inputs && inputsElement}
{activeTab === TabEnum.Outputs && outputsElement}
</div> </div>
<div className='p-4'> <div className='p-4'>
<div className='flex items-center mb-1 text-gray-700 text-[13px] font-semibold'> <div className='flex items-center mb-1 text-gray-700 text-[13px] font-semibold'>
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel' ...@@ -3,10 +3,9 @@ import BasePanel from '../_base/panel'
const Panel: FC = () => { const Panel: FC = () => {
return ( return (
<BasePanel <BasePanel>
inputsElement={<div>start panel inputs</div>} <div>start panel inputs</div>
outputsElement={<div>start panel outputs</div>} </BasePanel>
/>
) )
} }
......
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