From ee7fa47f0a7b916e08c545fdc839a1a93d7b7b99 Mon Sep 17 00:00:00 2001 From: Timothy Lau Date: Wed, 17 Apr 2024 10:53:34 +0800 Subject: [PATCH 1/2] feat(default theme): Add icons on action buttons --- docs/index.md | 6 +++ docs/reference/default-theme-home-page.md | 17 +++++++ .../theme-default/components/VPButton.vue | 49 ++++++++++++++++++- .../theme-default/components/VPHero.vue | 4 ++ types/default-theme.d.ts | 16 ++++++ 5 files changed, 90 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 9be32c3e103c..3c7faece1d25 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,12 +12,18 @@ hero: - theme: brand text: What is VitePress? link: /guide/what-is-vitepress + startIcon: + src: /public/vitepress-logo-mini.svg + width: 18 + height: 18 + endIcon: - theme: alt text: Quickstart link: /guide/getting-started - theme: alt text: GitHub link: https://github.com/vuejs/vitepress + endIcon: image: src: /vitepress-logo-large.webp alt: VitePress diff --git a/docs/reference/default-theme-home-page.md b/docs/reference/default-theme-home-page.md index f7baecca0138..3cf9fc96b497 100644 --- a/docs/reference/default-theme-home-page.md +++ b/docs/reference/default-theme-home-page.md @@ -75,7 +75,24 @@ interface HeroAction { // Link rel attribute. rel?: string + + // Show the left icon on action button. + startIcon?: ActionIcon + + // Show the right icon on action button. + endIcon?: ActionIcon } + +type ActionIcon = + | string + | { src: string; alt?: string; width?: string; height: string } + | { + light: string + dark: string + alt?: string + width?: string + height: string + } ``` ### Customizing the name color diff --git a/src/client/theme-default/components/VPButton.vue b/src/client/theme-default/components/VPButton.vue index 3b9152f2f2ba..55d63209403f 100644 --- a/src/client/theme-default/components/VPButton.vue +++ b/src/client/theme-default/components/VPButton.vue @@ -1,7 +1,9 @@