ADD: Styled splash screen

This commit is contained in:
Robert Kossessa
2024-02-08 15:40:11 +01:00
parent f47f39a53a
commit b6cfdad3db
2 changed files with 61 additions and 23 deletions

View File

@@ -2,24 +2,61 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="icon" href="/src/assets/favicon.png"> <link rel="icon" href="src/assets/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ZERO/ONE Starting...</title> <title>ZERO/ONE Starting...</title>
<link rel="stylesheet" href="src/assets/main.css">
<style> <style>
body { body {
background: black; background: black url(src/assets/images/splashBG.png) center;
background-size: cover;
color: white; color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh; height: 100vh;
margin: 0; overflow: hidden;
}
.badge {
background: #f79c1e;
color: black;
display: inline-block;
align-self: center;
width: fit-content;
border-radius: 4px;
padding: 4px 8px;
}
.title {
margin-top: 10vh;
gap: 8px;
}
.status {
margin-top: 10vh;
}
.footer {
font-size: 0.5rem;
} }
</style> </style>
</head> </head>
<body> <body>
<div> <div class="flex h-full flex-col text-center justify-between items-center p-2 px-8 select-none">
<h1 style="font-family: 'Comic Sans MS', sans-serif">LOADING</h1> <div class="title flex flex-col gap-2">
<h1 class="text-5xl">ZERO<span class="opacity-70">/</span>ONE</h1>
<p class="text-muted-foreground">Configuration Suite v0.1</p>
<div class="badge text-xs">PUBLIC BETA</div>
<div class="status">
<p>Stand by...</p>
<p class="text-muted-foreground text-sm">The goblins are turning the cogs.</p>
</div>
</div>
<div class="footer flex flex-col gap-2 text-muted-foreground">
<img class="w-3 self-center" src="/src/assets/icons/binarisEmblem.svg" alt="binaris-logo">
<p>Copyright 2024 Binaris Circuitry Ltd.</p>
<p>This software is licensed under the Apache License, Version 2.0 (the "License"). Usage of this
software is
permitted only in compliance with the terms of the License.</p>
</div>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -14,23 +14,25 @@ if (ess) {
const isDevelopment = process.env.NODE_ENV !== 'production' const isDevelopment = process.env.NODE_ENV !== 'production'
// Minimum time to show the splash screen, in milliseconds // Minimum time to show the splash screen, in milliseconds
const splashTime = isDevelopment ? 500 : 3000 const splashTime = isDevelopment ? 40000 : 40000
const loadingWindowWidth = 800 / 2
const loadingWindowHeight = 1100 / 2
const zoomFactor = 1 const zoomFactor = 1
const width = 1111 const mainWindowWidth = 1111
const height = 666 const mainWindowHeight = 666
const createMainWindow = () => { const createMainWindow = () => {
// Create the browser window. // Create the browser window.
const mainWindow = new BrowserWindow({ const mainWindow = new BrowserWindow({
show: false, show: false,
width: width, width: mainWindowWidth,
height: height, height: mainWindowHeight,
titleBarStyle: 'hidden', titleBarStyle: 'hidden',
trafficLightPosition: { x: 10, y: 10 }, trafficLightPosition: { x: 10, y: 10 },
resizable: true, resizable: true,
minWidth: width / 3, minWidth: mainWindowWidth / 3,
minHeight: height / 3, minHeight: mainWindowHeight / 3,
maximizable: true, maximizable: true,
fullscreenable: false, fullscreenable: false,
center: true, center: true,
@@ -43,12 +45,12 @@ const createMainWindow = () => {
}, },
}) })
mainWindow.setAspectRatio(width / height) mainWindow.setAspectRatio(mainWindowWidth / mainWindowHeight)
mainWindow.webContents.on('dom-ready', () => { mainWindow.webContents.on('dom-ready', () => {
mainWindow.webContents.setZoomFactor(zoomFactor) mainWindow.webContents.setZoomFactor(zoomFactor)
}) })
mainWindow.on('resize', () => { mainWindow.on('resize', () => {
mainWindow.webContents.setZoomFactor(zoomFactor * mainWindow.getSize()[0] / width) mainWindow.webContents.setZoomFactor(zoomFactor * mainWindow.getSize()[0] / mainWindowWidth)
}) })
mainWindow.on('maximize', () => { mainWindow.on('maximize', () => {
mainWindow.webContents.send('electron:maximized') mainWindow.webContents.send('electron:maximized')
@@ -70,9 +72,9 @@ const createMainWindow = () => {
const createLoadingWindow = (mainWindow) => { const createLoadingWindow = (mainWindow) => {
const loadingWindow = new BrowserWindow({ const loadingWindow = new BrowserWindow({
show: false, show: false,
width: 400, width: loadingWindowWidth,
height: 600, height: loadingWindowHeight,
resizable: false, resizable: true,
fullscreenable: false, fullscreenable: false,
maximizable: false, maximizable: false,
transparent: true, transparent: true,
@@ -84,12 +86,11 @@ const createLoadingWindow = (mainWindow) => {
}, },
}) })
const startTime = Date.now() const startTime = Date.now()
let loading = true
let loadingTimeout let loadingTimeout
loadingWindow.once('show', () => { loadingWindow.once('show', () => {
mainWindow.webContents.once('did-finish-load', () => { mainWindow.webContents.once('did-finish-load', () => {
return
loadingTimeout = setTimeout(() => { loadingTimeout = setTimeout(() => {
loading = false
mainWindow.show() mainWindow.show()
mainWindow.focus() mainWindow.focus()
loadingWindow.close() loadingWindow.close()
@@ -97,7 +98,7 @@ const createLoadingWindow = (mainWindow) => {
}) })
}) })
loadingWindow.once('closed', () => { loadingWindow.once('closed', () => {
if (loading) { if (!mainWindow.isVisible()) {
clearTimeout(loadingTimeout) clearTimeout(loadingTimeout)
mainWindow.close() mainWindow.close()
} }