Skip to content

Commit

Permalink
Add HeroImage component (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
stormwarning authored Jul 3, 2022
1 parent cef42af commit a20f134
Show file tree
Hide file tree
Showing 10 changed files with 1,563 additions and 17 deletions.
1,532 changes: 1,522 additions & 10 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"build": "vite-ssg build",
"dev": "TAILWIND_MODE=watch vite --port 3333 --open",
"lens": "lens",
"lint": "eslint .",
"preview": "vite preview",
"preview-https": "serve dist",
Expand Down Expand Up @@ -60,6 +61,7 @@
"vue-router": "4.0.16"
},
"devDependencies": {
"@tidaltheory/lens": "0.4.0",
"@typescript-eslint/eslint-plugin": "5.30.3",
"@typescript-eslint/parser": "5.30.3",
"@vitejs/plugin-vue": "2.3.3",
Expand Down
Binary file added public/cosmos-h.69935d14.avif
Binary file not shown.
Binary file added public/cosmos-h.69935d14.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cosmos-h.69935d14.webp
Binary file not shown.
Binary file added public/cosmos-v.ea9ba4ce.avif
Binary file not shown.
Binary file added public/cosmos-v.ea9ba4ce.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/cosmos-v.ea9ba4ce.webp
Binary file not shown.
34 changes: 34 additions & 0 deletions src/components/HeroImage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script setup lang="ts">
function reveal(event: any) {
;(event.target as HTMLElement).classList.toggle('opacity-0')
}
</script>

<template>
<picture>
<source
srcset="/cosmos-v.ea9ba4ce.avif"
type="image/avif"
media="(min-width: 768px)"
/>
<source
srcset="/cosmos-v.ea9ba4ce.webp"
type="image/webp"
media="(min-width: 768px)"
/>
<source
srcset="/cosmos-v.ea9ba4ce.jpg"
type="image/jpeg"
media="(min-width: 768px)"
/>
<source srcset="/cosmos-h.69935d14.avif" type="image/avif" />
<source srcset="/cosmos-h.69935d14.webp" type="image/webp" />
<img
class="h-full max-h-full w-full object-cover opacity-0"
src="/cosmos-h.69935d14.jpg"
loading="lazy"
decoding="async"
@load.once="reveal"
/>
</picture>
</template>
12 changes: 5 additions & 7 deletions src/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import HeroImage from '~/components/HeroImage.vue'
import SlugblasterText from '~/components/SlugblasterText.vue'
</script>

Expand All @@ -10,9 +11,10 @@ import SlugblasterText from '~/components/SlugblasterText.vue'
<router-view />
<div class="relative row-start-1 md:col-start-2">
<div
class="sticky top-0 h-full bg-black bg-cover bg-right"
:class="$style.image"
></div>
class="sticky top-0 h-full bg-black bg-cover bg-right md:h-screen"
>
<hero-image class="opacity-90" />
</div>
</div>

<div class="fixed -top-[13vw] w-full">
Expand All @@ -32,8 +34,4 @@ import SlugblasterText from '~/components/SlugblasterText.vue'
grid-template-rows: 25vh auto;
@apply md:grid-rows-1;
}
.image {
background-image: url('/cosmos.jpg');
}
</style>

0 comments on commit a20f134

Please sign in to comment.