Skip to content

Commit ad9d151

Browse files
committed
Implement a variable height hero for the rise up exhibition
1 parent 9b70707 commit ad9d151

File tree

5 files changed

+62
-4
lines changed

5 files changed

+62
-4
lines changed

public/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/mix-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"/js/app.js": "/js/app.js?id=b8905b220a3026e29c691fbcf7f1ab86",
3-
"/css/app.css": "/css/app.css?id=0b507e855f6ef0d9dc4aab21328475d9",
3+
"/css/app.css": "/css/app.css?id=81ca4c70d8e1a66441ec421a2a8c1814",
44
"/css/fitzwilliam.css": "/css/fitzwilliam.css?id=ac5439ad1da7ccbbd3f994488e57982e"
55
}

resources/sass/exhibition/_hero.scss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,46 @@
1010
.navbar:has(#global-announcement) + .exhibition-hero + .breadcrumbs-su {
1111
margin: 0;
1212
}
13+
14+
/**
15+
* Styles for a hero image that determines the height
16+
* of the hero image based on the height of the image.
17+
*/
18+
.exhibition-hero--variable-height {
19+
20+
// we revert to the default styles on mobile (which uses a CSS background image)
21+
img {
22+
display: none;
23+
}
24+
25+
// the variable height styles only apply to larger screens
26+
@media screen and (min-width: 768px) {
27+
height: auto !important;
28+
29+
.bg-overlay {
30+
background-image: none;
31+
height: auto;
32+
// margin-top takes account of the global navigation bar
33+
margin-top: 90px;
34+
position: relative;
35+
36+
img {
37+
display: block;
38+
object-fit: cover;
39+
width: 100%;
40+
}
41+
42+
// semi-transparent background behind the text for improved colour contrast (accessibility)
43+
&:after {
44+
background: linear-gradient( to top, rgba(0, 0, 0, 0.8) 10%, transparent );
45+
bottom: 0;
46+
content: "";
47+
left: 0;
48+
position: absolute;
49+
right: 0;
50+
top: 0;
51+
}
52+
}
53+
}
54+
55+
}

resources/views/components/exhibition-hero.blade.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@
55
If the end date is today, it will return false until the end of the day (23:59:59).
66
*/
77
$exhibitionStatus = (!empty($hero["end"]) && \Carbon\Carbon::createFromFormat('Y-m-d', $hero["end"])->endOfDay()->isPast());
8+
9+
$heroClasses = '';
10+
11+
if('rise-up' === $hero['exhibition_slug']) {
12+
$heroClasses = 'exhibition-hero--variable-height';
13+
}
814
@endphp
915
@if (!empty($hero))
10-
<div class="parallax home-hero exhibition-hero">
16+
17+
<div class="parallax home-hero exhibition-hero {{ $heroClasses }}">
1118
@if(!empty($hero['image']))
12-
<div class="bg-overlay" style="background: linear-gradient( to top, rgba(0, 0, 0, 0.8) 10%, transparent ), url({{ $hero['image']['data']['url'] }}) no-repeat center center / cover"></div>
19+
{{-- @TODO: We should refactor this so that it uses an img element for both of these instances - background image isn't ideal here --}}
20+
@if(str_contains($heroClasses, 'exhibition-hero--variable-height'))
21+
<div class="bg-overlay" style="background: linear-gradient( to top, rgba(0, 0, 0, 0.8) 10%, transparent ), url({{ $hero['image']['data']['url'] }}) no-repeat center center / cover">
22+
<img src="{{ $hero['image']['data']['url'] }}" alt="">
23+
</div>
24+
@else
25+
<div class="bg-overlay" style="background: linear-gradient( to top, rgba(0, 0, 0, 0.8) 10%, transparent ), url({{ $hero['image']['data']['url'] }}) no-repeat center center / cover"></div>
26+
@endif
1327
@else
1428
<div class="bg-overlay"></div>
1529
@endif

resources/views/exhibitions/details.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
$exhibition_tagline = $exhibition['exhibition_title'];
66
}
77
$hero = [
8+
'exhibition_slug' => $exhibition['slug'],
89
'hero_title' => $exhibition['exhibition_title'],
910
'hero_subtitle' => $exhibition_tagline,
1011
'start' => $exhibition["exhibition_start_date"],

0 commit comments

Comments
 (0)