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 export default docsearch
} }
declare module '@docsearch/react/dist/esm/types' {
export type DocSearchHit = any
}
declare module '@docsearch/css' { declare module '@docsearch/css' {
const css: string const css: string
export default css export default css

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

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

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

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

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

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

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

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

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

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

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

@ -9,7 +9,7 @@ export type GridSize = 'small' | 'medium' | 'big'
export interface UseSponsorsGridOprions { export interface UseSponsorsGridOprions {
el: Ref<HTMLElement | null> 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) const onResize = throttleAndDebounce(manage, 100)
onMounted(() => { onMounted(() => {
@ -57,7 +60,7 @@ export function useSponsorsGrid(options: UseSponsorsGridOprions) {
}) })
function manage() { 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'` // so that users can do `import DefaultTheme from 'vitepress/theme'`
import { ComponentOptions } from 'vue' import { ComponentOptions } from 'vue'
declare const defaultTheme: { export const VPHomeHero = ComponentOptions
export const VPHomeFeatures = ComponentOptions
export const VPHomeSponsors = ComponentOptions
declare const theme: {
Layout: ComponentOptions Layout: ComponentOptions
NotFound: ComponentOptions NotFound: ComponentOptions
} }
export default defaultTheme export default theme

Loading…
Cancel
Save