-
Notifications
You must be signed in to change notification settings - Fork 77
/
KcApp.tsx
133 lines (125 loc) 路 5 KB
/
KcApp.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { useEffect, memo } from "react";
import { useSplashScreen } from "onyxia-ui";
import { defaultKcProps } from "keycloakify";
import { makeStyles } from "app/theme";
import onyxiaNeumorphismDarkModeUrl from "app/assets/svg/OnyxiaNeumorphismDarkMode.svg";
import onyxiaNeumorphismLightModeUrl from "app/assets/svg/OnyxiaNeumorphismLightMode.svg";
import { Login } from "./Login";
import { Terms } from "./Terms";
import { Info } from "keycloakify/lib/components/Info";
import { Error } from "keycloakify/lib/components/Error";
import { LoginResetPassword } from "keycloakify/lib/components/LoginResetPassword";
import { LoginVerifyEmail } from "keycloakify/lib/components/LoginVerifyEmail";
import { LoginOtp } from "keycloakify/lib/components/LoginOtp";
import { LoginIdpLinkConfirm } from "keycloakify/lib/components/LoginIdpLinkConfirm";
import { LoginUpdateProfile } from "./LoginUpdateProfile";
import { RegisterUserProfile } from "./RegisterUserProfile";
import { Register } from "keycloakify/lib/components/Register";
import { getBrowser } from "app/tools/getBrowser";
import type { KcContext } from "./kcContext";
export type Props = {
kcContext: KcContext;
};
export const KcApp = memo((props: Props) => {
const { kcContext } = props;
const { hideRootSplashScreen } = useSplashScreen({
"fadeOutDuration": getBrowser() === "firefox" ? 0 : undefined,
});
useEffect(() => {
hideRootSplashScreen();
}, []);
const { classes } = useStyles();
const kcProps = {
...defaultKcProps,
"kcHtmlClass": [...defaultKcProps.kcHtmlClass, classes.kcHtmlClass],
"kcLoginClass": [...defaultKcProps.kcLoginClass, classes.kcLoginClass],
"kcFormCardClass": [...defaultKcProps.kcFormCardClass, classes.kcFormCardClass],
"kcButtonPrimaryClass": [
...defaultKcProps.kcButtonPrimaryClass,
classes.kcButtonPrimaryClass,
],
"kcInputClass": [...defaultKcProps.kcInputClass, classes.kcInputClass],
};
switch (kcContext.pageId) {
case "login.ftl":
return <Login {...{ kcContext, ...kcProps }} />;
case "register.ftl":
return <Register {...{ kcContext, ...kcProps }} />;
case "terms.ftl":
return <Terms {...{ kcContext, ...kcProps }} />;
case "info.ftl":
return <Info {...{ kcContext, ...kcProps }} />;
case "error.ftl":
return <Error {...{ kcContext, ...kcProps }} />;
case "login-reset-password.ftl":
return <LoginResetPassword {...{ kcContext, ...kcProps }} />;
case "login-verify-email.ftl":
return <LoginVerifyEmail {...{ kcContext, ...kcProps }} />;
case "login-otp.ftl":
return <LoginOtp {...{ kcContext, ...kcProps }} />;
case "login-update-profile.ftl":
return <LoginUpdateProfile {...{ kcContext, ...kcProps }} />;
case "login-idp-link-confirm.ftl":
return <LoginIdpLinkConfirm {...{ kcContext, ...kcProps }} />;
case "register-user-profile.ftl":
return <RegisterUserProfile {...{ kcContext, ...kcProps }} />;
}
});
const useStyles = makeStyles({ "name": { KcApp } })(theme => ({
"kcLoginClass": {
"& #kc-locale": {
"zIndex": 5,
},
},
"kcHtmlClass": {
"& body": {
"background": `url(${
theme.isDarkModeEnabled
? onyxiaNeumorphismDarkModeUrl
: onyxiaNeumorphismLightModeUrl
}) no-repeat center center fixed`,
"fontFamily": theme.typography.fontFamily,
},
"background": `${theme.colors.useCases.surfaces.background}`,
"& a": {
"color": `${theme.colors.useCases.typography.textFocus}`,
},
"& #kc-current-locale-link": {
"color": `${theme.colors.palette.light.greyVariant3}`,
},
"& label": {
"fontSize": 14,
"color": theme.colors.palette.light.greyVariant3,
"fontWeight": "normal",
},
"& #kc-page-title": {
...theme.typography.variants["page heading"].style,
"color": theme.colors.palette.dark.main,
},
"& #kc-header-wrapper": {
"visibility": "hidden",
},
},
"kcFormCardClass": {
"borderRadius": 10,
},
"kcButtonPrimaryClass": {
"backgroundColor": "unset",
"backgroundImage": "unset",
"borderColor": `${theme.colors.useCases.typography.textFocus}`,
"borderWidth": "2px",
"borderRadius": `20px`,
"color": `${theme.colors.useCases.typography.textFocus}`,
"textTransform": "uppercase",
},
"kcInputClass": {
"borderRadius": "unset",
"border": "unset",
"boxShadow": "unset",
"borderBottom": `1px solid ${theme.colors.useCases.typography.textTertiary}`,
"&:focus": {
"borderColor": "unset",
"borderBottom": `1px solid ${theme.colors.useCases.typography.textFocus}`,
},
},
}));