Skip to content

Commit

Permalink
add reset css button
Browse files Browse the repository at this point in the history
  • Loading branch information
z3db0y committed Nov 4, 2024
1 parent 43c63fd commit 6306079
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
26 changes: 26 additions & 0 deletions assets/html/splash.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<h1 class="title">[Rays] Nova</h1>
<span id="status"></span>
<span id="quote"></span>
<button id="resetCSS">Reset CSS</button>
</body>
<style>
@font-face {
Expand Down Expand Up @@ -60,6 +61,31 @@ <h1 class="title">[Rays] Nova</h1>
max-width: 30%;
}

#resetCSS {
position: absolute;
top: 20px;
right: 20px;
padding: 10px 20px;
color: #fff;
background: #fff1;
font-size: 20px;
outline: none;
border: none;
border-radius: 8px;
transition: .5s;
cursor: pointer;
-webkit-app-region: no-drag;
}

#resetCSS:disabled {
opacity: 0.5;
cursor: not-allowed;
}

#resetCSS:not(:disabled):hover {
background: #fff2;
}

.back {
animation: dim 5s ease-in-out infinite;
}
Expand Down
14 changes: 14 additions & 0 deletions assets/html/splash.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,17 @@ ipcRenderer.on('setTitle', (_, title) => {
ipcRenderer.on('setQuote', (_, quote) => {
document.getElementById('quote').innerText = quote;
});

resetCSS.onclick = () => {
ipcRenderer.send('resetCSS');

let orig = resetCSS.textContent;

resetCSS.disabled = true;
resetCSS.textContent = 'CSS Reset!';

setTimeout(() => {
resetCSS.disabled = false;
resetCSS.textContent = orig;
}, 1000);
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rays_nova",
"version": "3.0.0-alpha.8",
"version": "3.0.0-alpha.9",
"main": "js/launch.js",
"devDependencies": {
"@types/node": "^20.10.7",
Expand Down
14 changes: 13 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function updater(setTitle: (title: string) => void) {

async function getKanyeQuote() {
return new Promise<string>((resolve, reject) => {
get('https://kanye.grool.xyz/', (res) => {
get('https://api.kanye.rest/', (res) => {
let data = '';
res.on('data', (chunk) => (data += chunk));
res.on('end', () => {
Expand Down Expand Up @@ -232,13 +232,25 @@ export async function launch(key: string, launchMode?: number) {
'setTitle'
);

let onResetCSSEvent: (event: Electron.IpcMainEvent) => void;

ipcMain.on(
'resetCSS',
(onResetCSSEvent = (event) => {
if (event.sender !== splashWindow.webContents) return;
config.set('modules.easycss.active', -1);
})
);

if (shouldUpdate) {
setTitle('Checking for updates...');
await updater(setTitle);
}

setTitle('Client up to date!');
setTimeout(() => {
ipcMain.off('resetCSS', onResetCSSEvent);

app.on('window-all-closed', (event) => event.preventDefault());
splashWindow.close();
app.removeAllListeners('window-all-closed');
Expand Down

0 comments on commit 6306079

Please sign in to comment.