diff --git a/src/keycloak-theme/pages/LoginPassword.stories.tsx b/src/keycloak-theme/pages/LoginPassword.stories.tsx new file mode 100644 index 0000000..6a53efa --- /dev/null +++ b/src/keycloak-theme/pages/LoginPassword.stories.tsx @@ -0,0 +1,16 @@ +import {ComponentMeta} from '@storybook/react'; +import KcApp from '../KcApp'; +import {template} from '../../../.storybook/util' + +export default { + kind: 'Page', + title: 'Theme/Pages/Login/Password Only', + component: KcApp, + parameters: { + layout: 'fullscreen', + }, +} as ComponentMeta; + +const bind = template('login-password.ftl'); + +export const Default = bind({}) diff --git a/src/keycloak-theme/pages/LoginPassword.tsx b/src/keycloak-theme/pages/LoginPassword.tsx new file mode 100644 index 0000000..ff3798e --- /dev/null +++ b/src/keycloak-theme/pages/LoginPassword.tsx @@ -0,0 +1,86 @@ +import React, { useState } from "react"; +import { clsx } from "keycloakify/lib/tools/clsx"; +import { useConstCallback } from "keycloakify/lib/tools/useConstCallback"; +import type { FormEventHandler } from "react"; +import type { PageProps } from "keycloakify"; +import type { KcContext } from "../kcContext"; +import type { I18n } from "../i18n"; + +export default function LoginPassword(props: PageProps, I18n>) { + const { kcContext, i18n, doFetchDefaultThemeResources = true, Template, ...kcProps } = props; + + const { realm, url, login } = kcContext; + + const { msg, msgStr } = i18n; + + const [isLoginButtonDisabled, setIsLoginButtonDisabled] = useState(false); + + const onSubmit = useConstCallback>(e => { + e.preventDefault(); + + setIsLoginButtonDisabled(true); + + const formElement = e.target as HTMLFormElement; + + formElement.submit(); + }); + + return ( +