This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.tsx
87 lines (73 loc) · 2.07 KB
/
index.tsx
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { useEffect } from "react";
import ReactDOM from 'react-dom';
import './index.scss';
import App from './App';
import reportWebVitals from './reportWebVitals';
import {
KcApp,
defaultKcProps,
kcContext as realKcContext,
kcContextMocks,
kcMessages,
useKcLanguageTag
} from "keycloakify";
import { css } from "tss-react";
import tos_en_url from "./tos_en.md";
import tos_fr_url from "./tos_fr.md";
const kcContext = realKcContext ?? (
false /* Set to true to test the login pages outside of Keycloak */
? kcContextMocks.kcLoginContext /* Change to .kcRegisterContext for example */
:
undefined
);
if (kcContext !== undefined) {
console.log(kcContext);
}
ReactDOM.render(
kcContext === undefined ?
<App /> :
<Login />,
document.getElementById("root")
);
function Login() {
if (kcContext === undefined) {
throw new Error();
}
const { kcLanguageTag } = useKcLanguageTag();
//Lazily download the therms and conditions in the appropriate language
//if we are on the terms.ftl page.
useEffect(
() => {
if (kcContext!.pageId !== "terms.ftl") {
return;
}
kcMessages[kcLanguageTag].termsTitle = "";
fetch((() => {
switch (kcLanguageTag) {
case "fr": return tos_fr_url;
default: return tos_en_url;
}
})())
.then(response => response.text())
.then(rawMarkdown => kcMessages[kcLanguageTag].termsText = rawMarkdown);
},
[kcLanguageTag]
);
return (
<>
<div id="foobar" style={{ "width": "200px", "height": "200px" }}></div>
<h1 style={{ "fontFamily": '"Work Sans"' }}>Test that the font apply</h1>
<KcApp
kcContext={kcContext}
{...{
...defaultKcProps,
"kcHeaderWrapperClass": css({ "color": "red", "fontFamily": '"Work Sans"' })
}}
/>
</>
);
}
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();