Skip to content

Commit

Permalink
feat(core): dynamic render tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
NWYLZW committed Oct 10, 2023
1 parent 9250b27 commit fea4964
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions core/src/plugins/mpa/topbar/Files.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
import './Files.scss'

import type { ReactNode } from 'react'
import { useState } from 'react'

import type { BarItemProps } from '../..'

const prefix = 'mpa__topbar__files'

interface Tab {
id: string
icon?: string | ReactNode
title: ReactNode
}

export const Files: React.ComponentType<BarItemProps> = () => {
const [tabs, setTabs] = useState<Tab[]>([
{ id: 'index.ts', title: 'index.ts', icon: 'file' },
{ id: 'index.spec.ts', title: 'index.spec.ts', icon: 'beaker' }
])
return <div className={prefix}>
<div className={`${prefix}-tab active`}>
<span className='cldr codicon codicon-file' />
index.ts
<span className='cldr codicon codicon-close' />
</div>
<div className={`${prefix}-tab`}>
<span className='cldr codicon codicon-file' />
index.spec.ts
{tabs.map(tab => <div className={`${prefix}-tab`} key={tab.id}>
{tab.icon && typeof tab.icon === 'string'
? <span className={`cldr codicon codicon-${tab.icon}`} />
: tab.icon}
{tab.title}
<span className='cldr codicon codicon-close' />
</div>
</div>)}
<div className={`${prefix}-full`} />
</div>
}

0 comments on commit fea4964

Please sign in to comment.