feat: adjust how we pass image to home hero

pull/680/head
Kia King Ishii 2 years ago
parent a35800dc72
commit 8f7b11f216

@ -8,8 +8,8 @@ export interface HeroAction {
} }
export interface Image { export interface Image {
light: string src: string
dark: string alt?: string
} }
defineProps<{ defineProps<{
@ -44,8 +44,8 @@ defineProps<{
<div v-if="image" class="image"> <div v-if="image" class="image">
<div class="image-container"> <div class="image-container">
<img class="image-src light" :src="image.light"> <div class="image-bg" />
<img class="image-src dark" :src="image.dark"> <img class="image-src" :src="image.src" :alt="image.alt">
</div> </div>
</div> </div>
</div> </div>
@ -56,7 +56,6 @@ defineProps<{
.VPHero { .VPHero {
margin-top: calc(var(--vp-nav-height) * -1); margin-top: calc(var(--vp-nav-height) * -1);
padding: calc(var(--vp-nav-height) + 48px) 24px 48px; padding: calc(var(--vp-nav-height) + 48px) 24px 48px;
overflow: hidden;
} }
@media (min-width: 640px) { @media (min-width: 640px) {
@ -229,6 +228,15 @@ defineProps<{
} }
} }
@media (min-width: 960px) {
.image {
order: 2;
margin: 0;
width: calc(100% / 3);
min-height: 100%;
}
}
.image-container { .image-container {
position: relative; position: relative;
margin: 0 auto; margin: 0 auto;
@ -243,43 +251,60 @@ defineProps<{
} }
} }
.image-src { @media (min-width: 960px) {
.image-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
transform: translate(-32px, -32px);
}
}
.image-bg {
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
max-width: 392px; border-radius: 50%;
width: 192px;
height: 192px;
background-image: var(--vp-home-hero-image-background-image);
filter: var(--vp-home-hero-image-filter);
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.image-src.light { opacity: 1; }
.image-src.dark { opacity: 0; }
.dark .image-src.light { opacity: 0; }
.dark .image-src.dark { opacity: 1; }
@media (min-width: 640px) { @media (min-width: 640px) {
.image-src { .image-bg {
max-width: 512px; width: 256px;
transform: translate(-50%, -50%); height: 256px;
} }
} }
@media (min-width: 960px) { @media (min-width: 960px) {
.image { .image-bg {
order: 2; width: 320px;
margin: -8px 0; height: 320px;
width: calc(100% / 3);
min-height: 100%;
} }
}
.image-container { .image-src {
width: 100%; position: absolute;
height: 100%; top: 50%;
left: 50%;
max-width: 192px;
transform: translate(-50%, -50%);
}
@media (min-width: 640px) {
.image-src {
max-width: 256px;
} }
}
@media (min-width: 960px) {
.image-src { .image-src {
max-width: 640px; max-width: 320px;
transform: translate(calc(-50% - 32px), calc(-50% - 32px));
} }
} }
</style> </style>

@ -347,4 +347,7 @@
:root { :root {
--vp-home-hero-name-color: var(--vp-c-brand); --vp-home-hero-name-color: var(--vp-c-brand);
--vp-home-hero-name-background: transparent; --vp-home-hero-name-background: transparent;
--vp-home-hero-image-background-image: none;
--vp-home-hero-image-filter: none;
} }

Loading…
Cancel
Save