UI: Replace secondary link items with icon link items

This commit is contained in:
fuma-nama
2024-07-25 22:32:04 +08:00
parent c901e6bdb2
commit f8680180fa
4 changed files with 17 additions and 13 deletions
+9
View File
@@ -0,0 +1,9 @@
---
'fumadocs-ui': major
---
**Replace `secondary` link items with `icon` link items**
**why:** Link items with type `secondary` has been deprecated long time ago.
**migrate:** Replace type `secondary` with `icon`.
@@ -60,8 +60,7 @@ export type LinkItemType =
text: ReactNode;
})
| (BaseLinkItem & {
// TODO: Replace secondary type with icon (next major)
type: 'icon' | 'secondary';
type: 'icon';
/**
* `aria-label` of icon button
*/
@@ -176,7 +175,7 @@ export function LinkItem({
activeType !== 'none' &&
isActive(item.url, pathname, activeType === 'nested-url');
if ((item.type === 'secondary' || item.type === 'icon') && on === 'nav') {
if (item.type === 'icon' && on === 'nav') {
return (
<Link
aria-label={item.label}
+6 -1
View File
@@ -16,7 +16,6 @@ import { ThemeToggle } from '@/components/layout/theme-toggle';
import { NavBox, Title } from '@/components/layout/nav';
import { cn } from '@/utils/cn';
import { buttonVariants } from '@/theme/variants';
import { isSecondary } from '@/utils/shared';
import type { SharedNavProps } from '@/layout.shared';
export function Nav({
@@ -78,3 +77,9 @@ export function Nav({
</NavBox>
);
}
function isSecondary(item: LinkItemType): boolean {
return (
('secondary' in item && item.secondary === true) || item.type === 'icon'
);
}
-9
View File
@@ -1,6 +1,5 @@
import type { PageTree } from 'fumadocs-core/server';
import type { ReactNode } from 'react';
import type { LinkItemType } from '@/components/layout/link-item';
export const defaultImageSizes =
'(max-width: 768px) 100vw, (max-width: 1200px) 70vw, 800px';
@@ -40,11 +39,3 @@ export function hasActive(items: PageTree.Node[], url: string): boolean {
return false;
});
}
export function isSecondary(item: LinkItemType): boolean {
return (
('secondary' in item && item.secondary === true) ||
item.type === 'secondary' ||
item.type === 'icon'
);
}