-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor(wip): refactor with @lobehub/ui
- Loading branch information
1 parent
e9e51e6
commit e116458
Showing
8 changed files
with
874 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require('@lobehub/lint/dist/semantic-release'); | ||
module.exports = require('@lobehub/lint').semanticRelease; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,33 @@ | ||
import type {MenuProps} from 'antd'; | ||
import {Menu} from 'antd'; | ||
import {TabsNav, type TabsNavProps} from '@lobehub/ui'; | ||
import {memo, useEffect, useState} from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
/****************************************************** | ||
*********************** Style ************************* | ||
******************************************************/ | ||
const getNavButtons: HTMLButtonElement[] | any = () => | ||
gradioApp().querySelectorAll('#tabs > .tab-nav:first-child button') || []; | ||
|
||
const NavBar = styled(Menu)` | ||
overflow: hidden; | ||
flex: 1; | ||
line-height: 1; | ||
border: none; | ||
.ant-menu-overflow-item { | ||
padding: 8px 12px; | ||
color: var(--color-text-secondary); | ||
border-radius: 4px !important; | ||
&::after { | ||
display: none !important; | ||
} | ||
&:hover { | ||
color: var(--color-text); | ||
background: var(--color-fill-tertiary); | ||
} | ||
&.ant-menu-item-selected { | ||
font-weight: 600; | ||
color: var(--color-text); | ||
} | ||
} | ||
`; | ||
|
||
/****************************************************** | ||
************************* Dom ************************* | ||
******************************************************/ | ||
|
||
const onClick: MenuProps['onClick'] = (e: any) => { | ||
const buttons: HTMLButtonElement[] | any = gradioApp().querySelectorAll( | ||
'#tabs > .tab-nav:first-child button', | ||
); | ||
buttons[Number(e.key)]?.click(); | ||
const onChange: TabsNavProps['onChange'] = (activeKey) => { | ||
const buttons = getNavButtons(); | ||
buttons[Number(activeKey)]?.click(); | ||
}; | ||
|
||
const Nav = memo(() => { | ||
const [items, setItems] = useState<MenuProps['items']>([]); | ||
const [items, setItems] = useState<TabsNavProps['items']>([]); | ||
|
||
useEffect(() => { | ||
onUiLoaded(() => { | ||
const buttons = gradioApp().querySelectorAll('#tabs > .tab-nav:first-child button'); | ||
const list: MenuProps['items'] | any = []; | ||
buttons.forEach((button: HTMLButtonElement | any, index) => { | ||
const buttons = getNavButtons(); | ||
const list: TabsNavProps['items'] | any = []; | ||
buttons.forEach((button: HTMLButtonElement | any, index: number) => { | ||
button.id = `kitchen-nav-${index}`; | ||
list.push({ | ||
key: String(index), | ||
label: button.textContent, | ||
}); | ||
}); | ||
setItems(list); | ||
setItems(list.filter(Boolean)); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<NavBar | ||
defaultActiveFirst | ||
defaultSelectedKeys={['0']} | ||
items={items} | ||
mode="horizontal" | ||
onClick={onClick} | ||
/> | ||
); | ||
return <TabsNav items={items} onChange={onChange} />; | ||
}); | ||
|
||
export default Nav; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.