11import * as React from 'react'
22import { useState , useCallback } from 'react'
3- import { ButtonGroup , Button , Icon , IconName } from '@blueprintjs/core'
43import { observer } from 'mobx-react'
54import { MenuItemConstructorOptions , ipcRenderer } from 'electron'
65import { useTranslation } from 'react-i18next'
@@ -10,8 +9,17 @@ import { sendFakeCombo } from '$src/utils/keyboard'
109import { showAlertModal } from '$src/components/AppAlert'
1110import { LocalizedError } from '$src/locale/error'
1211import { useStores } from '$src/hooks/useStores'
13- import { UserHomeIcons } from '$src/constants/icons'
12+ import { UserHomeIcons , UserHomeIconsTabler } from '$src/constants/icons'
13+ import { ActionIcon , Button as Button2 , Flex } from '@mantine/core'
1414import { ALL_DIRS } from '$src/utils/platform'
15+ import {
16+ Icon ,
17+ IconProps ,
18+ IconFolder ,
19+ IconFolderExclamation ,
20+ IconSquareRoundedX ,
21+ IconCirclePlusFilled ,
22+ } from '@tabler/icons-react'
1523
1624/**
1725 * build a list of { regex, IconName } to match folders with an icon
@@ -23,17 +31,19 @@ import { ALL_DIRS } from '$src/utils/platform'
2331 */
2432export const TabIcons = Object . keys ( UserHomeIcons ) . map ( ( dirname : string ) => ( {
2533 regex : new RegExp ( `^${ ALL_DIRS [ dirname ] } $` ) ,
26- icon : UserHomeIcons [ dirname ] ,
34+ icon : UserHomeIconsTabler [ dirname ] ,
2735} ) )
2836
29- export const getTabIcon = ( path : string ) : IconName => {
37+ export const getTabIconTabler = (
38+ path : string ,
39+ ) : React . ForwardRefExoticComponent < IconProps & React . RefAttributes < Icon > > => {
3040 for ( const obj of TabIcons ) {
3141 if ( obj . regex . test ( path ) ) {
32- return obj . icon as IconName
42+ return obj . icon
3343 }
3444 }
3545
36- return 'folder-close'
46+ return IconFolder
3747}
3848
3949const TabList = observer ( ( ) => {
@@ -44,7 +54,7 @@ const TabList = observer(() => {
4454 useIpcRendererListener (
4555 'context-menu-tab-list:click' ,
4656 useCallback (
47- ( event , command , param ) => {
57+ ( _ , command , param ) => {
4858 if ( ! viewState ?. isActive ) {
4959 return
5060 }
@@ -180,55 +190,47 @@ const TabList = observer(() => {
180190 // whenever the language has changed
181191
182192 return (
183- < ButtonGroup fill className = "tablist" alignText = "center" >
193+ < Button2 . Group flex = { 0 } >
184194 { caches . map ( ( cache , index ) => {
185- const closeIcon = caches . length > 1 && (
186- < Icon
187- iconSize = { 12 }
188- htmlTitle = { t ( 'TABS.CLOSE' ) }
189- className = "closetab"
190- intent = "warning"
195+ const closeIcon = cache . isVisible && caches . length > 1 && (
196+ < IconSquareRoundedX
197+ size = { 16 }
191198 onClick = { ( e ) => {
192199 e . stopPropagation ( )
193200 closeTab ( index , e )
194201 } }
195- icon = "cross"
196- > </ Icon >
202+ />
197203 )
198204 const path = cache . path
199- const tabIcon = cache . error ? 'issue' : getTabIcon ( path )
205+ const TabIcon = cache . error ? IconFolderExclamation : getTabIconTabler ( path )
200206 const tabInfo = ( cache . getFS ( ) && cache . getFS ( ) . displaypath ( path ) ) || {
201207 fullPath : '' ,
202208 shortPath : '' ,
203209 }
204210
205211 return (
206- < Button
212+ < Button2
207213 key = { '' + viewId + index }
208214 onContextMenu = { ( ) => onContextMenu ( index ) }
209215 onClick = { ( ) => selectTab ( index ) }
210216 title = { tabInfo . fullPath }
211- intent = { cache . isVisible ? 'primary' : 'none' }
212- rightIcon = { closeIcon }
217+ leftSection = { < TabIcon size = { 16 } onContextMenu = { ( e ) => onFolderContextMenu ( index , e ) } /> }
218+ rightSection = { closeIcon }
219+ radius = "0"
220+ variant = { cache . isVisible ? 'filled' : 'default' }
213221 className = "tab"
222+ bd = "xl"
214223 >
215- < Icon
216- onContextMenu = { ( e ) => onFolderContextMenu ( index , e ) }
217- className = "folder"
218- icon = { tabIcon }
219- > </ Icon >
220224 { tabInfo . shortPath }
221- </ Button >
225+ </ Button2 >
222226 )
223227 } ) }
224- < Button
225- icon = "add"
226- className = "addtab"
227- minimal
228- title = { t ( 'TABS.NEW' ) }
229- onClick = { ( ) => addTab ( viewState . getVisibleCacheIndex ( ) ) }
230- > </ Button >
231- </ ButtonGroup >
228+ < Flex align = "center" mx = "sm" >
229+ < ActionIcon variant = "white" radius = "xl" title = { t ( 'TABS.NEW' ) } size = "sm" >
230+ < IconCirclePlusFilled stroke = { 1.5 } onClick = { ( ) => addTab ( viewState . getVisibleCacheIndex ( ) ) } />
231+ </ ActionIcon >
232+ </ Flex >
233+ </ Button2 . Group >
232234 )
233235} )
234236
0 commit comments