Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(theme): link in homepage features #1070

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/guide/theme-home-page.md
Expand Up @@ -98,6 +98,10 @@ features:
- icon: 🖖
title: Power of Vue meets Markdown
details: Lorem ipsum...
action:
theme: alt
text: markdown-it
link: https://github.com/markdown-it/markdown-it
- icon: 🛠️
title: Simple and minimal, always
details: Lorem ipsum...
Expand All @@ -115,5 +119,19 @@ interface Feature {

// Details of the feature.
details: string

// Action button to display in home feature section.
action?: FeatureAction
}

interface FeatureAction {
// Color theme of the button. Defaults to `brand`.
theme?: 'brand' | 'alt'

// Label of the button.
text: string

// Destination link of the button.
link: string
}
```
7 changes: 7 additions & 0 deletions src/client/theme-default/components/VPButton.vue
Expand Up @@ -54,6 +54,13 @@ const component = computed(() => {
transition: color 0.1s, border-color 0.1s, background-color 0.1s;
}

.VPButton.small {
border-radius: 16px;
padding: 0 16px;
line-height: 30px;
font-size: 12px;
}

.VPButton.medium {
border-radius: 20px;
padding: 0 20px;
Expand Down
23 changes: 23 additions & 0 deletions src/client/theme-default/components/VPFeature.vue
@@ -1,8 +1,17 @@
<script setup lang="ts">
import VPButton from './VPButton.vue'

export interface FeatureAction {
theme?: 'brand' | 'alt'
text: string
link: string
}

defineProps<{
icon?: string
title: string
details: string
action?: FeatureAction
}>()
</script>

Expand All @@ -11,6 +20,16 @@ defineProps<{
<div v-if="icon" class="icon">{{ icon }}</div>
<h2 class="title">{{ title }}</h2>
<p class="details">{{ details }}</p>
<div class="feature-actions">
<VPButton
v-if="action"
tag="a"
size="small"
:theme="action.theme"
:text="action.text"
:href="action.link"
/>
</div>
</article>
</template>

Expand Down Expand Up @@ -52,4 +71,8 @@ defineProps<{
font-weight: 500;
color: var(--vp-c-text-2);
}

.feature-actions {
padding-top: 16px;
}
</style>
8 changes: 8 additions & 0 deletions src/client/theme-default/components/VPFeatures.vue
Expand Up @@ -6,6 +6,13 @@ export interface Feature {
icon?: string
title: string
details: string
action?: FeatureAction
}

export interface FeatureAction {
theme?: 'brand' | 'alt'
text: string
link: string
}

const props = defineProps<{
Expand Down Expand Up @@ -38,6 +45,7 @@ const grid = computed(() => {
:icon="feature.icon"
:title="feature.title"
:details="feature.details"
:action="feature.action"
/>
</div>
</div>
Expand Down