From 2b4c85aa7ea668e9903647e155edd6b66eddf5d5 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Fri, 7 Jun 2024 05:20:57 +0200 Subject: [PATCH] update --- .prettierrc.json | 3 ++- .storybook/preview-head.html | 6 +++--- README.md | 23 +++++++++++++---------- package.json | 2 +- src/login/KcApp.tsx | 33 ++++++++++++++++++--------------- src/main.tsx | 1 - yarn.lock | 8 ++++---- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index aaeb4f2..6281138 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -14,7 +14,8 @@ "**/account/pages/*.tsx", "**/login/Template.tsx", "**/account/Template.tsx", - "**/login/UserProfileFormFields.tsx" + "**/login/UserProfileFormFields.tsx", + "KcApp.tsx" ], "options": { "printWidth": 150 diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html index 485c66e..da831e5 100644 --- a/.storybook/preview-head.html +++ b/.storybook/preview-head.html @@ -16,10 +16,10 @@ html { animation: fadeToTransparent 500ms forwards ease-in; } - body>.sb-preparing-docs { + body > .sb-preparing-docs { visibility: hidden; } - body>.sb-preparing-story { + body > .sb-preparing-story { visibility: hidden; } - \ No newline at end of file + diff --git a/README.md b/README.md index fb64e29..309807d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ 🚀 Keycloakify v10 starter 🚀

- -

This starter is based on Vite. There is also [a Webpack based starter](https://github.com/keycloakify/keycloakify-starter-cra). @@ -13,8 +11,9 @@ This starter is based on Vite. There is also [a Webpack based starter](https://g ```bash git clone https://github.com/keycloakify/keycloakify-starter cd keycloakify-starter -yarn install -yarn build-keycloak-theme # Build the keycloak theme, generate the .jar file to be imported in Keycloak +yarn install +# Generate the dist_keycloak/.jar file that you can import in Keycloak +yarn build-keycloak-theme ``` # Storybook @@ -34,8 +33,8 @@ npx keycloakify start-keycloak # Advanced customization -The starter only enables you to implement CSS level customization. To take full ownership -of some pages use the command: +The starter only enables you to implement CSS level customization. To take full ownership +of some pages use the command: ```bash npx keycloakify eject-page @@ -43,21 +42,25 @@ npx keycloakify eject-page # GitHub Actions -The starter comes with a GitHub Actions workflow that builds the theme and publishes +The starter comes with a generic GitHub Actions workflow that builds the theme and publishes the jars [as GitHub releases artifacts](https://github.com/keycloakify/keycloakify-starter/releases/tag/v7.1.0). +To release a new version **just update the `package.json` version and push**. + +To enable the workflow go to your fork of this repository on GitHub then navigate to: +`Settings` > `Actions` > `Workflow permissions`, select `Read and write permissions`. # Removing the account theme If you don't need to customize [the account theme pages](https://storybook.keycloakify.dev/?path=/story/account-account--default). -You can remove the `src/account` directory and make the necessary changes in `src/main.tsx` and `src/vite-env.d.ts`. +You can remove the `src/account` directory. This will significantly reduce the the size of the jar and the build time. +Don't forget to update `src/main.tsx` and `src/vite-env.d.ts`. # Email theme Keycloakify lets you bundle an email theme however customization can't be made with React yet. -It's just a regular Keycloak theme. +To initialize the email theme run: ```bash npx keycloakify initialize-email-theme ``` - diff --git a/package.json b/package.json index eba9831..168821b 100755 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "license": "MIT", "keywords": [], "dependencies": { - "keycloakify": "10.0.0-rc.34", + "keycloakify": "10.0.0-rc.35", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/src/login/KcApp.tsx b/src/login/KcApp.tsx index a4279b0..42f5760 100644 --- a/src/login/KcApp.tsx +++ b/src/login/KcApp.tsx @@ -16,23 +16,26 @@ export default function KcApp(props: { kcContext: KcContext }) { useDownloadTerms({ kcContext, - downloadTermMarkdown: async ({ currentLanguageTag }) => { - const termsFileName = (() => { - switch (currentLanguageTag) { - case "fr": - return "fr.md"; - case "es": - return "es.md"; - default: - return "en.md"; - } - })(); + downloadTermsMarkdown: async ({ currentLanguageTag }) => { + let termsLanguageTag = currentLanguageTag; + let termsFileName: string; - // Dynamically downloading Markdown files from public/terms/[currentLanguage].md - // Replace theses files by your organization's terms of service. - const response = await fetch(`${import.meta.env.BASE_URL}terms/${termsFileName}`); + switch (currentLanguageTag) { + case "fr": + termsFileName = "fr.md"; + break; + case "es": + termsFileName = "es.md"; + break; + default: + termsFileName = "en.md"; + termsLanguageTag = "en"; + break; + } - return response.text(); + const termsMarkdown = await fetch(`${import.meta.env.BASE_URL}terms/${termsFileName}`).then(r => r.text()); + + return { termsMarkdown, termsLanguageTag }; } }); diff --git a/src/main.tsx b/src/main.tsx index 374b519..8b46fb2 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -33,4 +33,3 @@ createRoot(document.getElementById("root")!).render( ); - diff --git a/yarn.lock b/yarn.lock index 261e563..6ae62e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5011,10 +5011,10 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -keycloakify@10.0.0-rc.34: - version "10.0.0-rc.34" - resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-10.0.0-rc.34.tgz#1909a053bd3f292afad6c98e59ecddfbf06f47b8" - integrity sha512-CAGc4h2CS0Q/Ol02ZANk/jd0ekrNgb8wlI8M8n0SficVNE4JI7+dMlrBfj8ZEmPh21enb/apQm48mj4KrjvSHA== +keycloakify@10.0.0-rc.35: + version "10.0.0-rc.35" + resolved "https://registry.yarnpkg.com/keycloakify/-/keycloakify-10.0.0-rc.35.tgz#8b5c1c22c7637d28f4eacc11ac358a001dad8ba5" + integrity sha512-Z5U5O/0U+Sx5ZkoS8pShCqR+iPoka8mD5OMvd/cciOk3opmpOvV5e5ZdJAGl2QI8Flb/0DRcWr+jE3Xlx9vZ0g== dependencies: react-markdown "^5.0.3" tsafe "^1.6.6"