1- import type { FC } from 'react' ;
1+ import type { ComponentProps , FC } from 'react' ;
22import React from 'react' ;
33
4- import { EmptyTabContent , IconButton } from 'storybook/internal/components' ;
4+ import { Badge , EmptyTabContent , IconButton } from 'storybook/internal/components' ;
55
66import { ChevronSmallDownIcon } from '@storybook/icons' ;
77
8+ import type { ImpactValue } from 'axe-core' ;
89import { styled } from 'storybook/theming' ;
910
1011import { getTitleForAxeResult } from '../../axeRuleMappingHelper' ;
11- import type { EnhancedResult , RuleType } from '../../types' ;
12+ import { type EnhancedResult , RuleType } from '../../types' ;
1213import { Details } from './Details' ;
1314
15+ const impactStatus : Record < NonNullable < ImpactValue > , ComponentProps < typeof Badge > [ 'status' ] > = {
16+ minor : 'neutral' ,
17+ moderate : 'warning' ,
18+ serious : 'negative' ,
19+ critical : 'critical' ,
20+ } ;
21+
22+ const impactLabels : Record < NonNullable < ImpactValue > , string > = {
23+ minor : 'Minor' ,
24+ moderate : 'Moderate' ,
25+ serious : 'Serious' ,
26+ critical : 'Critical' ,
27+ } ;
28+
1429const Wrapper = styled . div ( ( { theme } ) => ( {
1530 display : 'flex' ,
1631 flexDirection : 'column' ,
1732 width : '100%' ,
1833 borderBottom : `1px solid ${ theme . appBorderColor } ` ,
1934 containerType : 'inline-size' ,
35+ fontSize : theme . typography . size . s2 ,
2036} ) ) ;
2137
2238const Icon = styled ( ChevronSmallDownIcon ) ( {
@@ -40,11 +56,24 @@ const HeaderBar = styled.div(({ theme }) => ({
4056 } ,
4157} ) ) ;
4258
43- const Title = styled . div ( {
59+ const Title = styled . div ( ( { theme } ) => ( {
4460 display : 'flex' ,
61+ alignItems : 'baseline' ,
4562 flexGrow : 1 ,
46- gap : 6 ,
47- } ) ;
63+ fontSize : theme . typography . size . s2 ,
64+ gap : 8 ,
65+ } ) ) ;
66+
67+ const RuleId = styled . div ( ( { theme } ) => ( {
68+ display : 'none' ,
69+ color : theme . textMutedColor ,
70+ fontFamily : theme . typography . fonts . mono ,
71+ fontSize : theme . typography . size . s1 ,
72+
73+ '@container (min-width: 800px)' : {
74+ display : 'block' ,
75+ } ,
76+ } ) ) ;
4877
4978const Count = styled . div ( ( { theme } ) => ( {
5079 display : 'flex' ,
@@ -84,7 +113,13 @@ export const Report: FC<ReportProps> = ({
84113 < HeaderBar onClick = { ( event ) => toggleOpen ( event , type , item ) } data-active = { ! ! selection } >
85114 < Title >
86115 < strong > { title } </ strong >
116+ < RuleId > { item . id } </ RuleId >
87117 </ Title >
118+ { item . impact && (
119+ < Badge status = { type === RuleType . PASS ? 'neutral' : impactStatus [ item . impact ] } >
120+ { impactLabels [ item . impact ] }
121+ </ Badge >
122+ ) }
88123 < Count > { item . nodes . length } </ Count >
89124 < IconButton
90125 onClick = { ( event ) => toggleOpen ( event , type , item ) }
0 commit comments