File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939 purposes : [
4040 {
4141 id : 'youtube' ,
42- title : 'YouTube'
42+ title : 'YouTube videos'
43+ } ,
44+ {
45+ id : 'other' ,
46+ title : 'Another purpose'
4347 }
4448 ] ,
4549 privacyPolicyUrl : '#'
Original file line number Diff line number Diff line change 11import { FunctionComponent } from 'preact' ;
22import { Purpose } from '../../types' ;
33
4- export type ContextualNoticeOptions = Record < string , string > ;
4+ export interface ContextualNoticeOptions extends Record < string , string > {
5+ titleLevel ?: '1' | '2' | '3' | '4' | '5' | '6' ;
6+ }
57
6- export interface ContextualNoticeProps < Data extends ContextualNoticeOptions > {
8+ export interface ContextualNoticeProps <
9+ Data extends ContextualNoticeOptions
10+ > {
711 purpose : Purpose ;
812 data : Data ;
913 onAccept : ( ) => void ;
1014}
1115
1216export type ContextualNoticeComponent <
13- Data extends ContextualNoticeOptions
17+ Data extends ContextualNoticeOptions = ContextualNoticeOptions
1418> = FunctionComponent < ContextualNoticeProps < Data > > ;
Original file line number Diff line number Diff line change @@ -5,18 +5,17 @@ import type {
55} from '../../components/types/ContextualNotice' ;
66import { template } from '../../utils/template' ;
77
8- interface DsfrContextualNoticeData extends ContextualNoticeOptions {
9- titleLevel ?: string ;
10- }
11-
12- const ContextualNotice : ContextualNoticeComponent < DsfrContextualNoticeData > = ( {
8+ const ContextualNotice : ContextualNoticeComponent = ( {
139 purpose,
1410 data,
1511 onAccept
1612} ) => {
1713 const t = useTranslations ( ) ;
1814 const { titleLevel} = data ;
19- const TitleTag = titleLevel ? `h${ titleLevel } ` : 'h4' ;
15+ const TitleTag : `h${ContextualNoticeOptions [ 'titleLevel' ] } ` = titleLevel
16+ ? `h${ titleLevel } `
17+ : 'h4' ;
18+
2019 const templateProps = {
2120 purpose : purpose . title
2221 } ;
Original file line number Diff line number Diff line change @@ -5,18 +5,16 @@ import type {
55} from '../../components/types/ContextualNotice' ;
66import { template } from '../../utils/template' ;
77
8- interface StandardContextualNoticeOptions extends ContextualNoticeOptions {
9- titleLevel ?: string ;
10- }
11-
12- const ContextualNotice : ContextualNoticeComponent < StandardContextualNoticeOptions > = ( {
8+ const ContextualNotice : ContextualNoticeComponent = ( {
139 purpose,
1410 data,
1511 onAccept
1612} ) => {
1713 const t = useTranslations ( ) ;
1814 const { titleLevel} = data ;
19- const TitleTag = titleLevel ? `h${ data . titleLevel } ` : 'h2' ;
15+ const TitleTag :
16+ | `h${ContextualNoticeOptions [ 'titleLevel' ] } `
17+ | 'strong' = titleLevel ? `h${ titleLevel } ` : 'strong' ;
2018 const templateProps = {
2119 purpose : purpose . title
2220 } ;
You can’t perform that action at this time.
0 commit comments