Skip to content

Commit

Permalink
Merge pull request #333 from torchbox/feature/twe-8-division-page-fe
Browse files Browse the repository at this point in the history
TWE-8 | FE | Division page
  • Loading branch information
albinazs authored Jan 14, 2025
2 parents 1e0359b + 0072a1b commit 252bc62
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{% load wagtailcore_tags wagtailimages_tags %}
<div>
{% for item in value.images %}
{% srcset_image item.image format-webp loading="lazy" fill-{100x100} alt=item.image.alt_text %}
{% endfor %}
<div class="grid__four-photo-collage four-photo-collage">
{# Note the tabindex is important here as it makes the div focussable, meaning that the scrollbar can be operated with the keyboard #}
<div class="four-photo-collage__scroller" tabindex="0">
<div class="four-photo-collage__container">
{% for item in value.images %}
<div class="four-photo-collage__image-wrapper four-photo-collage__image-wrapper--{{ forloop.counter }}">
{% srcset_image item.image format-webp loading="lazy" fill-{500x500,600x600} sizes="(max-width: 1022px) 600px, 500px" class="four-photo-collage__image" alt=item.alt_text %}
</div>
{% endfor %}
</div>
</div>
{% if value.caption %}
{{ value.caption|richtext }}
<div class="heading heading--three heading--light four-photo-collage__caption rich-text">{{ value.caption|richtext }}</div>
{% endif %}
{% if value.description %}
{{ value.description|richtext }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ context:

tags:
srcset_image:
item.image format-webp loading="lazy" fill-{100x100} alt=item.image.alt_text:
'item.image format-webp loading="lazy" fill-{500x500,600x600} sizes="(max-width: 1022px) 600px, 500px" class="four-photo-collage__image" alt=item.alt_text':
raw: |
<img alt="" width="100" height="100" loading="lazy" sizes="100px" src="https://picsum.photos/100/100.webp" srcset="https://picsum.photos/100/100.webp 100w">
<img alt="" width="500" height="500" loading="lazy" class="four-photo-collage__image" sizes="(max-width: 1022px) 600px, 500px" src="https://picsum.photos/500/500.webp" srcset="https://picsum.photos/500/500.webp 500w, https://picsum.photos/600/600.webp 600w">
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% load wagtailcore_tags wagtailimages_tags %}
<div>
<div>
<div class="grid__intro-with-images intro-with-images">
<div class="intro-with-images__collage">
{% for item in value.images %}
{% srcset_image item.image format-webp loading="lazy" fill-{100x100} alt=item.image.alt_text %}
{% srcset_image item.image format-webp loading="lazy" fill-{200x300,400x600,600x900} sizes="(max-width: 598px) 150px, (max-width: 799px) 300px, 700px" class="intro-with-images__image" alt=item.image_alt_text %}
{% endfor %}
</div>
<div>
{{ value.introduction|richtext }}
{% if value.description %}{{ value.description|richtext }}{% endif %}
<div class="intro-with-images__text rich-text">
<div class="intro-with-images__title heading heading--three heading--light">{{ value.introduction|richtext }}</div>
{% if value.description %}<div class="text text--six">{{ value.description|richtext }}</div>{% endif %}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ context:

tags:
srcset_image:
item.image format-webp loading="lazy" fill-{100x100} alt=item.image.alt_text:
raw: |
<img alt="" width="100" height="100" loading="lazy" sizes="100px" src="https://picsum.photos/100/100.webp" srcset="https://picsum.photos/100/100.webp 100w">
'item.image format-webp loading="lazy" fill-{200x300,400x600,600x900} sizes="(max-width: 598px) 150px, (max-width: 799px) 300px, 700px" class="intro-with-images__image" alt=item.image_alt_text':
raw: '<img alt="alt" class="intro-with-images__image" height="225" sizes="(max-width: 598px) 150px, (max-width: 799px) 300px, 700px" src="https://picsum.photos/200/300.webp" srcset="https://picsum.photos/200/300.webp 200w, https://picsum.photos/400/600.webp 400w, https://picsum.photos/600/900.webp 600w" width="200">'
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@

{% block content %}

<p>Title: {{ page.title }}</p>
<div class="grid grid--spacer-large streamfield">
<div class="grid__title">
<h1 class="heading heading--mega">{{ page.title }}</h1>

<p>Label for logo: {{ page.label }}</p>
<p>{{ page.label }}</p>
</div>

{% include_block page.hero %}
<div class="grid__title">{% include_block page.hero %}</div>

{% include_block page.body %}
{% include_block page.body %}
</div>

{% endblock content %}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ <h2 class="underline mt-8 mb-2">Photo collage block</h2>
{% include "patterns/molecules/streamfield/blocks/photo_collage_block.html" %}
</div>

<div>
<h2 class="underline mt-8 mb-2">Four photo collage block</h2>
{% include "patterns/molecules/streamfield/blocks/four_photo_collage_block.html" %}
</div>

<div>
<h2 class="underline mt-8 mb-2">Introduction with images block</h2>
{% include "patterns/molecules/streamfield/blocks/introduction_with_images_block.html" %}
</div>

<div>
<h2 class="underline mt-8 mb-2">Tabbed paragraph block</h2>
{% include "patterns/molecules/streamfield/blocks/tabbed_paragraph_block.html" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ tags:
'item.image format-webp loading="lazy" fill-{288x288,576x576} sizes="(max-width: 598px) 576px, (min-width: 599px) 288px" class="photo-collage__image" alt=item.image_alt_text':
raw: |
<img alt="alt text" class="photo-collage__image" height="288" loading="lazy" sizes="(max-width: 598px) 576px, (min-width: 599px) 288px" src="https://picsum.photos/288/288.webp" srcset="https://picsum.photos/288/288.webp 288w, https://picsum.photos/576/576.webp 576w" width="288">
# four photo collage block
'item.image format-webp loading="lazy" fill-{500x500,600x600} sizes="(max-width: 1022px) 600px, 500px" class="four-photo-collage__image" alt=item.image.alt_text':
raw: |
<img alt="" width="500" height="500" loading="lazy" class="four-photo-collage__image" sizes="(max-width: 1022px) 600px, 500px" src="https://picsum.photos/500/500.webp" srcset="https://picsum.photos/500/500.webp 500w, https://picsum.photos/600/600.webp 600w">
# introduction with images block
'item.image format-webp loading="lazy" fill-{200x300,400x600,600x900} sizes="(max-width: 598px) 150px, (max-width: 799px) 300px, 700px" class="intro-with-images__image" alt=item.image_alt_text':
raw: |
<img alt="alt text" class="intro-with-images__image" height="225" loading="lazy" sizes="(max-width: 598px) 150px, (max-width: 799px) 300px, 700px" src="https://picsum.photos/200/300.webp" srcset="https://picsum.photos/200/300.webp 200w, https://picsum.photos/400/600.webp 400w, https://picsum.photos/600/900.webp 600w" width="200">
# values block
'value_item.image.image format-webp width-{482,964} sizes="(max-width: 598px) 100vw, (min-width: 599px) 30vw" loading="lazy" class="values__image"':
raw: '<img alt="test alt" class="values__image" height="590" loading="lazy" sizes="(max-width: 598px) 100vw, (min-width: 599px) 30vw" src="https://picsum.photos/482/589.webp" srcset="https://picsum.photos/482/589.webp 482w, https://picsum.photos/964/1178.webp 964w" width="482">'
Expand Down
121 changes: 121 additions & 0 deletions tbx/static_src/sass/components/_four-photo-collage.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
@use 'config' as *;

.four-photo-collage {
display: grid;
grid-template-columns: subgrid;

&__scroller {
width: 100%;
overflow-x: scroll;
margin-bottom: $spacer-medium;
grid-column: 1 / span 5;

@include media-query(large) {
overflow-x: visible;
width: auto;
margin-bottom: $spacer-small-plus;
grid-column: 2 / span 11;
}

&:focus {
@include focus-style();
}
}

&__container {
display: flex;
column-gap: 10px;
height: 270px;
// calculated based on the total width of the images rendered at the correct aspect ratio plus the 10px gap
aspect-ratio: 1946 / 403;

@include media-query(small) {
height: 370px;
}

@include media-query(medium) {
height: 403px;
}

@include media-query(large) {
display: grid;
height: auto;
// based on the size we want the images to render
grid-template-columns:
minmax(100px, 200px) minmax(60px, 120px) minmax(210px, 420px)
minmax(320px, 640px);
grid-template-rows: minmax(180px, 360px) minmax(230px, 460px) minmax(
40px,
80px
);
gap: $spacer-mini-plus;
// ensures the individual images remain at the correct aspect ratio
aspect-ratio: 7 / 4;
}
}

// These styles could just be applied direct to the images without a wrapper,
// but we do it on the wrapper to save having to mock loads of images with different
// classes in the pattern library
&__image-wrapper {
@include media-query(large) {
height: auto;
}

// Some browsers seem to need the aspect ratio set explicitly on each image wrapper at mobile
// but this needs unsetting at desktop
&--1 {
aspect-ratio: 4 / 3;

@include media-query(large) {
grid-column: 1 / span 2;
grid-row: 1 / span 1;
aspect-ratio: auto;
}
}

&--2 {
aspect-ratio: 4 / 3;

@include media-query(large) {
grid-column: 3 / span 1;
grid-row: 1 / span 1;
aspect-ratio: auto;
}
}

&--3 {
aspect-ratio: 3 / 4;

@include media-query(large) {
grid-column: 4 / span 1;
grid-row: 1 / span 3;
aspect-ratio: auto;
}
}

&--4 {
aspect-ratio: 7 / 5;

@include media-query(large) {
grid-column: 2 / span 2;
grid-row: 2 / span 1;
aspect-ratio: auto;
}
}
}

&__image {
width: 100%;
height: 100%;
object-fit: cover;
}

&__caption {
grid-column: 1 / span 4;

@include media-query(large) {
grid-column: 1 / span 7;
}
}
}
20 changes: 20 additions & 0 deletions tbx/static_src/sass/components/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
}
}

&__intro-with-images {
grid-column: 1 / span 5;
margin-bottom: $spacer-small-plus;

@include media-query(large) {
margin-bottom: $spacer-large;
grid-column: 2 / span 12;
}
}

&__quote {
margin-bottom: $spacer-medium;
grid-column: 2 / span 4;
Expand Down Expand Up @@ -181,6 +191,16 @@
}
}

&__four-photo-collage {
grid-column: 2 / span 5;
margin-bottom: $spacer-medium;

@include media-query(large) {
grid-column: 2 / span 12;
margin-bottom: $spacer;
}
}

&__promo,
&__event {
grid-column: 2 / span 5;
Expand Down
74 changes: 74 additions & 0 deletions tbx/static_src/sass/components/_intro-with-images.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@use 'config' as *;

.intro-with-images {
display: grid;
gap: $spacer-medium;

@include media-query(large) {
grid-template-columns: 1fr 1fr;
margin-right: -20px; // extend outside the grid
}

@include media-query(x-large) {
gap: $spacer-large;
}

&__collage {
display: grid;
grid-template-columns: 1fr 1fr;
gap: $spacer-mini-plus;

@include media-query(medium) {
max-width: 80vw;
}

@include media-query(large) {
grid-column: 2 / span 1;
}
}

&__image {
width: 100%;

&:first-child {
margin-top: $spacer-small-plus;

@include media-query(large) {
margin-top: $spacer-medium;
}
}

&:last-child {
margin-bottom: $spacer-small-plus;

@include media-query(large) {
margin-bottom: $spacer-medium;
}
}
}

&__text {
margin: 0 $spacer-small;
display: flex;
flex-direction: column;
gap: $spacer-small-plus;

@include media-query(large) {
margin: $spacer-half 0 0;
grid-column: 1 / span 1;
grid-row: 1;
}
}

&__title {
a {
// override rich text link color styles
.rich-text & {
@include link-styles(
var(--color--heading),
var(--color--heading)
);
}
}
}
}
2 changes: 1 addition & 1 deletion tbx/static_src/sass/components/_photo-collage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}

// Some browsers seem to need the aspect ratio set explicitly on each image wrapper at mobile
// but this needs unsetting at desltop
// but this needs unsetting at desktop
&--1 {
aspect-ratio: 1 / 1;

Expand Down
2 changes: 2 additions & 0 deletions tbx/static_src/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
@use 'components/footer';
@use 'components/footer-cta';
@use 'components/form';
@use 'components/four-photo-collage';
@use 'components/grid';
@use 'components/header';
@use 'components/home-page-hero';
@use 'components/home-page-intro';
@use 'components/image';
@use 'components/instagram-gallery';
@use 'components/intro-with-images';
@use 'components/link';
@use 'components/listing';
@use 'components/listing-avatar';
Expand Down

0 comments on commit 252bc62

Please sign in to comment.