Skip to content

Commit 204644c

Browse files
set max width and make the button text wrap
1 parent 0c6260b commit 204644c

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { css } from '@emotion/react';
12
import {
23
LinkButton,
34
SvgArrowRightStraight,
@@ -8,6 +9,13 @@ type ProductLinkButtonProps = {
89
url: string;
910
};
1011

12+
const linkButtonStyles = css`
13+
max-width: 100%;
14+
height: fit-content;
15+
white-space: normal;
16+
overflow-wrap: break-word;
17+
`;
18+
1119
export const ProductLinkButton = ({ label, url }: ProductLinkButtonProps) => {
1220
return (
1321
<LinkButton
@@ -20,6 +28,7 @@ export const ProductLinkButton = ({ label, url }: ProductLinkButtonProps) => {
2028
data-ignore="global-link-styling"
2129
data-link-name="in body link"
2230
data-spacefinder-role="inline"
31+
cssOverrides={[linkButtonStyles]}
2332
>
2433
{label}
2534
</LinkButton>

0 commit comments

Comments
 (0)