Skip to content

Commit 78a6ede

Browse files
Text wrap for product button (#14245)
* set max width and make the product button text wrap
1 parent 0c6260b commit 78a6ede

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

dotcom-rendering/src/components/ProductLinkButton.stories.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { breakpoints } from '@guardian/source/foundations';
12
import type { Meta, StoryObj } from '@storybook/react';
23
import { ProductLinkButton } from './ProductLinkButton';
34

@@ -6,7 +7,15 @@ const meta = {
67
title: 'Components/ProductLinkButton',
78
parameters: {
89
layout: 'padded',
10+
chromatic: {
11+
viewports: [
12+
breakpoints.mobile,
13+
breakpoints.leftCol,
14+
breakpoints.wide,
15+
],
16+
},
917
},
18+
1019
args: {
1120
label: '£6.50 for 350g at Ollie’s Kimchi',
1221
url: 'https://ollieskimchi.co.uk/shop/ols/products/ollies-kimchi',
@@ -18,3 +27,9 @@ export default meta;
1827
type Story = StoryObj<typeof meta>;
1928

2029
export const Default = {} satisfies Story;
30+
31+
export const WithLongLabel = {
32+
args: {
33+
label: '£10.99 for a 5 x 5 x 50cm sheet at Amazon',
34+
},
35+
} satisfies Story;

dotcom-rendering/src/components/ProductLinkButton.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { css } from '@emotion/react';
2+
import { space } from '@guardian/source/foundations';
13
import {
24
LinkButton,
35
SvgArrowRightStraight,
@@ -8,6 +10,15 @@ type ProductLinkButtonProps = {
810
url: string;
911
};
1012

13+
const linkButtonStyles = css`
14+
max-width: 100%;
15+
height: fit-content;
16+
padding-top: ${space[1]}px;
17+
padding-bottom: ${space[1]}px;
18+
white-space: normal;
19+
overflow-wrap: break-word;
20+
`;
21+
1122
export const ProductLinkButton = ({ label, url }: ProductLinkButtonProps) => {
1223
return (
1324
<LinkButton
@@ -20,6 +31,7 @@ export const ProductLinkButton = ({ label, url }: ProductLinkButtonProps) => {
2031
data-ignore="global-link-styling"
2132
data-link-name="in body link"
2233
data-spacefinder-role="inline"
34+
cssOverrides={[linkButtonStyles]}
2335
>
2436
{label}
2537
</LinkButton>

0 commit comments

Comments
 (0)