File tree Expand file tree Collapse file tree 6 files changed +122
-0
lines changed Expand file tree Collapse file tree 6 files changed +122
-0
lines changed Original file line number Diff line number Diff line change
1
+ import type { Meta , StoryObj } from '@storybook/react' ;
2
+ import { ProductLinkButton } from './ProductLinkButton' ;
3
+
4
+ const meta = {
5
+ component : ProductLinkButton ,
6
+ title : 'Components/ProductLinkButton' ,
7
+ parameters : {
8
+ layout : 'padded' ,
9
+ } ,
10
+ args : {
11
+ label : '£6.50 for 350g at Ollie’s Kimchi' ,
12
+ url : 'https://ollieskimchi.co.uk/shop/ols/products/ollies-kimchi' ,
13
+ } ,
14
+ } satisfies Meta < typeof ProductLinkButton > ;
15
+
16
+ export default meta ;
17
+
18
+ type Story = StoryObj < typeof meta > ;
19
+
20
+ export const Default = { } satisfies Story ;
Original file line number Diff line number Diff line change
1
+ import {
2
+ LinkButton ,
3
+ SvgArrowRightStraight ,
4
+ } from '@guardian/source/react-components' ;
5
+
6
+ type ProductLinkButtonProps = {
7
+ label : string ;
8
+ url : string ;
9
+ } ;
10
+
11
+ export const ProductLinkButton = ( { label, url } : ProductLinkButtonProps ) => {
12
+ return (
13
+ < LinkButton
14
+ href = { url }
15
+ rel = "sponsored"
16
+ iconSide = "right"
17
+ aria-label = { `Open ${ label } in a new tab` }
18
+ icon = { < SvgArrowRightStraight /> }
19
+ data-ignore = "global-link-styling"
20
+ data-link-name = "in body link"
21
+ data-spacefinder-role = "inline"
22
+ >
23
+ { label }
24
+ </ LinkButton >
25
+ ) ;
26
+ } ;
Original file line number Diff line number Diff line change 673
673
{
674
674
"$ref" : " #/definitions/KeyTakeawaysBlockElement"
675
675
},
676
+ {
677
+ "$ref" : " #/definitions/LinkBlockElement"
678
+ },
676
679
{
677
680
"$ref" : " #/definitions/ListBlockElement"
678
681
},
2497
2500
" title"
2498
2501
]
2499
2502
},
2503
+ "LinkBlockElement" : {
2504
+ "type" : " object" ,
2505
+ "properties" : {
2506
+ "_type" : {
2507
+ "type" : " string" ,
2508
+ "const" : " model.dotcomrendering.pageElements.LinkBlockElement"
2509
+ },
2510
+ "url" : {
2511
+ "type" : " string"
2512
+ },
2513
+ "label" : {
2514
+ "type" : " string"
2515
+ },
2516
+ "linkType" : {
2517
+ "type" : " string" ,
2518
+ "const" : " ProductButton"
2519
+ }
2520
+ },
2521
+ "required" : [
2522
+ " _type" ,
2523
+ " label" ,
2524
+ " linkType" ,
2525
+ " url"
2526
+ ]
2527
+ },
2500
2528
"ListBlockElement" : {
2501
2529
"type" : " object" ,
2502
2530
"properties" : {
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import { MultiBylines } from '../components/MultiBylines';
36
36
import { MultiImageBlockComponent } from '../components/MultiImageBlockComponent' ;
37
37
import { NumberedTitleBlockComponent } from '../components/NumberedTitleBlockComponent' ;
38
38
import { PersonalityQuizAtom } from '../components/PersonalityQuizAtom.importable' ;
39
+ import { ProductLinkButton } from '../components/ProductLinkButton' ;
39
40
import { ProfileAtomWrapper } from '../components/ProfileAtomWrapper.importable' ;
40
41
import { PullQuoteBlockComponent } from '../components/PullQuoteBlockComponent' ;
41
42
import { QandaAtom } from '../components/QandaAtom.importable' ;
@@ -562,6 +563,17 @@ export const renderElement = ({
562
563
/>
563
564
</ Island >
564
565
) ;
566
+ case 'model.dotcomrendering.pageElements.LinkBlockElement' :
567
+ return (
568
+ < >
569
+ { element . linkType === 'ProductButton' && (
570
+ < ProductLinkButton
571
+ label = { element . label }
572
+ url = { element . url }
573
+ />
574
+ ) }
575
+ </ >
576
+ ) ;
565
577
case 'model.dotcomrendering.pageElements.PullquoteBlockElement' :
566
578
return (
567
579
< PullQuoteBlockComponent
Original file line number Diff line number Diff line change 162
162
{
163
163
"$ref" : " #/definitions/KeyTakeawaysBlockElement"
164
164
},
165
+ {
166
+ "$ref" : " #/definitions/LinkBlockElement"
167
+ },
165
168
{
166
169
"$ref" : " #/definitions/ListBlockElement"
167
170
},
1986
1989
" title"
1987
1990
]
1988
1991
},
1992
+ "LinkBlockElement" : {
1993
+ "type" : " object" ,
1994
+ "properties" : {
1995
+ "_type" : {
1996
+ "type" : " string" ,
1997
+ "const" : " model.dotcomrendering.pageElements.LinkBlockElement"
1998
+ },
1999
+ "url" : {
2000
+ "type" : " string"
2001
+ },
2002
+ "label" : {
2003
+ "type" : " string"
2004
+ },
2005
+ "linkType" : {
2006
+ "type" : " string" ,
2007
+ "const" : " ProductButton"
2008
+ }
2009
+ },
2010
+ "required" : [
2011
+ " _type" ,
2012
+ " label" ,
2013
+ " linkType" ,
2014
+ " url"
2015
+ ]
2016
+ },
1989
2017
"ListBlockElement" : {
1990
2018
"type" : " object" ,
1991
2019
"properties" : {
Original file line number Diff line number Diff line change @@ -393,6 +393,13 @@ export interface ListItem {
393
393
bylineHtml ?: string ;
394
394
}
395
395
396
+ export interface LinkBlockElement {
397
+ _type : 'model.dotcomrendering.pageElements.LinkBlockElement' ;
398
+ url : string ;
399
+ label : string ;
400
+ linkType : 'ProductButton' ;
401
+ }
402
+
396
403
export interface ListBlockElement {
397
404
_type : 'model.dotcomrendering.pageElements.ListBlockElement' ;
398
405
listElementType :
@@ -792,6 +799,7 @@ export type FEElement =
792
799
| InteractiveBlockElement
793
800
| ItemLinkBlockElement
794
801
| KeyTakeawaysBlockElement
802
+ | LinkBlockElement
795
803
| ListBlockElement
796
804
| MapBlockElement
797
805
| MediaAtomBlockElement
You can’t perform that action at this time.
0 commit comments