feat: add altAction for home

pull/198/head
Evan You 4 years ago
parent 8a2ff33bf8
commit 9a17ddfdfb

@ -1,17 +1,23 @@
<template> <template>
<header v-if="showHero" class="home-hero"> <header v-if="showHero" class="home-hero">
<figure v-if="$frontmatter.heroImage" class="figure"> <figure v-if="$frontmatter.heroImage" class="figure">
<img <img class="image" :src="$withBase($frontmatter.heroImage)" :alt="$frontmatter.heroAlt" />
class="image"
:src="$withBase($frontmatter.heroImage)"
:alt="$frontmatter.heroAlt"
>
</figure> </figure>
<h1 v-if="hasHeroText" class="title">{{ heroText }}</h1> <h1 v-if="hasHeroText" class="title">{{ heroText }}</h1>
<p v-if="hasTagline" class="description">{{ tagline }}</p> <p v-if="hasTagline" class="description">{{ tagline }}</p>
<NavLink v-if="hasAction" :item="action" class="action" /> <NavLink
v-if="hasAction"
:item="{ link: data.actionLink, text: data.actionText }"
class="action"
/>
<NavLink
v-if="hasAltAction"
:item="{ link: data.altActionLink, text: data.altActionText }"
class="action alt"
/>
</header> </header>
</template> </template>
@ -37,10 +43,7 @@ const hasTagline = computed(() => data.value.tagline !== null)
const tagline = computed(() => data.value.tagline || site.value.description) const tagline = computed(() => data.value.tagline || site.value.description)
const hasAction = computed(() => data.value.actionLink && data.value.actionText) const hasAction = computed(() => data.value.actionLink && data.value.actionText)
const action = computed(() => ({ const hasAltAction = computed(() => data.value.altActionLink && data.value.altActionText)
link: data.value.actionLink,
text: data.value.actionText,
}))
</script> </script>
<style scoped> <style scoped>
@ -93,7 +96,7 @@ const action = computed(() => ({
.description { .description {
margin: 0; margin: 0;
margin-top: .25rem; margin-top: 0.25rem;
line-height: 1.3; line-height: 1.3;
font-size: 1.2rem; font-size: 1.2rem;
color: var(--c-text-light); color: var(--c-text-light);
@ -108,24 +111,36 @@ const action = computed(() => ({
.action { .action {
margin-top: 1.5rem; margin-top: 1.5rem;
display: inline-block;
}
.action.alt {
margin-left: 1.5rem;
} }
@media (min-width: 420px) { @media (min-width: 420px) {
.action { .action {
margin-top: 2rem; margin-top: 2rem;
display: inline-block;
} }
} }
.action :deep(.item) { .action :deep(.item) {
display: inline-block; display: inline-block;
border-radius: 4px; border-radius: 6px;
padding: 0 20px; padding: 0 20px;
line-height: 48px; line-height: 44px;
font-size: 1rem; font-size: 1rem;
font-weight: 500; font-weight: 500;
color: #ffffff; color: #ffffff;
background-color: var(--c-brand); background-color: var(--c-brand);
transition: background-color .1s ease; border: 2px solid var(--c-brand);
transition: background-color 0.1s ease;
}
.action.alt :deep(.item) {
background-color: #fff;
color: var(--c-brand);
} }
.action :deep(.item:hover) { .action :deep(.item:hover) {
@ -137,7 +152,7 @@ const action = computed(() => ({
@media (min-width: 420px) { @media (min-width: 420px) {
.action :deep(.item) { .action :deep(.item) {
padding: 0 24px; padding: 0 24px;
line-height: 56px; line-height: 52px;
font-size: 1.2rem; font-size: 1.2rem;
font-weight: 500; font-weight: 500;
} }

Loading…
Cancel
Save