File tree Expand file tree Collapse file tree 4 files changed +122
-2
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 4 files changed +122
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ const meta = {
2020 ] ,
2121 parameters : {
2222 viewport : {
23- defaultViewport : 'mobile ' ,
23+ defaultViewport : 'mobileMedium ' ,
2424 } ,
2525 } ,
2626} satisfies Meta < typeof FootballMatchStat > ;
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ const barCss = css`
5050 bor der- radius: 8px;
5151` ;
5252
53- export type MatchStatistic = {
53+ type MatchStatistic = {
5454 teamName : string ;
5555 teamColour : string ;
5656 value : number ;
Original file line number Diff line number Diff line change 1+ import { css } from '@emotion/react' ;
2+ import { palette , space } from '@guardian/source/foundations' ;
3+ import type { Meta , StoryObj } from '@storybook/react-webpack5' ;
4+ import { FootballMiniMatchStats } from './FootballMiniMatchStats' ;
5+
6+ const meta = {
7+ title : 'Components/Football Mini Match Stats' ,
8+ component : FootballMiniMatchStats ,
9+ decorators : [
10+ ( Story ) => (
11+ < div
12+ css = { css `
13+ padding : ${ space [ 4 ] } px;
14+ background-color : ${ palette . neutral [ 97 ] } ;
15+ ` }
16+ >
17+ < Story />
18+ </ div >
19+ ) ,
20+ ] ,
21+ parameters : {
22+ viewport : {
23+ defaultViewport : 'mobileMedium' ,
24+ } ,
25+ } ,
26+ } satisfies Meta < typeof FootballMiniMatchStats > ;
27+
28+ export default meta ;
29+ type Story = StoryObj < typeof meta > ;
30+
31+ export const FootballMiniMatchStatsMobile = {
32+ args : {
33+ homeTeam : {
34+ name : 'Manchester United' ,
35+ colour : '#da020e' ,
36+ } ,
37+ awayTeam : {
38+ name : 'Arsenal' ,
39+ colour : '#023474' ,
40+ } ,
41+ stats : [
42+ {
43+ label : 'Possession' ,
44+ homeValue : 39 ,
45+ awayValue : 61 ,
46+ showPercentage : true ,
47+ } ,
48+ { label : 'Goal Attempts' , homeValue : 7 , awayValue : 4 } ,
49+ ] ,
50+ } ,
51+ } satisfies Story ;
Original file line number Diff line number Diff line change 1+ import { css } from '@emotion/react' ;
2+ import { palette } from '@guardian/source/foundations' ;
3+ import {
4+ LinkButton ,
5+ SvgArrowRightStraight ,
6+ } from '@guardian/source/react-components' ;
7+ import { FootballMatchStat } from './FootballMatchStat' ;
8+
9+ const containerCss = css `
10+ display : flex;
11+ flex-direction : column;
12+ gap : 10px ;
13+ ` ;
14+
15+ type FootballTeam = {
16+ name : string ;
17+ colour : string ;
18+ } ;
19+
20+ type MatchStatistic = {
21+ label : string ;
22+ homeValue : number ;
23+ awayValue : number ;
24+ showPercentage ?: boolean ;
25+ } ;
26+
27+ type Props = {
28+ homeTeam : FootballTeam ;
29+ awayTeam : FootballTeam ;
30+ stats : MatchStatistic [ ] ;
31+ } ;
32+
33+ export const FootballMiniMatchStats = ( {
34+ homeTeam,
35+ awayTeam,
36+ stats,
37+ } : Props ) => {
38+ console . log ( homeTeam , awayTeam , stats ) ;
39+ return (
40+ < div css = { containerCss } >
41+ { stats . map ( ( stat ) => (
42+ < FootballMatchStat
43+ key = { stat . label }
44+ label = { stat . label }
45+ home = { {
46+ teamName : homeTeam . name ,
47+ teamColour : homeTeam . colour ,
48+ value : stat . homeValue ,
49+ } }
50+ away = { {
51+ teamName : awayTeam . name ,
52+ teamColour : awayTeam . colour ,
53+ value : stat . awayValue ,
54+ } }
55+ showPercentage = { stat . showPercentage }
56+ />
57+ ) ) }
58+ < LinkButton
59+ href = "#"
60+ size = "small"
61+ icon = { < SvgArrowRightStraight /> }
62+ iconSide = "right"
63+ theme = { { backgroundPrimary : palette . sport [ 400 ] } }
64+ >
65+ More stats, line-ups and tables
66+ </ LinkButton >
67+ </ div >
68+ ) ;
69+ } ;
You can’t perform that action at this time.
0 commit comments