types: fix theme typings

pull/672/head
Kia King Ishii 3 years ago
parent 57d6a7bd72
commit 0cacee70d0

@ -19,6 +19,10 @@ declare module '@docsearch/js' {
export default docsearch
}
declare module '@docsearch/react/dist/esm/types' {
export type DocSearchHit = any
}
declare module '@docsearch/css' {
const css: string
export default css

@ -1,12 +1,11 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { DefaultTheme } from 'vitepress'
import { useFlyout } from '../composables/flyout'
import VPIconChevronDown from './icons/VPIconChevronDown.vue'
import VPIconMoreHorizontal from './icons/VPIconMoreHorizontal.vue'
import VPMenu from './VPMenu.vue'
const props = defineProps<{
defineProps<{
icon?: any
button?: string
label?: string

@ -1,7 +1,7 @@
<script setup lang="ts">
import VPButton from './VPButton.vue'
interface HeroAction {
export interface HeroAction {
theme?: 'brand' | 'alt'
text: string
link: string

@ -3,13 +3,13 @@ import VPIconHeart from './icons/VPIconHeart.vue'
import VPButton from './VPButton.vue'
import VPSponsors from './VPSponsors.vue'
interface Sponsors {
export interface Sponsors {
tier: string
size?: 'medium' | 'big'
items: Sponsor[]
}
interface Sponsor {
export interface Sponsor {
name: string
img: string
url: string

@ -1,18 +1,12 @@
<script lang="ts" setup>
import { DefaultTheme, useData } from 'vitepress'
import { isActive } from '../support/utils'
import { DefaultTheme } from '../config'
import VPFlyout from './VPFlyout.vue'
defineProps<{
item: DefaultTheme.NavItemWithChildren
}>()
const { page } = useData()
</script>
<template>
<VPFlyout
:button="item.text"
:items="item.items"
/>
<VPFlyout :button="item.text" :items="item.items" />
</template>

@ -1,13 +1,12 @@
<script lang="ts" setup>
import { computed, ref } from 'vue'
import { DefaultTheme } from 'vitepress'
import VPIconPlus from './icons/VPIconPlus.vue'
import VPNavScreenMenuGroupLink from './VPNavScreenMenuGroupLink.vue'
import VPNavScreenMenuGroupSection from './VPNavScreenMenuGroupSection.vue'
const props = defineProps<{
text: string
items: DefaultTheme.NavItemChild[]
items: any[]
}>()
const isOpen = ref(false)

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { DefaultTheme } from 'vitepress'
import { DefaultTheme } from '../config'
import VPNavScreenMenuGroupLink from './VPNavScreenMenuGroupLink.vue'
defineProps<{

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { ref } from 'vue'
import { DefaultTheme } from '../config'
import VPIconPlusSquare from './icons/VPIconPlusSquare.vue'
import VPIconMinusSquare from './icons/VPIconMinusSquare.vue'

@ -1,5 +1,5 @@
<script lang="ts" setup>
import { DefaultTheme } from 'vitepress'
import { DefaultTheme } from '../config'
import VPIconDiscord from './icons/VPIconDiscord.vue'
import VPIconFacebook from './icons/VPIconFacebook.vue'
import VPIconGitHub from './icons/VPIconGitHub.vue'
@ -9,7 +9,7 @@ import VPIconSlack from './icons/VPIconSlack.vue'
import VPIconTwitter from './icons/VPIconTwitter.vue'
import VPIconYouTube from './icons/VPIconYouTube.vue'
const props = defineProps<{
defineProps<{
icon: DefaultTheme.SocialLinkIcon
link: string
}>()

@ -2,13 +2,13 @@
import { computed } from 'vue'
import VPSponsorsGrid from './VPSponsorsGrid.vue'
interface Sponsors {
export interface Sponsors {
tier?: string
size?: 'small' | 'medium' | 'big'
items: Sponsor[]
}
interface Sponsor {
export interface Sponsor {
name: string
img: string
url: string
@ -17,7 +17,7 @@ interface Sponsor {
const props = defineProps<{
tier?: string
size?: 'small' | 'medium' | 'big'
data: Sposors[] | Sponsor[]
data: Sponsors[] | Sponsor[]
}>()
const sponsors = computed(() => {

@ -2,7 +2,7 @@
import { ref } from 'vue'
import { useSponsorsGrid } from '../composables/sponsor-grid'
interface Sponsor {
export interface Sponsor {
name: string
img: string
url: string

@ -45,7 +45,10 @@ export function useSidebar() {
* a11y: cache the element that opened the Sidebar (the menu button) then
* focus that button again when Menu is closed with Escape key.
*/
export function useCloseSidebarOnEscape(isOpen: Ref<boolean>, close: () => {}) {
export function useCloseSidebarOnEscape(
isOpen: Ref<boolean>,
close: () => void
) {
let triggerElement: HTMLButtonElement | undefined
watchEffect(() => {

@ -9,7 +9,7 @@ export type GridSize = 'small' | 'medium' | 'big'
export interface UseSponsorsGridOprions {
el: Ref<HTMLElement | null>
size: GridSize
size?: GridSize
}
/**
@ -44,7 +44,10 @@ const GridSettings: GridSetting = {
]
}
export function useSponsorsGrid(options: UseSponsorsGridOprions) {
export function useSponsorsGrid({
el,
size = 'medium'
}: UseSponsorsGridOprions) {
const onResize = throttleAndDebounce(manage, 100)
onMounted(() => {
@ -57,7 +60,7 @@ export function useSponsorsGrid(options: UseSponsorsGridOprions) {
})
function manage() {
adjustSlots(options.el.value!, options.size)
adjustSlots(el.value!, size)
}
}

8
theme.d.ts vendored

@ -1,9 +1,13 @@
// so that users can do `import DefaultTheme from 'vitepress/theme'`
import { ComponentOptions } from 'vue'
declare const defaultTheme: {
export const VPHomeHero = ComponentOptions
export const VPHomeFeatures = ComponentOptions
export const VPHomeSponsors = ComponentOptions
declare const theme: {
Layout: ComponentOptions
NotFound: ComponentOptions
}
export default defaultTheme
export default theme

Loading…
Cancel
Save