Skip to content

Commit a3dc358

Browse files
authored
feat: redesign display block (#3284)
add rgbToOklch script pin cypress/code-coverage pkg version add display responsive examples add DisplayWithImageOverlay upgrade tailwindcss to 3.4.17 add padding for smallest screens
1 parent c850705 commit a3dc358

20 files changed

+500
-157
lines changed

apps/docs/components/content/_blocks/Banners.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@
22

33
Banners are components that deliver main image and content in various configurations.
44

5+
## Responsive Display
6+
7+
Display blocks that switch between horizontal/vertical arrangement based on [parent container's size](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries).
8+
9+
<Showcase showcase-name="Banners/DisplayResponsive" style="min-height:800px">
10+
11+
::vue-only
12+
<<<../../../../preview/nuxt/pages/showcases/Banners/DisplayResponsive.vue
13+
::
14+
::react-only
15+
<<<../../../../preview/next/pages/showcases/Banners/DisplayResponsive.tsx
16+
::
17+
18+
</Showcase>
19+
520
## Horizontal Display
621

22+
Horizontal display block with image and content to the side.
23+
724
<Showcase showcase-name="Banners/DisplayHorizontal" style="min-height:800px">
825

926
::vue-only
@@ -45,6 +62,21 @@ Four vertical displays in row on desktop.
4562

4663
</Showcase>
4764

65+
## Display With Image Overlay
66+
67+
Display block with image filling all of its background area.
68+
69+
<Showcase showcase-name="Banners/DisplayWithImageOverlay" style="min-height:800px">
70+
71+
::vue-only
72+
<<<../../../../preview/nuxt/pages/showcases/Banners/DisplayWithImageOverlay.vue
73+
::
74+
::react-only
75+
<<<../../../../preview/next/pages/showcases/Banners/DisplayWithImageOverlay.tsx
76+
::
77+
78+
</Showcase>
79+
4880
## Hero
4981

5082
The Hero component simplifies the process of creating stunning hero sections for your website. With Hero, you have the flexibility to seamlessly integrate a main image and customize your content to suit your needs. Additionally, Hero allows adding background images tailored for both mobile and desktop devices. To ensure an optimal blend of performance and visual appeal, we recommend adhering to the following image guidelines:

apps/preview/next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"prettier": "^3.0.0",
4343
"rimraf": "^6.0.1",
4444
"string-replace-loader": "^3.1.0",
45-
"tailwindcss": "^3.4.7",
45+
"tailwindcss": "3.4.17",
4646
"ts-loader": "^9.4.2"
4747
}
4848
}

apps/preview/next/pages/showcases/Banners/DisplayHorizontal.tsx

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ const displayDetails = [
1414
buttonText: 'Discover now',
1515
reverse: false,
1616
backgroundColor: 'bg-negative-200',
17-
titleClass: 'md:typography-display-2',
18-
subtitleClass: 'md:typography-headline-6',
19-
descriptionClass: 'md:typography-text-lg',
2017
},
2118
{
2219
image: 'http://localhost:3100/@assets/display-2.png',
@@ -40,41 +37,47 @@ const displayDetails = [
4037

4138
export default function DisplayHorizontalBlock() {
4239
return (
43-
<div className="flex flex-col md:flex-row flex-wrap gap-6 max-w-[1540px]">
44-
{displayDetails.map(
45-
({ image, title, subtitle, description, buttonText, backgroundColor, reverse, titleClass, subtitleClass }) => (
40+
<div className="grid md:flex md:flex-row flex-wrap gap-6 max-w-[1540px]">
41+
{displayDetails.map(({ image, title, subtitle, description, buttonText, backgroundColor, reverse }) => (
42+
<div
43+
key={title}
44+
className={classNames(
45+
'relative flex md:max-w-[1536px] md:[&:not(:first-of-type)]:flex-1 md:first-of-type:w-full @container group',
46+
backgroundColor,
47+
)}
48+
>
49+
<a
50+
className="absolute w-full h-full z-1 focus-visible:outline focus-visible:rounded-lg"
51+
aria-label={title}
52+
href="#"
53+
/>
4654
<div
47-
key={title}
48-
className={classNames(
49-
'relative flex md:max-w-[1536px] md:[&:not(:first-of-type)]:flex-1 md:first-of-type:w-full',
50-
backgroundColor,
51-
)}
55+
className={classNames('flex justify-between overflow-hidden grow', {
56+
'flex-row-reverse': reverse,
57+
})}
5258
>
53-
<a
54-
className="absolute w-full h-full z-1 focus-visible:outline focus-visible:rounded-lg"
55-
aria-label={title}
56-
href="#"
57-
/>
58-
<div
59-
className={classNames('flex justify-between overflow-hidden grow', {
60-
'flex-row-reverse': reverse,
61-
})}
62-
>
63-
<div className="flex flex-col justify-center items-start p-6 lg:p-10 max-w-1/2">
64-
<p
65-
className={classNames('uppercase typography-text-xs block font-bold tracking-widest', subtitleClass)}
66-
>
67-
{subtitle}
68-
</p>
69-
<h2 className={classNames('mb-4 mt-2 font-bold typography-display-3', titleClass)}>{title}</h2>
70-
<p className="typography-text-base block mb-4">{description}</p>
71-
<SfButton className="!bg-black">{buttonText}</SfButton>
72-
</div>
73-
<img src={image} alt={title} className="w-1/2 self-end object-contain" />
59+
<div className="grow flex flex-col justify-center items-start p-4 @sm:p-6 @3xl:p-10 max-w-1/2">
60+
<p className="uppercase typography-text-xs block font-medium tracking-widest @3xl:typography-headline-6">
61+
{subtitle}
62+
</p>
63+
<h2 className="mb-4 mt-2 font-semibold typography-display-3 -tracking-wide @3xl:typography-display-1">
64+
{title}
65+
</h2>
66+
<p className="typography-text-base block mb-4 @3xl:typography-text-lg">{description}</p>
67+
<SfButton
68+
blank
69+
className="text-white bg-neutral-700 hover:bg-neutral-800 active:bg-neutral-900 group-hover:bg-neutral-800 group-active:bg-neutral-900 group-has-[:focus-visible]:outline group-has-[:focus-visible]:outline-offset pointer-events-none"
70+
tabIndex={-1}
71+
>
72+
{buttonText}
73+
</SfButton>
74+
</div>
75+
<div className="flex-shrink-0 w-1/2 self-start object-contain">
76+
<img src={image} alt={title} className="w-full" />
7477
</div>
7578
</div>
76-
),
77-
)}
79+
</div>
80+
))}
7881
</div>
7982
);
8083
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* eslint-disable jsx-a11y/anchor-is-valid */
2+
/* eslint-disable jsx-a11y/anchor-has-content */
3+
import { ShowcasePageLayout } from '../../showcases';
4+
// #region source
5+
import { SfButton } from '@storefront-ui/react';
6+
import classNames from 'classnames';
7+
8+
const displayDetails = [
9+
{
10+
image: 'http://localhost:3100/@assets/display-2.png',
11+
title: 'Pack it Up',
12+
subtitle: 'Be active',
13+
description: 'Explore the great outdoors with our backpacks',
14+
buttonText: 'Discover now',
15+
reverse: true,
16+
backgroundColor: 'bg-warning-200',
17+
},
18+
{
19+
image: 'http://localhost:3100/@assets/display.png',
20+
title: 'Sunny Days Ahead',
21+
subtitle: 'Be inspired',
22+
description: 'Step out in style with our sunglasses collection',
23+
buttonText: 'Discover now',
24+
reverse: true,
25+
backgroundColor: 'bg-negative-200',
26+
},
27+
];
28+
29+
export default function DisplayHorizontalBlock() {
30+
return (
31+
<div className="grid md:flex md:flex-row flex-wrap gap-6 max-w-[1540px]">
32+
{displayDetails.map(({ image, title, subtitle, description, buttonText, backgroundColor, reverse }) => (
33+
<div
34+
key={title}
35+
className={classNames(
36+
'relative flex md:max-w-[1536px] md:[&:not(:first-of-type)]:flex-1 md:first-of-type:w-full @container group',
37+
backgroundColor,
38+
)}
39+
>
40+
<a
41+
className="absolute w-full h-full z-1 focus-visible:outline focus-visible:rounded-lg"
42+
aria-label={title}
43+
href="#"
44+
/>
45+
<div
46+
className={classNames('flex justify-between overflow-hidden grow flex-col @md:flex-row', {
47+
'@md:flex-row-reverse flex-col-reverse': reverse,
48+
})}
49+
>
50+
<div className="grow flex flex-col justify-center items-start p-4 @sm:p-6 @3xl:p-10 max-w-1/2 items-center text-center @md:items-start @md:text-start">
51+
<p className="uppercase typography-text-xs block font-medium tracking-widest @3xl:typography-headline-6">
52+
{subtitle}
53+
</p>
54+
<h2 className="mb-4 mt-2 font-semibold typography-display-3 -tracking-wide @3xl:typography-display-1">
55+
{title}
56+
</h2>
57+
<p className="typography-text-base block mb-4 @3xl:typography-text-lg">{description}</p>
58+
<SfButton
59+
blank
60+
className="text-white bg-neutral-700 hover:bg-neutral-800 active:bg-neutral-900 group-hover:bg-neutral-800 group-active:bg-neutral-900 group-has-[:focus-visible]:outline group-has-[:focus-visible]:outline-offset pointer-events-none"
61+
tabIndex={-1}
62+
>
63+
{buttonText}
64+
</SfButton>
65+
</div>
66+
<div className="flex flex-shrink-0 items-center w-full @md:w-1/2 @md:self-start @md:object-contain">
67+
<img src={image} alt={title} className="w-full" />
68+
</div>
69+
</div>
70+
</div>
71+
))}
72+
</div>
73+
);
74+
}
75+
// #endregion source
76+
DisplayHorizontalBlock.getLayout = ShowcasePageLayout;

apps/preview/next/pages/showcases/Banners/DisplayVertical.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function DisplayVertical() {
3333
<div
3434
key={title}
3535
className={classNames(
36-
`relative flex flex-col justify-between rounded-md md:items-center md:basis-1/2 ${backgroundColor}`,
36+
`relative flex flex-col justify-between rounded-md md:items-center md:basis-1/2 ${backgroundColor} @container group`,
3737
{ 'flex-col-reverse': reverse },
3838
)}
3939
>
@@ -42,11 +42,21 @@ export default function DisplayVertical() {
4242
aria-label={title}
4343
href="#"
4444
/>
45-
<div className="flex flex-col items-center p-4 text-center md:p-10">
46-
<p className="mb-2 font-bold tracking-widest uppercase typography-headline-6">{subtitle}</p>
47-
<p className="mb-4 font-bold typography-display-2">{title}</p>
48-
<p className="mb-4 typography-text-lg">{description}</p>
49-
<SfButton className="font-semibold !bg-neutral-900">{callToAction}</SfButton>
45+
<div className="flex flex-col items-center p-4 @sm:p-6 text-center @3xl:p-10">
46+
<p className="uppercase typography-text-xs block font-medium tracking-widest @3xl:typography-headline-6">
47+
{subtitle}
48+
</p>
49+
<h2 className="mb-4 mt-2 font-semibold typography-display-3 -tracking-wide @3xl:typography-display-1">
50+
{title}
51+
</h2>
52+
<p className="typography-text-base block mb-4 @3xl:typography-text-lg">{description}</p>
53+
<SfButton
54+
blank
55+
className="text-white bg-neutral-700 hover:bg-neutral-800 active:bg-neutral-900 group-hover:bg-neutral-800 group-active:bg-neutral-900 group-has-[:focus-visible]:outline group-has-[:focus-visible]:outline-offset pointer-events-none"
56+
tabIndex={-1}
57+
>
58+
{callToAction}
59+
</SfButton>
5060
</div>
5161
<div className="flex items-center w-full">
5262
<img src={image} alt={title} className="w-full" />

apps/preview/next/pages/showcases/Banners/DisplayVerticalMultiple.tsx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,25 @@ const displayDetails = [
2828
},
2929

3030
{
31-
title: 'Pack it Up',
32-
subtitle: 'Be active',
33-
description: 'Explore the great outdoors with our backpacks',
34-
callToAction: 'Discover now',
35-
image: 'http://localhost:3100/@assets/display-2.png',
36-
backgroundColor: 'bg-warning-200',
37-
reverse: true,
38-
},
39-
{
40-
title: 'Sunny Days Ahead',
41-
subtitle: 'Be inspired',
42-
description: 'Step out in style with our sunglasses collection',
31+
title: 'Fresh and Bold',
32+
subtitle: 'New collection',
33+
description: 'Add a pop up color to your outfit',
4334
callToAction: 'Discover now',
44-
image: 'http://localhost:3100/@assets/display.png',
45-
backgroundColor: 'bg-negative-200',
35+
image: 'http://localhost:3100/@assets/display-3.png',
36+
backgroundColor: 'bg-secondary-200',
4637
reverse: false,
4738
},
4839
];
4940
export default function DisplayVerticalMultiple() {
5041
return (
5142
<div className="flex flex-col gap-6 md:flex-row">
52-
<div className="flex flex-col gap-6 md:flex-row">
43+
<div className="flex flex-col flex-grow gap-6 md:flex-row">
5344
{displayDetails.map(
5445
({ title, subtitle, description, callToAction, image, backgroundColor, reverse }, index) => (
5546
<div
5647
key={`${title}-${index}`}
5748
className={classNames(
58-
`relative flex flex-col justify-between rounded-md md:items-center md:basis-1/2 ${backgroundColor}`,
49+
`relative flex flex-col justify-between rounded-md md:items-center md:basis-1/2 ${backgroundColor} @container group`,
5950
{ 'flex-col-reverse': reverse },
6051
)}
6152
>
@@ -64,11 +55,21 @@ export default function DisplayVerticalMultiple() {
6455
aria-label={title}
6556
href="#"
6657
/>
67-
<div className="flex flex-col items-center p-4 text-center md:p-10">
68-
<p className="mb-2 font-bold tracking-widest uppercase typography-headline-6">{subtitle}</p>
69-
<p className="mb-4 font-bold typography-display-2">{title}</p>
70-
<p className="mb-4 typography-text-lg">{description}</p>
71-
<SfButton className="font-semibold !bg-neutral-900">{callToAction}</SfButton>
58+
<div className="flex flex-col p-4 @sm:p-6 text-center items-center @3xl:p-10">
59+
<p className="uppercase typography-text-xs block font-medium tracking-widest @3xl:typography-headline-6">
60+
{subtitle}
61+
</p>
62+
<h2 className="mb-4 mt-2 font-semibold typography-display-3 -tracking-wide @3xl:typography-display-1">
63+
{title}
64+
</h2>
65+
<p className="typography-text-base block mb-4 @3xl:typography-text-lg">{description}</p>
66+
<SfButton
67+
blank
68+
className="text-white bg-neutral-700 hover:bg-neutral-800 active:bg-neutral-900 group-hover:bg-neutral-800 group-active:bg-neutral-900 group-has-[:focus-visible]:outline group-has-[:focus-visible]:outline-offset pointer-events-none"
69+
tabIndex={-1}
70+
>
71+
{callToAction}
72+
</SfButton>
7273
</div>
7374
<div className="flex items-center w-full">
7475
<img src={image} alt={title} className="w-full" />
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* eslint-disable jsx-a11y/anchor-is-valid */
2+
/* eslint-disable jsx-a11y/anchor-has-content */
3+
import { ShowcasePageLayout } from '../../showcases';
4+
// #region source
5+
import { SfButton } from '@storefront-ui/react';
6+
7+
const displayDetails = [
8+
{
9+
title: 'Cap Game Strong',
10+
subtitle: 'Special Offer',
11+
description: 'Score serious style points with our Open Capsule collection',
12+
buttonText: 'Browse offers',
13+
backgroundImage: 'http://localhost:3100/@assets/display-overlay.png',
14+
},
15+
];
16+
17+
export default function DisplayWithImageOverlay() {
18+
return (
19+
<div className="max-w-[1540px]">
20+
{displayDetails.map(({ title, subtitle, description, buttonText, backgroundImage }) => (
21+
<div key={title} className="relative flex text-white max-w-[1536px] @container group">
22+
<a
23+
className="absolute w-full h-full z-1 focus-visible:outline focus-visible:rounded-lg"
24+
aria-label={title}
25+
href="#"
26+
/>
27+
<div className="h-[680px] @3xl:h-auto @3xl:aspect-[2] flex justify-between overflow-hidden grow">
28+
<div className="grow flex flex-col justify-center items-center text-center p-4 @sm:p-6 @3xl:p-10 max-w-1/2">
29+
<p className="uppercase typography-text-xs block font-medium tracking-widest @3xl:typography-headline-6">
30+
{subtitle}
31+
</p>
32+
<h2 className="mb-4 mt-2 font-semibold typography-display-3 -tracking-wide @3xl:typography-display-1">
33+
{title}
34+
</h2>
35+
<p className="typography-text-base block mb-4 @3xl:typography-text-lg">{description}</p>
36+
<SfButton
37+
blank
38+
className="w-[200px] bg-white text-primary-700 ring-secondary-400 group-hover:bg-primary-100 group-hover:hover:text-primary-800 group-hover:ring-secondary-500 group-active:bg-primary-200 group-active:text-primary-900 group-active:ring-secondary-600 group-has-[:focus-visible]:outline group-has-[:focus-visible]:outline-offset pointer-events-none"
39+
tabIndex={-1}
40+
variant="secondary"
41+
>
42+
{buttonText}
43+
</SfButton>
44+
</div>
45+
<div className="absolute inset-0 z-[-1] overflow-hidden bg-primary-900">
46+
<img src={backgroundImage} alt={title} className="w-full h-full object-cover opacity-75" />
47+
</div>
48+
</div>
49+
</div>
50+
))}
51+
</div>
52+
);
53+
}
54+
// #endregion source
55+
56+
DisplayWithImageOverlay.getLayout = ShowcasePageLayout;

0 commit comments

Comments
 (0)