Skip to content

Commit

Permalink
webp for background static header
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Nov 21, 2024
1 parent 2103c1d commit f974945
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 31 deletions.
12 changes: 9 additions & 3 deletions components/ui/static-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,16 @@ class StaticHeader extends React.Component {
return (
<div
className={`c-static-header ${customClasses}`}
style={{
backgroundImage: `url(${background})`,
}}
>
<div className="c-static-background">
<picture>
{/* make sure webp image is also available */}
<source type="image/webp" srcSet={background.replace('.jpg', '.webp')} />
<source type="image/jpeg" srcSet={background} />
<img src={background} alt="" />
</picture>
</div>

{tabs ? (
<div className="wrapper">
<div className="container">
Expand Down
4 changes: 1 addition & 3 deletions css/components/page/_static-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
width: 100%;
min-height: 220px;

background-size: cover;
background-repeat: no-repeat;
background-position: center;
position: relative;

text-align: center;

Expand Down
50 changes: 25 additions & 25 deletions css/components/page/_static-section.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@
height: 80vh;
max-height: 720px;
}
}

.c-static-background {
display: block;
overflow: hidden;
.c-static-background {
display: block;
overflow: hidden;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
box-sizing: border-box;
margin: 0;

img {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
box-sizing: border-box;
margin: 0;

img {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
box-sizing: border-box;
padding: 0;
border: none;
margin: auto;
display: block;
width: 0;
height: 0;
min-width: 100%;
max-width: 100%;
min-height: 100%;
max-height: 100%;
object-fit: cover;
object-position: center;
}
padding: 0;
border: none;
margin: auto;
display: block;
width: 0;
height: 0;
min-width: 100%;
max-width: 100%;
min-height: 100%;
max-height: 100%;
object-fit: cover;
object-position: center;
}
}
Binary file added public/static/images/static-header/bg-about.webp
Binary file not shown.
Binary file added public/static/images/static-header/bg-help.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit f974945

Please sign in to comment.