1
0
mirror of https://github.com/Damillora/Yuika synced 2024-11-14 14:07:31 +00:00
Yuika/partials/site-background.hbs

50 lines
2.0 KiB
Handlebars
Raw Normal View History

2020-11-11 04:54:56 +00:00
{{!--
Wow what the hell is going on in here even?
Ok so, several templates use this big header with a giant BG image. Nice idea, but big images
have a heavy impact on performance, so it's a good idea to make them responsive. Because we
can only get the image dynamically using Handlebars, and we can only set the image to properly
be a background image using CSS, we end up with a handful of inline styles.
If the template in question has a background image, then we render responsive image styles
for it, and apply those styles to the <header> tag. Else, we just output a <header> tag
with a `no-image` class so we can style it accordingly.
--}}
{{#if @site.cover_image}}
<style type="text/css">
.responsive-site-header-img {
background-image: url({{img_url @site.cover_image size='xl'}});
}
@media(max-width: 1000px) {
.responsive-site-header-img {
background-image: url({{img_url @site.cover_image size='l'}});
background-image: -webkit-image-set(url({{img_url @site.cover_image size='l'}}) 1x,
url({{img_url @site.cover_image size='xl'}}) 2x);
background-image: image-set(url({{img_url @site.cover_image size='l'}}) 1x,
url({{img_url @site.cover_image size='xl'}}) 2x);
2020-11-11 05:28:51 +00:00
background-position: right 25% top 20%;
2020-11-11 04:54:56 +00:00
}
}
@media(max-width: 600px) {
.responsive-site-header-img {
background-image: url({{img_url @site.cover_image size='m'}});
background-image: -webkit-image-set(url({{img_url @site.cover_image size='m'}}) 1x,
url({{img_url @site.cover_image size='l'}}) 2x);
background-image: image-set(url({{img_url @site.cover_image size='m'}}) 1x,
url({{img_url @site.cover_image size='l'}}) 2x);
2020-11-11 05:28:51 +00:00
background-position: right 25% top 20%;
2020-11-11 04:54:56 +00:00
}
}
</style>
2020-11-11 05:28:51 +00:00
<div class="h-full w-full responsive-site-header-img bg-cover bg-yuika-blue-500">
2020-11-11 04:54:56 +00:00
{{else}}
<div class="h-full w-full no-image">
{{/if}}