From c76258e9d18b1e536e7abeff8da7195927eb220c Mon Sep 17 00:00:00 2001 From: Waldemar Reusch Date: Tue, 14 Mar 2023 18:02:42 +0100 Subject: [PATCH] feat(storybook): introduce more pages --- .../pages/LoginPassword.stories.tsx | 16 +++ src/keycloak-theme/pages/LoginPassword.tsx | 86 +++++++++++++ .../pages/LoginResetPassword.stories.tsx | 17 +++ .../pages/LoginResetPassword.tsx | 69 +++++++++++ .../pages/LoginUpdatePassword.stories.tsx | 16 +++ .../pages/LoginUpdatePassword.tsx | 117 ++++++++++++++++++ 6 files changed, 321 insertions(+) create mode 100644 src/keycloak-theme/pages/LoginPassword.stories.tsx create mode 100644 src/keycloak-theme/pages/LoginPassword.tsx create mode 100644 src/keycloak-theme/pages/LoginResetPassword.stories.tsx create mode 100644 src/keycloak-theme/pages/LoginResetPassword.tsx create mode 100644 src/keycloak-theme/pages/LoginUpdatePassword.stories.tsx create mode 100644 src/keycloak-theme/pages/LoginUpdatePassword.tsx 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 ( +