Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: popup setup spinner #11053

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/mask/.webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const __dirname = fileURLToPath(dirname(import.meta.url))
const require = createRequire(import.meta.url)
const patchesDir = join(__dirname, '../../../patches')
const templateContent = readFile(join(__dirname, './template.html'), 'utf8')
const popupTemplateContent = readFile(join(__dirname, './popups.html'), 'utf8')

export async function createConfiguration(_inputFlags: BuildFlags): Promise<webpack.Configuration> {
const VERSION = JSON.parse(await readFile(new URL('../../../package.json', import.meta.url), 'utf-8')).version
const flags = normalizeBuildFlags(_inputFlags)
Expand Down Expand Up @@ -346,11 +348,11 @@ async function addHTMLEntry({
gun?: boolean
perf: boolean
}) {
let template = await templateContent
let template = await (options.filename === 'popups.html' ? popupTemplateContent : templateContent)
if (gun) template = template.replace(`<!-- Gun -->`, '<script src="/js/gun.js"></script>')
if (perf) template = template.replace(`<!-- Profiling -->`, '<script src="/js/perf-measure.js"></script>')
return new HTMLPlugin({
templateContent: template,
templateContent: options.filename === 'popups.html' ? popupTemplateContent : templateContent,
inject: 'body',
scriptLoading: 'defer',
minify: false,
Expand Down
98 changes: 98 additions & 0 deletions packages/mask/.webpack/popups.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<!doctype html>
<html>
<head>
<title>Mask Network</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<!-- CSP -->
<script src="/js/patches.js"></script>
<!-- Gun -->
<script src="/js/polyfill/ecmascript.js"></script>
<script src="/js/polyfill/dom.js"></script>
<script src="/js/polyfill/browser-polyfill.js"></script>
<script src="/js/sentry.js"></script>
<script src="/js/sentry-patch.js"></script>
<script src="/js/polyfill/lockdown.js"></script>
<script src="/js/lockdown.js"></script>
<script src="/js/trusted-types.js"></script>
<script src="/js/module-loader.js"></script>
<style>
body {
background: #ffffff;
margin: 0;
min-width: 400px;
min-height: 600px;
}
.text {
margin: 0;
font-family: Helvetica;
font-size: 14px;
color: #767f8d;
font-weight: 400;
margin-top: 12px;
margin-bottom: 0;
line-height: 1.5;
}
.spinner-box {
padding: 16px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.app-spinner-container {
display: flex;
flex-direction: column;
height: 100vh;
justify-content: center;
align-items: center;
overflow: hidden;
}
@media (prefers-color-scheme: dark) {
body {
background: #030303;
}
.app-spinner-container {
color: #ffffff;
}
.text {
color: rgba(255, 255, 255, 0.78);
}
}
@keyframes loadingAnimation {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.animate {
-webkit-animation: loadingAnimation 1s linear infinite;
animation: loadingAnimation 1s linear infinite;
}
</style>
</head>
<body>
<div class="app-spinner-container" id="app-spinner">
<div class="spinner-box">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36" width="24" height="24" class="animate">
<g fill="currentColor">
<path
d="M34.5 18c0 9.113-7.387 16.5-16.5 16.5S1.5 27.113 1.5 18 8.887 1.5 18 1.5 34.5 8.887 34.5 18ZM4.8 18c0 7.29 5.91 13.2 13.2 13.2 7.29 0 13.2-5.91 13.2-13.2 0-7.29-5.91-13.2-13.2-13.2-7.29 0-13.2 5.91-13.2 13.2Z"
opacity=".5" />
<path
d="M18 32.85c0 .911-.74 1.658-1.647 1.568A16.5 16.5 0 1 1 31.595 8.65c.517.751.218 1.76-.58 2.199-.799.439-1.794.14-2.33-.598a13.2 13.2 0 1 0-12.33 20.846c.903.114 1.645.842 1.645 1.753Z" />
</g>
</svg>
<p class="text">Loading</p>
</div>
</div>
</body>
</html>
6 changes: 6 additions & 0 deletions packages/mask/src/extension/popups/UI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const personaInitialState = {
const PopupRoutes = memo(function PopupRoutes() {
const location = useLocation()
const mainLocation = location.state?.mainLocation as Location | undefined

useEffect(() => {
const spinner = document.getElementById('app-spinner')
if (spinner) spinner.remove()
}, [])

return (
<Suspense
fallback={
Expand Down
Loading