-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: append OneKey footer as shadow dom * fix: update layout padding * feat: update footer source url * fix: cleanup code
- Loading branch information
1 parent
4e409ee
commit 2cc1d44
Showing
4 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { FunctionComponent, useEffect, useRef } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
import { ILocale } from '../../types'; | ||
|
||
const LOCALE_MAPPING: { | ||
[TKey in ILocale]: string; | ||
} = { | ||
'en-US': '', | ||
'zh-CN': '/zh_CN', | ||
}; | ||
|
||
const BASE_URL = 'https://onekey.so'; | ||
|
||
export const Footer: FunctionComponent = () => { | ||
const intl = useIntl(); | ||
|
||
const containerRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
fetch( | ||
`${BASE_URL}${LOCALE_MAPPING[intl.locale as ILocale]}/internal/footer/` | ||
) | ||
.then((response) => response.text()) | ||
.then((data) => { | ||
const element = containerRef.current; | ||
|
||
if (!element) { | ||
return; | ||
} | ||
|
||
const shadowRoot = | ||
element.shadowRoot ?? element.attachShadow({ mode: 'open' }); | ||
|
||
shadowRoot.innerHTML = data; | ||
}) | ||
.catch(console.error); | ||
}, [intl.locale]); | ||
|
||
return <div ref={containerRef} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Footer } from './Footer'; | ||
|
||
export default Footer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters