-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refactor: refactor dumi docs layout
- Loading branch information
1 parent
755d714
commit 80fa42f
Showing
39 changed files
with
734 additions
and
410 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,5 +1,6 @@ | ||
--- | ||
title: Changelog | ||
description: New updates and improvements to @lobehub/ui | ||
nav: | ||
title: Changelog | ||
order: 999 | ||
|
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
97 changes: 97 additions & 0 deletions
97
packages/dumi-theme-lobehub/src/components/Toc/TocMobile.tsx
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { ActionIcon } from '@lobehub/ui'; | ||
import { Anchor, AnchorProps, Collapse, ConfigProvider } from 'antd'; | ||
import { useTheme } from 'antd-style'; | ||
import { PanelTopClose, PanelTopOpen } from 'lucide-react'; | ||
import { memo, useMemo } from 'react'; | ||
import useControlledState from 'use-merge-value'; | ||
|
||
import { AnchorItem } from '@/types'; | ||
|
||
import { useStyles } from './style'; | ||
|
||
export interface TocMobileProps { | ||
/** | ||
* @title 当前激活的目录项 key 值 | ||
*/ | ||
activeKey?: string; | ||
getContainer?: AnchorProps['getContainer']; | ||
/** | ||
* @title 目录项列表 | ||
*/ | ||
items: AnchorItem[]; | ||
/** | ||
* @title 目录项切换的回调函数 | ||
* @param activeKey - 切换后的目录项 key 值 | ||
*/ | ||
onChange?: (activeKey: string) => void; | ||
} | ||
const TocMobile = memo<TocMobileProps>(({ items, activeKey, onChange, getContainer }) => { | ||
const [activeLink, setActiveLink] = useControlledState<string>('', { | ||
value: activeKey, | ||
onChange, | ||
}); | ||
const { styles } = useStyles(); | ||
|
||
const theme = useTheme(); | ||
const activeAnchor = items.find((item) => item.id === activeLink); | ||
|
||
const linkItems = useMemo( | ||
() => | ||
items.map((item) => ({ | ||
href: `#${item.id}`, | ||
title: item.title, | ||
key: item.id, | ||
children: item.children?.map((child) => ({ | ||
href: `#${child.id}`, | ||
title: child?.title, | ||
key: child.id, | ||
})), | ||
})), | ||
[items], | ||
); | ||
|
||
return ( | ||
<ConfigProvider theme={{ token: { fontSize: 12, sizeStep: 3 } }}> | ||
<section className={styles.mobileCtn}> | ||
<Collapse | ||
bordered={false} | ||
className={styles.expand} | ||
expandIcon={({ isActive }) => | ||
isActive ? ( | ||
<ActionIcon | ||
icon={PanelTopClose} | ||
size={{ fontSize: 16, strokeWidth: 1, blockSize: 24, borderRadius: 3 }} | ||
/> | ||
) : ( | ||
<ActionIcon | ||
icon={PanelTopOpen} | ||
size={{ fontSize: 16, strokeWidth: 1, blockSize: 24, borderRadius: 3 }} | ||
/> | ||
) | ||
} | ||
expandIconPosition={'end'} | ||
ghost | ||
> | ||
<Collapse.Panel | ||
forceRender | ||
header={!activeAnchor ? 'TOC' : activeAnchor.title} | ||
key={'toc'} | ||
> | ||
<ConfigProvider theme={{ token: { fontSize: 14, sizeStep: 4 } }}> | ||
<Anchor | ||
getContainer={getContainer} | ||
items={linkItems} | ||
onChange={(currentLink) => { | ||
setActiveLink(currentLink.replace('#', '')); | ||
}} | ||
targetOffset={theme.headerHeight + 48} | ||
/> | ||
</ConfigProvider> | ||
</Collapse.Panel> | ||
</Collapse> | ||
</section> | ||
</ConfigProvider> | ||
); | ||
}); | ||
|
||
export default TocMobile; |
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
Oops, something went wrong.
80fa42f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
lobe-ui – ./
lobe-ui.vercel.app
lobe-ui-git-master-lobehub.vercel.app
ui.lobehub.com
lobe-ui-lobehub.vercel.app