Skip to content

Commit 9d4a501

Browse files
authored
feat(account-center): add powered by logto (#8021)
1 parent ca419d5 commit 9d4a501

File tree

8 files changed

+45
-30
lines changed

8 files changed

+45
-30
lines changed

packages/account-center/src/App.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import LogtoSignature from '@experience/shared/components/LogtoSignature';
12
import { LogtoProvider, useLogto, UserScope } from '@logto/react';
23
import { accountCenterApplicationId } from '@logto/schemas';
34
import { useContext, useEffect } from 'react';
45
import { BrowserRouter, Route, Routes } from 'react-router-dom';
56

67
import AppBoundary from '@ac/Providers/AppBoundary';
7-
import ErrorBoundary from '@ac/Providers/AppBoundary/ErrorBoundary';
8-
import LogtoErrorBoundary from '@ac/Providers/AppBoundary/LogtoErrorBoundary';
98
import LoadingContextProvider from '@ac/Providers/LoadingContextProvider';
109

1110
import styles from './App.module.scss';
1211
import Callback from './Callback';
12+
import ErrorBoundary from './Providers/AppBoundary/ErrorBoundary';
13+
import LogtoErrorBoundary from './Providers/AppBoundary/LogtoErrorBoundary';
1314
import PageContextProvider from './Providers/PageContextProvider';
1415
import PageContext from './Providers/PageContextProvider/PageContext';
1516
import BrandingHeader from './components/BrandingHeader';
@@ -20,7 +21,6 @@ import Home from './pages/Home';
2021
import Phone from './pages/Phone';
2122
import UpdateSuccess from './pages/UpdateSuccess';
2223
import { accountCenterBasePath, handleAccountCenterRoute } from './utils/account-center-route';
23-
2424
import '@experience/shared/scss/normalized.scss';
2525

2626
void initI18n();
@@ -68,6 +68,29 @@ const Main = () => {
6868
);
6969
};
7070

71+
const Layout = () => {
72+
const { experienceSettings, theme } = useContext(PageContext);
73+
const hideLogtoBranding = experienceSettings?.hideLogtoBranding === true;
74+
75+
return (
76+
<div className={styles.app}>
77+
<BrandingHeader />
78+
<div className={styles.layout}>
79+
<div className={styles.container}>
80+
<main className={styles.main}>
81+
<ErrorBoundary>
82+
<LogtoErrorBoundary>
83+
<Main />
84+
</LogtoErrorBoundary>
85+
</ErrorBoundary>
86+
{!hideLogtoBranding && <LogtoSignature className={styles.signature} theme={theme} />}
87+
</main>
88+
</div>
89+
</div>
90+
</div>
91+
);
92+
};
93+
7194
const App = () => (
7295
<BrowserRouter basename={accountCenterBasePath}>
7396
<LogtoProvider
@@ -80,20 +103,7 @@ const App = () => (
80103
<LoadingContextProvider>
81104
<PageContextProvider>
82105
<AppBoundary>
83-
<div className={styles.app}>
84-
<BrandingHeader />
85-
<div className={styles.layout}>
86-
<div className={styles.container}>
87-
<main className={styles.main}>
88-
<ErrorBoundary>
89-
<LogtoErrorBoundary>
90-
<Main />
91-
</LogtoErrorBoundary>
92-
</ErrorBoundary>
93-
</main>
94-
</div>
95-
</div>
96-
</div>
106+
<Layout />
97107
</AppBoundary>
98108
</PageContextProvider>
99109
</LoadingContextProvider>

packages/experience/src/Layout/AppLayout/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { useContext } from 'react';
33
import { Outlet } from 'react-router-dom';
44

55
import PageContext from '@/Providers/PageContextProvider/PageContext';
6-
import LogtoSignature from '@/components/LogtoSignature';
76
import usePlatform from '@/hooks/use-platform';
7+
import LogtoSignature from '@/shared/components/LogtoSignature';
88
import { layoutClassNames } from '@/utils/consts';
99

1010
import CustomContent from './CustomContent';
1111
import styles from './index.module.scss';
1212

1313
const AppLayout = () => {
14-
const { experienceSettings } = useContext(PageContext);
14+
const { experienceSettings, theme } = useContext(PageContext);
1515
const { isMobile } = usePlatform();
1616
const hideLogtoBranding = experienceSettings?.hideLogtoBranding === true;
1717

@@ -22,7 +22,10 @@ const AppLayout = () => {
2222
<main className={classNames(styles.main, layoutClassNames.mainContent)}>
2323
<Outlet />
2424
{!hideLogtoBranding && (
25-
<LogtoSignature className={classNames(styles.signature, layoutClassNames.signature)} />
25+
<LogtoSignature
26+
className={classNames(styles.signature, layoutClassNames.signature)}
27+
theme={theme}
28+
/>
2629
)}
2730
</main>
2831
</div>

packages/experience/src/assets/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ declare module '@/assets/icons/*.svg' {
44
const value: SvgComponent;
55
export default value;
66
}
7+
8+
declare module '@/shared/assets/icons/*.svg' {
9+
const value: SvgComponent;
10+
export default value;
11+
}

packages/experience/src/assets/icons/logto-logo-dark.svg renamed to packages/experience/src/shared/assets/icons/logto-logo-dark.svg

File renamed without changes.

packages/experience/src/assets/icons/logto-logo-light.svg renamed to packages/experience/src/shared/assets/icons/logto-logo-light.svg

File renamed without changes.

packages/experience/src/assets/icons/logto-logo-shadow.svg renamed to packages/experience/src/shared/assets/icons/logto-logo-shadow.svg

File renamed without changes.

packages/experience/src/components/LogtoSignature/index.module.scss renamed to packages/experience/src/shared/components/LogtoSignature/index.module.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@use '@/shared/scss/underscore' as _;
22

3-
43
.signature {
54
@include _.flex-row;
65
font: var(--font-label-2);
@@ -37,7 +36,6 @@
3736
}
3837
}
3938

40-
4139
:global(body.mobile) {
4240
.signature {
4341
color: var(--color-neutral-variant-80);

packages/experience/src/components/LogtoSignature/index.tsx renamed to packages/experience/src/shared/components/LogtoSignature/index.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Theme } from '@logto/schemas';
2-
import { useContext, useEffect, useRef } from 'react';
2+
import { useEffect, useRef } from 'react';
33

4-
import PageContext from '@/Providers/PageContextProvider/PageContext';
5-
import LogtoLogtoDark from '@/assets/icons/logto-logo-dark.svg?react';
6-
import LogtoLogoLight from '@/assets/icons/logto-logo-light.svg?react';
7-
import LogtoLogoShadow from '@/assets/icons/logto-logo-shadow.svg?react';
4+
import LogtoLogtoDark from '@/shared/assets/icons/logto-logo-dark.svg?react';
5+
import LogtoLogoLight from '@/shared/assets/icons/logto-logo-light.svg?react';
6+
import LogtoLogoShadow from '@/shared/assets/icons/logto-logo-shadow.svg?react';
87

98
import styles from './index.module.scss';
109

@@ -77,10 +76,10 @@ body.mobile [data-logto-signature="secured"][data-logto-signature="secured"] {
7776

7877
type Props = {
7978
readonly className?: string;
79+
readonly theme: Theme;
8080
};
8181

82-
const LogtoSignature = ({ className }: Props) => {
83-
const { theme } = useContext(PageContext);
82+
const LogtoSignature = ({ className, theme }: Props) => {
8483
const LogtoLogo = theme === Theme.Light ? LogtoLogoLight : LogtoLogtoDark;
8584

8685
const containerRef = useRef<HTMLDivElement>(null);
@@ -165,7 +164,7 @@ const LogtoSignature = ({ className }: Props) => {
165164
guardStyleElement.remove();
166165
}
167166
};
168-
}, [className]);
167+
}, []);
169168

170169
return (
171170
<div ref={containerRef} className={className} data-logto-signature-container="secured">

0 commit comments

Comments
 (0)