Skip to content

Commit

Permalink
style(experience): update the devTenantNotification style (#6745)
Browse files Browse the repository at this point in the history
update the devTenantNotification style
  • Loading branch information
simeng-li authored Nov 5, 2024
1 parent 6698679 commit fe06860
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
2 changes: 2 additions & 0 deletions packages/experience-legacy/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -50,6 +51,7 @@ const App = () => {
<PageContextProvider>
<SettingsProvider>
<UserInteractionContextProvider>
<DevelopmentTenantNotification />
<AppBoundary>
<Routes>
<Route element={<LoadingLayerProvider />}>
Expand Down
2 changes: 0 additions & 2 deletions packages/experience-legacy/src/Layout/AppLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -17,7 +16,6 @@ const AppLayout = () => {
<div className={classNames(styles.container, layoutClassNames.pageContainer)}>
{!isMobile && <CustomContent className={layoutClassNames.customContent} />}
<main className={classNames(styles.main, layoutClassNames.mainContent)}>
<DevelopmentTenantNotification />
<Outlet />
<LogtoSignature className={classNames(styles.signature, layoutClassNames.signature)} />
</main>
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -50,27 +50,29 @@ const DevelopmentTenantNotification = () => {
const iconRef = useRef<HTMLSpanElement>(null);
const { experienceSettings, isPreview } = useContext(PageContext);
const { isDevelopmentTenant } = experienceSettings ?? {};
const { isMobile } = usePlatform();

const styles: Record<string, string> = Object.freeze({
display: 'flex',
'align-items': 'center',
'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<string, string> = 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(() => {
Expand All @@ -86,13 +88,14 @@ const DevelopmentTenantNotification = () => {
return null;
}

return (
return createPortal(
<div ref={ref}>
<span ref={iconRef}>
<DevIcon />
</span>
{t('development_tenant.notification')}
</div>
</div>,
document.body
);
};

Expand Down
2 changes: 2 additions & 0 deletions packages/experience/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -49,6 +50,7 @@ const App = () => {
<PageContextProvider>
<SettingsProvider>
<UserInteractionContextProvider>
<DevelopmentTenantNotification />
<AppBoundary>
<Routes>
<Route element={<LoadingLayerProvider />}>
Expand Down
2 changes: 0 additions & 2 deletions packages/experience/src/Layout/AppLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -17,7 +16,6 @@ const AppLayout = () => {
<div className={classNames(styles.container, layoutClassNames.pageContainer)}>
{!isMobile && <CustomContent className={layoutClassNames.customContent} />}
<main className={classNames(styles.main, layoutClassNames.mainContent)}>
<DevelopmentTenantNotification />
<Outlet />
<LogtoSignature className={classNames(styles.signature, layoutClassNames.signature)} />
</main>
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -50,27 +50,29 @@ const DevelopmentTenantNotification = () => {
const iconRef = useRef<HTMLSpanElement>(null);
const { experienceSettings, isPreview } = useContext(PageContext);
const { isDevelopmentTenant } = experienceSettings ?? {};
const { isMobile } = usePlatform();

const styles: Record<string, string> = Object.freeze({
display: 'flex',
'align-items': 'center',
'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<string, string> = 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(() => {
Expand All @@ -86,13 +88,14 @@ const DevelopmentTenantNotification = () => {
return null;
}

return (
return createPortal(
<div ref={ref}>
<span ref={iconRef}>
<DevIcon />
</span>
{t('development_tenant.notification')}
</div>
</div>,
document.body
);
};

Expand Down

0 comments on commit fe06860

Please sign in to comment.