@@ -9,10 +9,12 @@ import type { I18n } from "./i18n";
99import type { KcContext } from "./KcContext" ;
1010import useSetCookieConsent from "./useSetCookieConsent.tsx" ;
1111// import logo from "./assets/logo.svg";
12- import icon from "./assets/favicon.svg" ;
12+ import iconLightTheme from "./assets/favicon-light-theme.svg" ;
13+ import iconDarkTheme from "./assets/favicon-dark-theme.svg" ;
1314
1415import Lottie from "lottie-react" ;
15- import animationData from "./assets/logo.json" ; // path to your Lottie JSON file
16+ import animationDataLightTheme from "./assets/logo-light-theme.json" ; // path to your Lottie JSON file
17+ import animationDataDarkTheme from "./assets/logo-dark-theme.json" ; // path to your Lottie JSON file
1618
1719export default function Template ( props : TemplateProps < KcContext , I18n > ) {
1820 const {
@@ -35,7 +37,16 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
3537
3638 const { msg, msgStr, advancedMsgStr, currentLanguage, enabledLanguages } = i18n ;
3739
38- const { realm, auth, url, message, isAppInitiatedAction } = kcContext ;
40+ let icon = iconDarkTheme ;
41+ let animationData = animationDataDarkTheme ;
42+
43+ const { auth, url, message, isAppInitiatedAction } = kcContext ;
44+
45+ const darkThemeMq = window . matchMedia ( "(prefers-color-scheme: dark)" ) ;
46+ if ( ! darkThemeMq . matches ) {
47+ icon = iconLightTheme ;
48+ animationData = animationDataLightTheme ;
49+ }
3950
4051 useEffect ( ( ) => {
4152 document . title = documentTitle ?? msgStr ( "loginTitle" , kcContext . realm . displayName ) ;
@@ -142,7 +153,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
142153
143154 useSetClassName ( {
144155 qualifiedName : "body" ,
145- className : bodyClassName ?? kcClsx ( "kcBodyClass" )
156+ className : bodyClassName ?? clsx ( kcClsx ( "kcBodyClass" ) , darkThemeMq . matches ? "dark" : "light ")
146157 } ) ;
147158
148159 const footerImprintUrl = advancedMsgStr ( "footerImprintUrl" ) !== "footerImprintUrl" ? advancedMsgStr ( "footerImprintUrl" ) : null ;
@@ -162,7 +173,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
162173 < div
163174 className = { clsx (
164175 kcClsx ( "kcLoginClass" ) ,
165- "bg-background flex flex-col items-center justify-center min-h-screen sm:py-16 overflow-x-hidden"
176+ "bg-background dark:bg-background-dark flex flex-col items-center justify-center min-h-screen sm:py-16 overflow-x-hidden"
166177 ) }
167178 >
168179 < div id = "kc-header" >
@@ -196,8 +207,9 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
196207 ) }
197208 </ div >
198209
199- < div className = { clsx ( kcClsx ( "kcFormCardClass" ) , "relative z-10 max-w-md w-full rounded-lg" ) } >
200- < div className = { "font-bold text-center text-2xl" } > { msg ( "loginTitleHtml" , realm . displayNameHtml ) } </ div >
210+ < div className = { clsx ( kcClsx ( "kcFormCardClass" ) , "bg-white dark:bg-black relative z-10 max-w-md w-full rounded-lg" ) } >
211+ { /* Hide Realm */ }
212+ { /* <div className={"text-primary-800 dark:text-primary-400 font-bold text-center text-2xl"}>{msg("loginTitleHtml", realm.displayNameHtml)}</div> */ }
201213 < header className = { clsx ( kcClsx ( "kcFormHeaderClass" ) ) } >
202214 { ( ( ) => {
203215 const node = ! ( auth !== undefined && auth . showUsername && ! auth . showResetCredentials ) ? (
@@ -270,7 +282,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
270282 document . forms [ "kc-select-try-another-way-form" as never ] . submit ( ) ;
271283 return false ;
272284 } }
273- className = "bg-secondary-100 text-secondary-600 focus:ring-secondary-600 hover:bg-secondary-200 hover:text-secondary-900 px-4 py-2 text-sm flex justify-center relative rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-offset-2"
285+ className = "bg-secondary-100 dark:bg-secondary-800 text-secondary-600 dark:text-secondary-300 focus:ring-secondary-600 dark:focus:ring-secondary-300 hover:bg-secondary-300 dark: hover:bg-secondary-600 hover: text-secondary-900 dark:hover:text-secondary-100 px-4 py-2 text-sm flex justify-center relative rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-offset-2"
274286 >
275287 { msg ( "doTryAnotherWay" ) }
276288 </ button >
@@ -279,7 +291,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
279291 ) }
280292 { socialProvidersNode }
281293 { displayInfo && (
282- < div className = { "space-y-4" } >
294+ < div >
283295 < div id = "kc-info-wrapper" > { infoNode } </ div >
284296 </ div >
285297 ) }
@@ -291,7 +303,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
291303 < section className = { "flex flex-col ml-5" } >
292304 { ( footerImprintUrl || kcContext . properties [ "TAILCLOAKIFY_FOOTER_IMPRINT_URL" ] ) && (
293305 < a
294- className = { "text-secondary-600 hover:text-secondary-900 text-sm inline-flex no-underline hover:no-underline" }
306+ className = { "text-secondary-600 dark:text-secondary-300 hover:text-secondary-900 text-sm inline-flex no-underline hover:no-underline" }
295307 target = { "_blank" }
296308 rel = { "noopener noreferrer" }
297309 href = { footerImprintUrl || kcContext . properties [ "TAILCLOAKIFY_FOOTER_IMPRINT_URL" ] }
@@ -301,7 +313,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
301313 ) }
302314 { ( footerDataprotectionUrl || kcContext . properties [ "TAILCLOAKIFY_FOOTER_DATAPROTECTION_URL" ] ) && (
303315 < a
304- className = { "text-secondary-600 hover:text-secondary-900 text-sm inline-flex no-underline hover:no-underline" }
316+ className = { "text-secondary-600 dark:text-secondary-300 hover:text-secondary-900 text-sm inline-flex no-underline hover:no-underline" }
305317 target = { "_blank" }
306318 rel = { "noopener noreferrer" }
307319 href = { footerDataprotectionUrl || kcContext . properties [ "TAILCLOAKIFY_FOOTER_DATAPROTECTION_URL" ] }
@@ -311,7 +323,7 @@ export default function Template(props: TemplateProps<KcContext, I18n>) {
311323 ) }
312324 { kcContext . properties [ "TAILCLOAKIFY_FOOTER_ORESTBIDACOOKIECONSENT" ] && (
313325 < a
314- className = { "text-secondary-600 hover:text-secondary-900 text-sm inline-flex no-underline hover:no-underline" }
326+ className = { "text-secondary-600 dark:text-secondary-300 hover:text-secondary-900 text-sm inline-flex no-underline hover:no-underline" }
315327 target = { "_blank" }
316328 rel = { "noopener noreferrer" }
317329 type = { "button" }
0 commit comments