Skip to content

Commit d8abe45

Browse files
committed
TabList: rewrite using mantine
1 parent 309859f commit d8abe45

File tree

5 files changed

+100
-83
lines changed

5 files changed

+100
-83
lines changed

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# .npmrc
2+
engine-strict=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v24.3.0

package-lock.json

Lines changed: 56 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "4.0.0-rc.1",
44
"description": "Plugin-based file explorer written with React",
55
"main": "build/main.js",
6+
"engines" : {
7+
"node" : ">=24.3.0"
8+
},
69
"build": {
710
"productName": "React-Explorer",
811
"appId": "reactexplorer",
@@ -113,8 +116,8 @@
113116
"typescript": "^5.8.3",
114117
"url-loader": "^4.1.1",
115118
"wait-on": "^3.3.0",
116-
"webpack": "^5.74.0",
117-
"webpack-cli": "^4.10.0"
119+
"webpack": "^5.99.9",
120+
"webpack-cli": "^5.1.4"
118121
},
119122
"dependencies": {
120123
"@babel/runtime": "^7.20.1",

src/components/TabList.tsx

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react'
22
import { useState, useCallback } from 'react'
3-
import { ButtonGroup, Button, Icon, IconName } from '@blueprintjs/core'
43
import { observer } from 'mobx-react'
54
import { MenuItemConstructorOptions, ipcRenderer } from 'electron'
65
import { useTranslation } from 'react-i18next'
@@ -10,8 +9,17 @@ import { sendFakeCombo } from '$src/utils/keyboard'
109
import { showAlertModal } from '$src/components/AppAlert'
1110
import { LocalizedError } from '$src/locale/error'
1211
import { 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'
1414
import { 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
*/
2432
export 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

3949
const 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

Comments
 (0)