Skip to content

Commit a2a2c88

Browse files
committed
fixup! Contextual consent
1 parent 918915e commit a2a2c88

4 files changed

Lines changed: 21 additions & 16 deletions

File tree

site/features/contextual.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
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: '#'
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import {FunctionComponent} from 'preact';
22
import {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

1216
export type ContextualNoticeComponent<
13-
Data extends ContextualNoticeOptions
17+
Data extends ContextualNoticeOptions = ContextualNoticeOptions
1418
> = FunctionComponent<ContextualNoticeProps<Data>>;

src/ui/themes/dsfr/ContextualNotice.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ import type {
55
} from '../../components/types/ContextualNotice';
66
import {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
};

src/ui/themes/standard/ContextualNotice.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ import type {
55
} from '../../components/types/ContextualNotice';
66
import {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
};

0 commit comments

Comments
 (0)