mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
UI: Replace secondary link items with icon link items
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user