feat(devx): introduce storybook
First shot at introducing storybook, with stories for the keycloak theme pages already in the repo.
This commit is contained in:
1 parent
38dd7a946e
commit
8cdc6b7730
9 files changed
+7120
-157
No files matched your search
@@ -0,0 +1,97 @@
|
||||
import { ComponentMeta } from '@storybook/react';
|
||||
import KcApp from '../KcApp';
|
||||
|
||||
import { useKcStoryData, socialProviders } from '../../../.storybook/data'
|
||||
|
||||
export default {
|
||||
title: 'Login',
|
||||
component: KcApp,
|
||||
parameters: {
|
||||
layout: 'fullscreen',
|
||||
},
|
||||
} as ComponentMeta<typeof KcApp>;
|
||||
|
||||
const pageId = 'login.ftl'
|
||||
|
||||
export const Default = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const InFrench = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, locale: { currentLanguageTag: 'fr' } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const RealmDisplayNameIsHtml = () => {
|
||||
const { kcContext } = useKcStoryData({
|
||||
pageId, message: undefined, realm: {
|
||||
displayNameHtml: '<marquee>my realm</marquee>'
|
||||
}
|
||||
})
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const NoInternationalization = () => {
|
||||
const { kcContext } = useKcStoryData({
|
||||
pageId, message: undefined, realm: {
|
||||
internationalizationEnabled: false,
|
||||
}
|
||||
})
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const NoPasswordField = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, realm: { password: false } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const RegistrationNotAllowed = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, realm: { registrationAllowed: false } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const RememberMeNotAllowed = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, realm: { rememberMe: false } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const PasswordResetNotAllowed = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, realm: { resetPasswordAllowed: false } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const EmailIsUsername = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, realm: { loginWithEmailAllowed: false } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const TryAnotherWay = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, auth: { showTryAnotherWayLink: true } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const PresetUsername = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, login: { username: 'max.mustermann@mail.com' } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const ReadOnlyPresetUsername = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: undefined, login: { username: 'max.mustermann@mail.com' }, usernameEditDisabled: true })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const WithSocialProviders = () => {
|
||||
const { kcContext } = useKcStoryData({
|
||||
pageId, message: undefined, social: {
|
||||
displayInfo: true,
|
||||
providers: socialProviders
|
||||
}
|
||||
})
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const WithError = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, message: { type: "error", summary: "This is an error" } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { ComponentMeta } from '@storybook/react';
|
||||
import KcApp from '../KcApp';
|
||||
|
||||
import { useKcStoryData } from '../../../.storybook/data'
|
||||
|
||||
export default {
|
||||
title: 'My Extra Page 1',
|
||||
component: KcApp,
|
||||
parameters: {
|
||||
layout: 'fullscreen',
|
||||
},
|
||||
} as ComponentMeta<typeof KcApp>;
|
||||
|
||||
const pageId = 'my-extra-page-1.ftl'
|
||||
|
||||
export const Default = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const InFrench = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, locale: { currentLanguageTag: 'fr' } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { ComponentMeta } from '@storybook/react';
|
||||
import KcApp from '../KcApp';
|
||||
|
||||
import { useKcStoryData } from '../../../.storybook/data'
|
||||
|
||||
export default {
|
||||
title: 'My Extra Page 2',
|
||||
component: KcApp,
|
||||
parameters: {
|
||||
layout: 'fullscreen',
|
||||
},
|
||||
} as ComponentMeta<typeof KcApp>;
|
||||
|
||||
const pageId = 'my-extra-page-2.ftl'
|
||||
|
||||
export const Default = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const InFrench = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, locale: { currentLanguageTag: 'fr' } })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
|
||||
export const WithCustomValue = () => {
|
||||
const { kcContext } = useKcStoryData({ pageId, someCustomValue: 'Foo Bar Baz' })
|
||||
return <KcApp kcContext={kcContext} />
|
||||
}
|
||||
Loaded 3 of 9 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user