From fe0686064500953344cb0c0dad434257e701b34e Mon Sep 17 00:00:00 2001 From: simeng-li Date: Tue, 5 Nov 2024 13:59:07 +0800 Subject: [PATCH] style(experience): update the devTenantNotification style (#6745) update the devTenantNotification style --- packages/experience-legacy/src/App.tsx | 2 ++ .../src/Layout/AppLayout/index.tsx | 2 -- .../DevelopmentTenantNotification/index.tsx | 23 +++++++++++-------- packages/experience/src/App.tsx | 2 ++ .../experience/src/Layout/AppLayout/index.tsx | 2 -- .../DevelopmentTenantNotification/index.tsx | 23 +++++++++++-------- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/packages/experience-legacy/src/App.tsx b/packages/experience-legacy/src/App.tsx index 3f2912334f8..e6e191bf0df 100644 --- a/packages/experience-legacy/src/App.tsx +++ b/packages/experience-legacy/src/App.tsx @@ -7,6 +7,7 @@ import LoadingLayerProvider from './Providers/LoadingLayerProvider'; import PageContextProvider from './Providers/PageContextProvider'; import SettingsProvider from './Providers/SettingsProvider'; import UserInteractionContextProvider from './Providers/UserInteractionContextProvider'; +import DevelopmentTenantNotification from './containers/DevelopmentTenantNotification'; import Callback from './pages/Callback'; import Consent from './pages/Consent'; import Continue from './pages/Continue'; @@ -50,6 +51,7 @@ const App = () => { + }> diff --git a/packages/experience-legacy/src/Layout/AppLayout/index.tsx b/packages/experience-legacy/src/Layout/AppLayout/index.tsx index 1b0ce7beb26..3762440163b 100644 --- a/packages/experience-legacy/src/Layout/AppLayout/index.tsx +++ b/packages/experience-legacy/src/Layout/AppLayout/index.tsx @@ -2,7 +2,6 @@ import classNames from 'classnames'; import { Outlet } from 'react-router-dom'; import LogtoSignature from '@/components/LogtoSignature'; -import DevelopmentTenantNotification from '@/containers/DevelopmentTenantNotification'; import usePlatform from '@/hooks/use-platform'; import { layoutClassNames } from '@/utils/consts'; @@ -17,7 +16,6 @@ const AppLayout = () => {
{!isMobile && }
-
diff --git a/packages/experience-legacy/src/containers/DevelopmentTenantNotification/index.tsx b/packages/experience-legacy/src/containers/DevelopmentTenantNotification/index.tsx index 852a6394813..7858e7ee9f5 100644 --- a/packages/experience-legacy/src/containers/DevelopmentTenantNotification/index.tsx +++ b/packages/experience-legacy/src/containers/DevelopmentTenantNotification/index.tsx @@ -1,9 +1,9 @@ import { useContext, useEffect, useRef } from 'react'; +import { createPortal } from 'react-dom'; import { useTranslation } from 'react-i18next'; import PageContext from '@/Providers/PageContextProvider/PageContext'; import DevIcon from '@/assets/icons/dev-icon.svg?react'; -import usePlatform from '@/hooks/use-platform'; /** * Styles that may effect the visibility of a DOM element. @@ -50,7 +50,6 @@ const DevelopmentTenantNotification = () => { const iconRef = useRef(null); const { experienceSettings, isPreview } = useContext(PageContext); const { isDevelopmentTenant } = experienceSettings ?? {}; - const { isMobile } = usePlatform(); const styles: Record = Object.freeze({ display: 'flex', @@ -58,19 +57,22 @@ const DevelopmentTenantNotification = () => { 'justify-content': 'center', 'align-self': 'stretch', gap: '8px', - margin: isMobile ? '-16px -20px 16px' : '-24px -24px 0', - padding: '12px 16px', - 'border-radius': isMobile ? 'unset' : '8px 8px 0 0', - background: 'var(--color-container-alert)', + padding: '6px 16px', + 'border-radius': 'unset', + background: 'var(--color-container-on-alert)', font: 'var(--font-label-2)', - color: 'var(--color-type-primary)', + color: 'var(--color-static-white)', + position: 'fixed', + left: '0', + right: '0', + 'z-index': '9999', }); const iconStyles: Record = Object.freeze({ // Use 'display: inline-flex' and 'align-items: center' to vertically center the icon display: 'inline-flex', 'align-items': 'center', - color: 'var(--color-container-on-alert)', + color: 'var(--color-container-alert)', }); useEffect(() => { @@ -86,13 +88,14 @@ const DevelopmentTenantNotification = () => { return null; } - return ( + return createPortal(
{t('development_tenant.notification')} -
+
, + document.body ); }; diff --git a/packages/experience/src/App.tsx b/packages/experience/src/App.tsx index 680b9c351e3..3c1bfa846ca 100644 --- a/packages/experience/src/App.tsx +++ b/packages/experience/src/App.tsx @@ -7,6 +7,7 @@ import LoadingLayerProvider from './Providers/LoadingLayerProvider'; import PageContextProvider from './Providers/PageContextProvider'; import SettingsProvider from './Providers/SettingsProvider'; import UserInteractionContextProvider from './Providers/UserInteractionContextProvider'; +import DevelopmentTenantNotification from './containers/DevelopmentTenantNotification'; import Callback from './pages/Callback'; import Consent from './pages/Consent'; import Continue from './pages/Continue'; @@ -49,6 +50,7 @@ const App = () => { + }> diff --git a/packages/experience/src/Layout/AppLayout/index.tsx b/packages/experience/src/Layout/AppLayout/index.tsx index 1b0ce7beb26..3762440163b 100644 --- a/packages/experience/src/Layout/AppLayout/index.tsx +++ b/packages/experience/src/Layout/AppLayout/index.tsx @@ -2,7 +2,6 @@ import classNames from 'classnames'; import { Outlet } from 'react-router-dom'; import LogtoSignature from '@/components/LogtoSignature'; -import DevelopmentTenantNotification from '@/containers/DevelopmentTenantNotification'; import usePlatform from '@/hooks/use-platform'; import { layoutClassNames } from '@/utils/consts'; @@ -17,7 +16,6 @@ const AppLayout = () => {
{!isMobile && }
-
diff --git a/packages/experience/src/containers/DevelopmentTenantNotification/index.tsx b/packages/experience/src/containers/DevelopmentTenantNotification/index.tsx index 852a6394813..7858e7ee9f5 100644 --- a/packages/experience/src/containers/DevelopmentTenantNotification/index.tsx +++ b/packages/experience/src/containers/DevelopmentTenantNotification/index.tsx @@ -1,9 +1,9 @@ import { useContext, useEffect, useRef } from 'react'; +import { createPortal } from 'react-dom'; import { useTranslation } from 'react-i18next'; import PageContext from '@/Providers/PageContextProvider/PageContext'; import DevIcon from '@/assets/icons/dev-icon.svg?react'; -import usePlatform from '@/hooks/use-platform'; /** * Styles that may effect the visibility of a DOM element. @@ -50,7 +50,6 @@ const DevelopmentTenantNotification = () => { const iconRef = useRef(null); const { experienceSettings, isPreview } = useContext(PageContext); const { isDevelopmentTenant } = experienceSettings ?? {}; - const { isMobile } = usePlatform(); const styles: Record = Object.freeze({ display: 'flex', @@ -58,19 +57,22 @@ const DevelopmentTenantNotification = () => { 'justify-content': 'center', 'align-self': 'stretch', gap: '8px', - margin: isMobile ? '-16px -20px 16px' : '-24px -24px 0', - padding: '12px 16px', - 'border-radius': isMobile ? 'unset' : '8px 8px 0 0', - background: 'var(--color-container-alert)', + padding: '6px 16px', + 'border-radius': 'unset', + background: 'var(--color-container-on-alert)', font: 'var(--font-label-2)', - color: 'var(--color-type-primary)', + color: 'var(--color-static-white)', + position: 'fixed', + left: '0', + right: '0', + 'z-index': '9999', }); const iconStyles: Record = Object.freeze({ // Use 'display: inline-flex' and 'align-items: center' to vertically center the icon display: 'inline-flex', 'align-items': 'center', - color: 'var(--color-container-on-alert)', + color: 'var(--color-container-alert)', }); useEffect(() => { @@ -86,13 +88,14 @@ const DevelopmentTenantNotification = () => { return null; } - return ( + return createPortal(
{t('development_tenant.notification')} -
+
, + document.body ); };