diff --git a/.gitignore b/.gitignore index 8a39e24..dbdea4d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist TODOs.md .DS_Store demo/.vitepress/cache +.idea diff --git a/src/core/components/VTFlyout.vue b/src/core/components/VTFlyout.vue index f835c9a..5f6b657 100644 --- a/src/core/components/VTFlyout.vue +++ b/src/core/components/VTFlyout.vue @@ -1,15 +1,17 @@ @@ -20,6 +22,7 @@ const isExternal = computed(() => props.href && /^[a-z]+:/i.test(props.href)) :rel="isExternal ? 'noopener noreferrer' : undefined" > + diff --git a/src/core/components/VTMenuBadge.vue b/src/core/components/VTMenuBadge.vue new file mode 100644 index 0000000..2a20e59 --- /dev/null +++ b/src/core/components/VTMenuBadge.vue @@ -0,0 +1,9 @@ + + + diff --git a/src/core/components/VTMenuLink.vue b/src/core/components/VTMenuLink.vue index 98bc917..2898b79 100644 --- a/src/core/components/VTMenuLink.vue +++ b/src/core/components/VTMenuLink.vue @@ -6,7 +6,7 @@ defineProps<{ item: MenuItemWithLink }>() diff --git a/src/core/styles/index.css b/src/core/styles/index.css index 80a5be3..5e38afa 100644 --- a/src/core/styles/index.css +++ b/src/core/styles/index.css @@ -10,6 +10,7 @@ @import './vt-hamburger.css'; @import './vt-link.css'; @import './vt-menu.css'; +@import './vt-menu-badge.css'; @import './vt-menu-group.css'; @import './vt-menu-link.css'; @import './vt-locales.css'; diff --git a/src/core/styles/vt-menu-badge.css b/src/core/styles/vt-menu-badge.css new file mode 100644 index 0000000..2cafb02 --- /dev/null +++ b/src/core/styles/vt-menu-badge.css @@ -0,0 +1,35 @@ +.vt-menu-badge { + display: inline-block; + padding: 3.5px 4px; + margin-left: 6px; + font-size: 10px; + font-style: normal; + font-weight: 600; + line-height: 1; + letter-spacing: .2px; + border-radius: 6px; + background: var(--vt-c-blue); + color: var(--vt-c-white-soft); +} + +.vt-menu-badge.secondary { + background: var(--vt-c-gray-light-5); + color: var(--vt-c-blue-dark); +} + +.vt-menu-badge.success { + background: var(--vt-c-green); +} + +.vt-menu-badge.info { + background: var(--vt-c-indigo-soft); +} + +.vt-menu-badge.warning { + background: var(--vt-c-yellow-light); + color: var(--vt-c-black-soft); +} + +.vt-menu-badge.danger { + background: var(--vt-c-red); +} diff --git a/src/core/types/menu.ts b/src/core/types/menu.ts index d14b6cb..536ccee 100644 --- a/src/core/types/menu.ts +++ b/src/core/types/menu.ts @@ -3,6 +3,7 @@ export type MenuItem = MenuItemWithLink | MenuItemWithChildren export interface MenuItemWithLink { text: string link: string + badge?: MenuBadgeItem } export interface MenuItemWithChildren { @@ -17,6 +18,11 @@ export interface MenuItemChildWithChildren { items: MenuItemWithLink[] } +export interface MenuBadgeItem { + text: string + type?: 'primary' | 'secondary' | 'success' | 'info' | 'warning' | 'danger' +} + export type LocaleLinkItem = MenuItemWithLink & { repo?: string isTranslationsDesc?: boolean diff --git a/src/vitepress/components/VPNavBarMenuGroup.vue b/src/vitepress/components/VPNavBarMenuGroup.vue index 236470c..a618b1a 100644 --- a/src/vitepress/components/VPNavBarMenuGroup.vue +++ b/src/vitepress/components/VPNavBarMenuGroup.vue @@ -18,6 +18,7 @@ const { page } = useData() active: isActive(page.relativePath, item.activeMatch, true) }" :button="item.text" + :badge="item.badge" :items="item.items" /> diff --git a/src/vitepress/components/VPNavBarMenuLink.vue b/src/vitepress/components/VPNavBarMenuLink.vue index bb8f691..62a9a8f 100644 --- a/src/vitepress/components/VPNavBarMenuLink.vue +++ b/src/vitepress/components/VPNavBarMenuLink.vue @@ -22,6 +22,7 @@ const { page } = useData() ) }" :href="item.link" + :badge="item.badge" :noIcon="true" > {{ item.text }} diff --git a/src/vitepress/components/VPNavScreenMenu.vue b/src/vitepress/components/VPNavScreenMenu.vue index 3c8ae9c..3ac1bc3 100644 --- a/src/vitepress/components/VPNavScreenMenu.vue +++ b/src/vitepress/components/VPNavScreenMenu.vue @@ -12,11 +12,13 @@ const { config } = useConfig() diff --git a/src/vitepress/components/VPNavScreenMenuGroup.vue b/src/vitepress/components/VPNavScreenMenuGroup.vue index 6f9c709..fe9e21f 100644 --- a/src/vitepress/components/VPNavScreenMenuGroup.vue +++ b/src/vitepress/components/VPNavScreenMenuGroup.vue @@ -1,11 +1,13 @@ diff --git a/src/vitepress/components/VPNavScreenMenuGroupSection.vue b/src/vitepress/components/VPNavScreenMenuGroupSection.vue index 936dbeb..6d1311a 100644 --- a/src/vitepress/components/VPNavScreenMenuGroupSection.vue +++ b/src/vitepress/components/VPNavScreenMenuGroupSection.vue @@ -16,6 +16,7 @@ defineProps<{ :key="item.text" :text="item.text" :link="item.link" + :badge="item.badge" /> diff --git a/src/vitepress/components/VPNavScreenMenuLink.vue b/src/vitepress/components/VPNavScreenMenuLink.vue index 279ce4d..a9edc6b 100644 --- a/src/vitepress/components/VPNavScreenMenuLink.vue +++ b/src/vitepress/components/VPNavScreenMenuLink.vue @@ -1,17 +1,18 @@ diff --git a/src/vitepress/components/VPSidebar.vue b/src/vitepress/components/VPSidebar.vue index 30d7914..c7ae996 100644 --- a/src/vitepress/components/VPSidebar.vue +++ b/src/vitepress/components/VPSidebar.vue @@ -35,7 +35,7 @@ watchPostEffect(async () => { config.i18n?.ariaSidebarNav ?? 'Sidebar Navigation' }}
- +
diff --git a/src/vitepress/components/VPSidebarGroup.vue b/src/vitepress/components/VPSidebarGroup.vue index 9f9014f..a749c1d 100644 --- a/src/vitepress/components/VPSidebarGroup.vue +++ b/src/vitepress/components/VPSidebarGroup.vue @@ -1,11 +1,13 @@