-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from lordvlad/lordvlad/issue125
feat(devx): introduce storybook
- Loading branch information
Showing
50 changed files
with
9,067 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,20 @@ jobs: | |
name: build | ||
path: build | ||
|
||
deploy_storybook: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/[email protected] | ||
with: | ||
node-version: '16' | ||
- uses: bahmutov/npm-install@v1 | ||
- run: yarn build-storybook -o ./build_storybook | ||
- run: git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${{github.repository}}.git | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- run: npx -y -p [email protected] gh-pages -d ./build_storybook --dest storybook --add -u "github-actions-bot <[email protected]>" | ||
|
||
check_if_version_upgraded: | ||
name: Check if version upgrade | ||
runs-on: ubuntu-latest | ||
|
@@ -53,7 +67,7 @@ jobs: | |
needs: | ||
- check_if_version_upgraded | ||
- build | ||
# We publish the the docker image only if it's a push on the default branch or if it's a PR from a | ||
# We publish the docker image only if it's a push on the default branch or if it's a PR from a | ||
# branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.DOCKERHUB_TOKEN is | ||
# defined but GitHub Action don't allow it. | ||
if: | | ||
|
@@ -80,7 +94,7 @@ jobs: | |
- check_if_version_upgraded | ||
- build | ||
runs-on: ubuntu-latest | ||
# We publish the the docker image only if it's a push on the default branch or if it's a PR from a | ||
# We publish the docker image only if it's a push on the default branch or if it's a PR from a | ||
# branch (meaning not a PR from a fork). It would be more straightforward to test if secrets.DOCKERHUB_TOKEN is | ||
# defined but GitHub Action don't allow it. | ||
if: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,5 @@ jspm_packages | |
/dist | ||
|
||
/build_keycloak | ||
/build | ||
/build | ||
/storybook-static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
"stories": [ | ||
"../src/keycloak-theme/**/*.stories.tsx", | ||
], | ||
"addons": [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
"@storybook/preset-create-react-app" | ||
], | ||
"framework": "@storybook/react", | ||
"core": { | ||
"builder": "@storybook/builder-webpack5" | ||
}, | ||
"staticDirs": ['../public'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const parameters = { | ||
actions: {argTypesRegex: "^on[A-Z].*"}, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
options: { | ||
storySort: (a, b) => | ||
a[1].kind === b[1].kind ? 0 : a[1].id.localeCompare(b[1].id, undefined, {numeric: true}), | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type {KcContextExtension} from "keycloak-theme/kcContext"; | ||
import KcApp from "../src/keycloak-theme/KcApp"; | ||
import {KcContextBase} from "keycloakify"; | ||
import {getKcContext} from "keycloakify/lib/getKcContext"; | ||
import {ExtendsKcContextBase} from "keycloakify/src/lib/getKcContext/getKcContextFromWindow"; | ||
import {DeepPartial} from "keycloakify/src/lib/tools/DeepPartial"; | ||
|
||
|
||
export const socialProviders = [ | ||
{loginUrl: 'google', alias: 'google', providerId: 'google', displayName: 'Google'}, | ||
{loginUrl: 'microsoft', alias: 'microsoft', providerId: 'microsoft', displayName: 'Microsoft'}, | ||
{loginUrl: 'facebook', alias: 'facebook', providerId: 'facebook', displayName: 'Facebook'}, | ||
{loginUrl: 'instagram', alias: 'instagram', providerId: 'instagram', displayName: 'Instagram'}, | ||
{loginUrl: 'twitter', alias: 'twitter', providerId: 'twitter', displayName: 'Twitter'}, | ||
{loginUrl: 'linkedin', alias: 'linkedin', providerId: 'linkedin', displayName: 'LinkedIn'}, | ||
{loginUrl: 'stackoverflow', alias: 'stackoverflow', providerId: 'stackoverflow', displayName: 'Stackoverflow'}, | ||
{loginUrl: 'github', alias: 'github', providerId: 'github', displayName: 'Github'}, | ||
{loginUrl: 'gitlab', alias: 'gitlab', providerId: 'gitlab', displayName: 'Gitlab'}, | ||
{loginUrl: 'bitbucket', alias: 'bitbucket', providerId: 'bitbucket', displayName: 'Bitbucket'}, | ||
{loginUrl: 'paypal', alias: 'paypal', providerId: 'paypal', displayName: 'PayPal'}, | ||
{loginUrl: 'openshift', alias: 'openshift', providerId: 'openshift', displayName: 'OpenShift'}, | ||
] | ||
|
||
type PageId = (KcContextExtension | KcContextBase)['pageId'] | ||
export const template = (pageId: PageId) => { | ||
type MockData = DeepPartial<ExtendsKcContextBase<KcContextExtension>>; | ||
|
||
const Template = (mockData: MockData) => { | ||
const finalMockData = { | ||
message: undefined, | ||
pageId, | ||
...mockData | ||
} as MockData | ||
if (!("message" in mockData)) mockData["message"] = undefined | ||
const {kcContext} = getKcContext<KcContextExtension>({mockPageId: pageId, mockData: [finalMockData]}) | ||
return <KcApp kcContext={kcContext as NonNullable<typeof kcContext>}/> | ||
} | ||
|
||
return (args: MockData) => Object.assign(Template.bind({}), {args}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type {ComponentMeta} from '@storybook/react'; | ||
import KcApp from './KcApp'; | ||
import {template} from '../../.storybook/util' | ||
|
||
const bind = template('my-extra-page-1.ftl'); | ||
|
||
export default { | ||
title: 'Theme/Template', | ||
component: KcApp, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} as ComponentMeta<typeof KcApp>; | ||
|
||
|
||
export const Default = bind({}) | ||
export const InFrench = bind({locale: {currentLanguageTag: 'fr'}}) | ||
export const RealmDisplayNameIsHtml = bind({ | ||
realm: { | ||
displayNameHtml: '<marquee>my realm</marquee>' | ||
} | ||
}) | ||
|
||
export const NoInternationalization = bind({ | ||
realm: { | ||
internationalizationEnabled: false, | ||
} | ||
}) | ||
|
||
export const WithGlobalError = bind({ | ||
message: {type: "error", summary: "This is an error"} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {ComponentMeta} from '@storybook/react'; | ||
import KcApp from '../KcApp'; | ||
import {template} from '../../../.storybook/util' | ||
|
||
const bind = template('error.ftl'); | ||
|
||
export default { | ||
kind: 'Page', | ||
title: 'Theme/Pages/Notification/Error', | ||
component: KcApp, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} as ComponentMeta<typeof KcApp>; | ||
|
||
export const Default = bind({message: {type: 'error', summary: 'Something went wrong'}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// copied and adapted from https://github.com/InseeFrLab/keycloakify/blob/main/src/lib/pages/Error.tsx | ||
import React from "react"; | ||
import type { PageProps } from "keycloakify" | ||
import type { KcContext } from "../kcContext"; | ||
import type { I18n } from "../i18n"; | ||
|
||
|
||
export default function Error(props: PageProps<Extract<KcContext, { pageId: "error.ftl" }>, I18n>) { | ||
const { kcContext, i18n, doFetchDefaultThemeResources = true, Template, ...kcProps } = props; | ||
|
||
const { message, client } = kcContext; | ||
|
||
const { msg } = i18n; | ||
|
||
return ( | ||
<Template | ||
{...{ kcContext, i18n, doFetchDefaultThemeResources, ...kcProps }} | ||
displayMessage={false} | ||
headerNode={msg("errorTitle")} | ||
formNode={ | ||
<div id="kc-error-message"> | ||
<p className="instruction">{message.summary}</p> | ||
{client !== undefined && client.baseUrl !== undefined && ( | ||
<p> | ||
<a id="backToApplication" href={client.baseUrl}> | ||
{msg("backToApplication")} | ||
</a> | ||
</p> | ||
)} | ||
</div> | ||
} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ComponentMeta } from '@storybook/react'; | ||
import KcApp from '../KcApp'; | ||
import { template } from '../../../.storybook/util' | ||
|
||
const bind = template('idp-review-user-profile.ftl'); | ||
|
||
export default { | ||
kind: 'Page', | ||
title: 'Theme/Pages/IDP/Review User Profile', | ||
component: KcApp, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
} as ComponentMeta<typeof KcApp>; | ||
|
||
export const Default = bind({}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useState } from "react"; | ||
import { clsx } from "keycloakify/lib/tools/clsx"; | ||
import { UserProfileFormFields } from "keycloakify/lib/pages/shared/UserProfileCommons"; | ||
import type { PageProps } from "keycloakify"; | ||
import type { KcContext } from "../kcContext"; | ||
import type { I18n } from "../i18n"; | ||
|
||
export default function IdpReviewUserProfile(props: PageProps<Extract<KcContext, { pageId: "idp-review-user-profile.ftl" }>, I18n>) { | ||
const { kcContext, i18n, doFetchDefaultThemeResources = true, Template, ...kcProps } = props; | ||
|
||
const { msg, msgStr } = i18n; | ||
|
||
const { url } = kcContext; | ||
|
||
const [isFomSubmittable, setIsFomSubmittable] = useState(false); | ||
|
||
return ( | ||
<Template | ||
{...{ kcContext, i18n, doFetchDefaultThemeResources, ...kcProps }} | ||
headerNode={msg("loginIdpReviewProfileTitle")} | ||
formNode={ | ||
<form id="kc-idp-review-profile-form" className={clsx(kcProps.kcFormClass)} action={url.loginAction} method="post"> | ||
<UserProfileFormFields kcContext={kcContext} onIsFormSubmittableValueChange={setIsFomSubmittable} i18n={i18n} {...kcProps} /> | ||
|
||
<div className={clsx(kcProps.kcFormGroupClass)}> | ||
<div id="kc-form-options" className={clsx(kcProps.kcFormOptionsClass)}> | ||
<div className={clsx(kcProps.kcFormOptionsWrapperClass)} /> | ||
</div> | ||
<div id="kc-form-buttons" className={clsx(kcProps.kcFormButtonsClass)}> | ||
<input | ||
className={clsx( | ||
kcProps.kcButtonClass, | ||
kcProps.kcButtonPrimaryClass, | ||
kcProps.kcButtonBlockClass, | ||
kcProps.kcButtonLargeClass | ||
)} | ||
type="submit" | ||
value={msgStr("doSubmit")} | ||
disabled={!isFomSubmittable} | ||
/> | ||
</div> | ||
</div> | ||
</form> | ||
} | ||
/> | ||
); | ||
} |
Oops, something went wrong.