From 3b9714b99379cd0a6de61e08457432a6847b92ce Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Mon, 9 Sep 2024 17:10:39 +0800 Subject: [PATCH] refactor: set `lang` attribute for html tag (#6536) * refactor: set `lang` attribute for html tag * refactor: use shared i18next instance * refactor: align html attr usage --- .changeset/quiet-penguins-join.md | 7 +++++++ packages/console/src/App.tsx | 12 +++++++++++- packages/demo-app/package.json | 2 ++ packages/demo-app/src/App.tsx | 10 ++++++++++ packages/experience/src/App.tsx | 11 ++++++++++- .../experience/src/Providers/AppBoundary/AppMeta.tsx | 2 -- pnpm-lock.yaml | 6 ++++++ 7 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 .changeset/quiet-penguins-join.md diff --git a/.changeset/quiet-penguins-join.md b/.changeset/quiet-penguins-join.md new file mode 100644 index 000000000..1ea04e206 --- /dev/null +++ b/.changeset/quiet-penguins-join.md @@ -0,0 +1,7 @@ +--- +"@logto/experience": patch +"@logto/demo-app": patch +"@logto/console": patch +--- + +set `lang` attribute for `` diff --git a/packages/console/src/App.tsx b/packages/console/src/App.tsx index aac799a98..c5f3a5022 100644 --- a/packages/console/src/App.tsx +++ b/packages/console/src/App.tsx @@ -7,6 +7,7 @@ import { TenantScope, } from '@logto/schemas'; import { conditionalArray } from '@silverhand/essentials'; +import i18next from 'i18next'; import { useContext, useMemo } from 'react'; import { Helmet } from 'react-helmet'; import { createBrowserRouter, RouterProvider } from 'react-router-dom'; @@ -114,7 +115,16 @@ function Providers() { }} > - + diff --git a/packages/demo-app/package.json b/packages/demo-app/package.json index 2fbc7dabf..235b53d67 100644 --- a/packages/demo-app/package.json +++ b/packages/demo-app/package.json @@ -31,6 +31,7 @@ "@silverhand/ts-config-react": "6.0.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", + "@types/react-helmet": "^6.1.6", "@vitejs/plugin-react": "^4.3.1", "eslint": "^8.56.0", "i18next": "^22.4.15", @@ -40,6 +41,7 @@ "prettier": "^3.0.0", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-helmet": "^6.1.0", "react-i18next": "^12.3.1", "stylelint": "^15.0.0", "typescript": "^5.5.3", diff --git a/packages/demo-app/src/App.tsx b/packages/demo-app/src/App.tsx index 666bef60f..a714d4ff3 100644 --- a/packages/demo-app/src/App.tsx +++ b/packages/demo-app/src/App.tsx @@ -1,6 +1,8 @@ import { type IdTokenClaims, LogtoProvider, useLogto, type Prompt } from '@logto/react'; import { demoAppApplicationId } from '@logto/schemas'; +import i18next from 'i18next'; import { useCallback, useEffect, useState } from 'react'; +import { Helmet } from 'react-helmet'; import { useTranslation } from 'react-i18next'; import '@/scss/normalized.scss'; @@ -121,6 +123,14 @@ const Main = () => { return (
+ {showDevPanel && }
{congratsIcon && Congrats} diff --git a/packages/experience/src/App.tsx b/packages/experience/src/App.tsx index 3f2912334..178569c99 100644 --- a/packages/experience/src/App.tsx +++ b/packages/experience/src/App.tsx @@ -1,4 +1,6 @@ import { MfaFactor, experience } from '@logto/schemas'; +import i18next from 'i18next'; +import { Helmet } from 'react-helmet'; import { Route, Routes, BrowserRouter } from 'react-router-dom'; import AppLayout from './Layout/AppLayout'; @@ -39,7 +41,6 @@ import Springboard from './pages/Springboard'; import VerificationCode from './pages/VerificationCode'; import { UserMfaFlow } from './types'; import { handleSearchParametersData } from './utils/search-parameters'; - import './scss/normalized.scss'; handleSearchParametersData(); @@ -47,6 +48,14 @@ handleSearchParametersData(); const App = () => { return ( + diff --git a/packages/experience/src/Providers/AppBoundary/AppMeta.tsx b/packages/experience/src/Providers/AppBoundary/AppMeta.tsx index 5b1d0403f..78cfc73c6 100644 --- a/packages/experience/src/Providers/AppBoundary/AppMeta.tsx +++ b/packages/experience/src/Providers/AppBoundary/AppMeta.tsx @@ -1,7 +1,6 @@ import { Theme } from '@logto/schemas'; import { conditionalString } from '@silverhand/essentials'; import classNames from 'classnames'; -import i18next from 'i18next'; import { useContext } from 'react'; import { Helmet } from 'react-helmet'; @@ -38,7 +37,6 @@ const AppMeta = () => { return ( - {experienceSettings?.customCss && } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2ec5f576..782a9d5d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3213,6 +3213,9 @@ importers: '@types/react-dom': specifier: ^18.3.0 version: 18.3.0 + '@types/react-helmet': + specifier: ^6.1.6 + version: 6.1.6 '@vitejs/plugin-react': specifier: ^4.3.1 version: 4.3.1(vite@5.3.4(@types/node@20.12.7)(lightningcss@1.25.1)(sass@1.77.8)) @@ -3240,6 +3243,9 @@ importers: react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) + react-helmet: + specifier: ^6.1.0 + version: 6.1.0(react@18.3.1) react-i18next: specifier: ^12.3.1 version: 12.3.1(i18next@22.4.15)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)