1
0
mirror of https://github.com/Damillora/Yuika synced 2024-11-16 14:57:32 +00:00
Yuika/partials/header-background.hbs

61 lines
2.1 KiB
Handlebars
Raw Normal View History

2019-11-08 20:59:26 +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
2021-04-14 08:24:27 +00:00
with a `no-image` class so we can style it accordingly.
--}}
{{#if background}}
<style type="text/css">
.responsive-header-img {
background-image: url({{img_url background size='xl'}});
background-size: cover;
}
@media(max-width: 1000px) {
.responsive-header-img {
background-image: url({{img_url background size='l'}});
2021-04-14 12:04:44 +00:00
background-position: center;
2021-04-14 08:24:27 +00:00
}
}
@media(max-width: 600px) {
.responsive-header-img {
background-image: url({{img_url background size='m'}});
2021-04-14 12:04:44 +00:00
background-position: center;
2021-04-14 08:24:27 +00:00
}
}
</style>
{{else}}
<style type="text/css">
.responsive-header-img {
background-image: url({{img_url @site.cover_image size='xl'}});
background-size: cover;
}
@media(max-width: 1000px) {
.responsive-header-img {
background-image: url({{img_url @site.cover_image size='l'}});
background-position: center;
}
}
@media(max-width: 600px) {
.responsive-header-img {
background-image: url({{img_url @site.cover_image size='m'}});
background-position: center;
}
}
</style>
2021-04-14 08:24:27 +00:00
2021-04-14 12:04:44 +00:00
{{/if}}