fix(client): clarify login form styling
- Add spacing for the session-expired notice and distinguish login inputs. - Assert those surfaces in expired-session light and dark stories.
This commit is contained in:
1 parent
8676d6281c
commit
f2bcbe07b6
3 files changed
+29
-1
No files matched your search
@@ -21,13 +21,30 @@ const meta: Meta<typeof LoginForm> = {
|
|||||||
export default meta;
|
export default meta;
|
||||||
type Story = StoryObj<typeof LoginForm>;
|
type Story = StoryObj<typeof LoginForm>;
|
||||||
|
|
||||||
|
async function expectLoginSurfaces(canvasElement: HTMLElement) {
|
||||||
|
const canvas = within(canvasElement);
|
||||||
|
const card = canvasElement.querySelector('section');
|
||||||
|
const notice = canvas.getByText('Your session has expired. Sign in again to continue.');
|
||||||
|
const username = canvas.getByRole('textbox', { name: 'Username' });
|
||||||
|
if (!card) throw new Error('Login card was not rendered.');
|
||||||
|
|
||||||
|
await expect(window.getComputedStyle(notice).marginBottom).not.toBe('0px');
|
||||||
|
await expect(window.getComputedStyle(username).backgroundColor).not.toBe(
|
||||||
|
window.getComputedStyle(card).backgroundColor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export const Initial: Story = {};
|
export const Initial: Story = {};
|
||||||
|
|
||||||
export const ExpiredSession: Story = { args: { expired: true } };
|
export const ExpiredSession: Story = {
|
||||||
|
args: { expired: true },
|
||||||
|
play: async ({ canvasElement }) => expectLoginSurfaces(canvasElement),
|
||||||
|
};
|
||||||
|
|
||||||
export const SignedOut: Story = { args: { signedOut: true } };
|
export const SignedOut: Story = { args: { signedOut: true } };
|
||||||
|
|
||||||
export const DarkTheme: Story = {
|
export const DarkTheme: Story = {
|
||||||
|
args: { expired: true },
|
||||||
decorators: [
|
decorators: [
|
||||||
(Story) => (
|
(Story) => (
|
||||||
<div data-theme="dark" style={{ width: 440, padding: 24, background: 'var(--color-bg)' }}>
|
<div data-theme="dark" style={{ width: 440, padding: 24, background: 'var(--color-bg)' }}>
|
||||||
@@ -35,6 +52,7 @@ export const DarkTheme: Story = {
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
play: async ({ canvasElement }) => expectLoginSurfaces(canvasElement),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const NarrowViewport: Story = {
|
export const NarrowViewport: Story = {
|
||||||
|
|||||||
@@ -31,6 +31,14 @@
|
|||||||
font-size: var(--font-size-sm);
|
font-size: var(--font-size-sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notice {
|
||||||
|
margin-bottom: var(--space-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form .loginInput {
|
||||||
|
background: var(--color-bg-subtle);
|
||||||
|
}
|
||||||
|
|
||||||
.form {
|
.form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export function LoginForm({ expired = false, signedOut = false, onSubmit }: Logi
|
|||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
name="username"
|
name="username"
|
||||||
|
className={styles.loginInput}
|
||||||
label={t('auth.username')}
|
label={t('auth.username')}
|
||||||
autoComplete="username"
|
autoComplete="username"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
@@ -95,6 +96,7 @@ export function LoginForm({ expired = false, signedOut = false, onSubmit }: Logi
|
|||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
name="password"
|
name="password"
|
||||||
|
className={styles.loginInput}
|
||||||
type="password"
|
type="password"
|
||||||
label={t('auth.password')}
|
label={t('auth.password')}
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
|
|||||||
Reference in new issue
Block a user