-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExitThisPage.tsx
More file actions
45 lines (41 loc) · 1.34 KB
/
ExitThisPage.tsx
File metadata and controls
45 lines (41 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from "react";
import { ExitThisPageProps } from "./ExitThisPage.types";
const ExitThisPage: React.FC<ExitThisPageProps> = ({
children = "Exit this page",
className,
redirectUrl = "https://www.bbc.co.uk/weather",
activatedText,
timedOutText,
pressTwoMoreTimesText,
pressOneMoreTimeText,
...attributes
}) => {
const i18nProps: Record<string, string> = {};
if (activatedText) i18nProps["data-i18n.activated"] = activatedText;
if (timedOutText) i18nProps["data-i18n.timed-out"] = timedOutText;
if (pressTwoMoreTimesText)
i18nProps["data-i18n.press-two-more-times"] = pressTwoMoreTimesText;
if (pressOneMoreTimeText)
i18nProps["data-i18n.press-one-more-time"] = pressOneMoreTimeText;
return (
<div
{...attributes}
{...i18nProps}
className={`govuk-exit-this-page${className ? ` ${className}` : ""}`}
data-module="govuk-exit-this-page"
>
<a
href={redirectUrl}
role="button"
draggable={false}
className="govuk-button govuk-button--warning govuk-exit-this-page__button govuk-js-exit-this-page-button"
data-module="govuk-button"
rel="nofollow noreferrer"
>
<span className="govuk-visually-hidden">Emergency</span> {children}
</a>
</div>
);
};
ExitThisPage.displayName = "ExitThisPage";
export default ExitThisPage;