File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed
Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import Hint , { HintProps } from '../components/hint/Hint' ;
3+ import Label , { LabelProps } from '../components/label/Label' ;
4+ import ErrorMessage , { ErrorMessageProps } from '../components/error-message/ErrorMessage' ;
5+
6+ interface LabelBlockProps {
7+ elementId ?: string ;
8+ label ?: string ;
9+ labelProps ?: LabelProps ;
10+ hint ?: string ;
11+ hintProps ?: HintProps ;
12+ error ?: string | boolean ;
13+ errorProps ?: ErrorMessageProps ;
14+ }
15+
16+ const LabelBlock : React . FC < LabelBlockProps > = ( {
17+ elementId,
18+ label,
19+ labelProps,
20+ hint,
21+ hintProps,
22+ error,
23+ errorProps,
24+ } ) => (
25+ < >
26+ { label ? (
27+ < Label id = { elementId ? `${ elementId } --label` : undefined } htmlFor = { elementId } { ...labelProps } >
28+ { label }
29+ </ Label >
30+ ) : null }
31+ { hint ? (
32+ < Hint id = { elementId ? `${ elementId } --hint` : undefined } { ...hintProps } >
33+ { hint }
34+ </ Hint >
35+ ) : null }
36+ { error && typeof error === 'string' ? (
37+ < ErrorMessage id = { elementId ? `${ elementId } --error-message` : undefined } { ...errorProps } >
38+ { error }
39+ </ ErrorMessage >
40+ ) : null }
41+ </ >
42+ ) ;
43+
44+ export default LabelBlock ;
Original file line number Diff line number Diff line change 1+ import { ErrorMessageProps } from '../../components/error-message/ErrorMessage' ;
2+ import { HintProps } from '../../components/hint/Hint' ;
3+ import { LabelProps } from '../../components/label/Label' ;
4+
5+ export interface FormElementProps {
6+ label ?: string ;
7+ labelProps ?: LabelProps ;
8+ error ?: string ;
9+ errorProps ?: ErrorMessageProps ;
10+ hint ?: string ;
11+ hintProps ?: HintProps
12+ }
Original file line number Diff line number Diff line change 1+ export type NHSUKSize = 's' | 'm' | 'l' | 'xl' ;
2+
3+ export type InputWidth = '2' | '3' | '4' | '5' | '10' ;
4+
5+ export type CareCardType = 'non-urgent' | 'urgent' | 'immediate' ;
6+
7+ export type ColWidth = 'full' | 'three-quarters' | 'one-half' | 'two-thirds' | 'one-third' | 'one-quarter' ;
You can’t perform that action at this time.
0 commit comments