1+ import React from 'react' ;
2+ import { Card , CardBody , CardFooter , CardHeader , Text , TextContent , TextVariants } from '@patternfly/react-core' ;
3+ import { HelperText } from '@patternfly/react-core/dist/dynamic/components/HelperText' ;
4+ import { HelperTextItem } from '@patternfly/react-core/dist/dynamic/components/HelperText' ;
5+ import { createUseStyles } from 'react-jss' ;
6+
7+ export interface ServiceCardProps {
8+ /** Service card title */
9+ title : string ;
10+ /** Service card subtitle */
11+ subtitle : string ;
12+ /** Service card description */
13+ description : string ;
14+ /** Service card icon */
15+ icon : React . ReactNode ;
16+ /** Optional Service card helper text*/
17+ helperText ?: string ;
18+ /** Optional footer */
19+ footer ?: React . ReactElement | null ;
20+ /** Optional custom OUIA ID */
21+ ouiaId ?: string | number ;
22+ }
23+
24+ const useStyles = createUseStyles ( {
25+ card : {
26+ height : 'var(--pf-v5-u-h-100)'
27+ } ,
28+ image : {
29+ marginRight : 'var(--pf-v5-global--spacer--md)' ,
30+ width : 48
31+ }
32+ } ) ;
33+
34+ const ServiceCard : React . FunctionComponent < ServiceCardProps > = ( {
35+ title,
36+ subtitle,
37+ description,
38+ icon,
39+ helperText,
40+ footer = null ,
41+ ouiaId= 'ServiceCard'
42+ } : ServiceCardProps ) => {
43+ const classes = useStyles ( ) ;
44+
45+ return (
46+ < Card className = { classes . card } ouiaId = { `${ ouiaId } -card` } >
47+ < CardHeader >
48+ < div className = { classes . image } >
49+ { icon }
50+ </ div >
51+ < TextContent >
52+ < Text component = { TextVariants . h2 } ouiaId = { `${ ouiaId } -title` } > { title } </ Text >
53+ { subtitle }
54+ </ TextContent >
55+ </ CardHeader >
56+ < CardBody data-ouia-component-id = { `${ ouiaId } -description` } > { description } </ CardBody >
57+ < CardFooter data-ouia-component-id = { `${ ouiaId } -footer` } >
58+ { helperText ?
59+ ( < HelperText data-ouia-component-id = { `${ ouiaId } -helper-text` } >
60+ < HelperTextItem variant = "indeterminate" className = "pf-v5-u-mb-lg" >
61+ { helperText }
62+ </ HelperTextItem >
63+ </ HelperText > ) : null
64+ }
65+ { footer }
66+ </ CardFooter >
67+ </ Card >
68+ )
69+ }
70+
71+ export default ServiceCard ;
0 commit comments