-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
287c380
commit 12836ef
Showing
6 changed files
with
262 additions
and
9 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
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,115 @@ | ||
@import url("./fonts/fonts.css"); | ||
|
||
:root { | ||
user-select: none; | ||
-webkit-user-select: none; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
} | ||
div#notification { | ||
background: rgba(255, 255, 255, 0.5); | ||
backdrop-filter: blur(8px); | ||
border-radius: 8px; | ||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 11px rgba(0, 0, 0, 0.1); | ||
opacity: 1; | ||
transform: scale(1); | ||
transition: background-color 0.125s ease-in-out, opacity 0.125s ease-in-out, transform 0.125s ease-in-out; | ||
} | ||
|
||
div#notification.hidden { | ||
opacity: 0; | ||
transform: scale(0.9); | ||
} | ||
|
||
div#notification:hover { | ||
background: rgba(255, 255, 255, 0.75); | ||
} | ||
|
||
img#notificationicon { | ||
height: 24px; | ||
margin-right: 8px; | ||
} | ||
|
||
div#notificationheader { | ||
display: flex; | ||
flex-direction: row; | ||
padding: 12px; | ||
justify-content: space-between; | ||
border-bottom: rgba(0, 0, 0, 0.125) 1px solid; | ||
} | ||
|
||
div#notificationheader, div#notificationheader>:not(div#notificationclose) { | ||
-webkit-app-region: drag; | ||
} | ||
|
||
div#notificationclose { | ||
-webkit-app-region: no-drag; | ||
} | ||
|
||
left { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
} | ||
|
||
div#notificationtitle { | ||
text-transform: uppercase; | ||
font-family: "Uni Sans CAPS"; | ||
font-weight: bold; | ||
} | ||
|
||
div#notificationcontent { | ||
padding: 12px 16px; | ||
} | ||
|
||
div#notificationinfotitle { | ||
font-weight: bold; | ||
font-family: "Montserrat"; | ||
margin-bottom: 4px; | ||
} | ||
|
||
div#notificationinfo { | ||
font-family: 'Montserrat'; | ||
font-size: 12px; | ||
-webkit-line-clamp: 2; | ||
-webkit-box-orient: vertical; | ||
white-space: pre-wrap; | ||
display: -webkit-box; | ||
overflow: hidden; | ||
} | ||
|
||
div#notification:has(button:not(:empty)) div#notificationinfo { | ||
margin-bottom: 16px; | ||
} | ||
|
||
div#notificationbuttons { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-around; | ||
} | ||
|
||
button { | ||
all: unset; | ||
cursor: pointer; | ||
padding: 8px; | ||
background: rgba(255, 255, 255, 0.5); | ||
font-family: 'Montserrat'; | ||
font-weight: 666; | ||
font-size: 12px; | ||
text-align: center; | ||
border-radius: 8px | ||
} | ||
|
||
div#notificationbuttons>button:not(:empty) { | ||
width: 1000%; | ||
} | ||
|
||
div#notificationbuttons:not(:has(button:empty))>button:not(:last-child) { | ||
margin-right: 25px | ||
} | ||
|
||
button:empty { | ||
display: none; | ||
} |
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,27 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="notification.css"> | ||
</head> | ||
<body> | ||
<div id="notification"> | ||
<div id="notificationheader"> | ||
<left> | ||
<img id="notificationicon" src="./res/DEADFORGE.icon.png"> | ||
<div id="notificationtitle">deadforge</div> | ||
</left> | ||
<right> | ||
<div id="notificationclose" class="material-symbols-outlined" onclick="closeNotification(null)">close</div> | ||
</right> | ||
</div> | ||
<div id="notificationcontent"> | ||
<div id="notificationinfotitle"></div> | ||
<div id="notificationinfo"></div> | ||
<div id="notificationbuttons"> | ||
<button id="notificationbuttonA" onclick="notificationActionA()"></button> | ||
<button id="notificationbuttonB" onclick="notificationActionB()"></button> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
<script src="notification.js"></script> | ||
</html> |
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,52 @@ | ||
const { ipcRenderer } = require('electron'); | ||
const { BrowserWindow } = require('@electron/remote'); | ||
|
||
let notificationActionA, notificationActionB, timer; | ||
|
||
function closeNotification(callbackFn = null) { | ||
document.querySelector('div#notification').classList.add('hidden'); | ||
setTimeout(() => { | ||
ipcRenderer.send('notificationclose', callbackFn); | ||
}, 125); | ||
} | ||
|
||
ipcRenderer.on('notification', (event, notification) => { | ||
console.log(notification); | ||
const title = notification.title; | ||
const message = notification.message; | ||
const actionA = notification.actionA && notification.actionA.message ? notification.actionA : null; | ||
const actionB = notification.actionB && notification.actionB.message ? notification.actionB : null; | ||
|
||
document.querySelector('div#notificationinfotitle').textContent = title; | ||
document.querySelector('div#notificationinfo').textContent = message; | ||
|
||
if (actionA != null) { | ||
document.querySelector('button#notificationbuttonA').textContent = actionA.message; | ||
notificationActionA = () => { closeNotification(actionA.callbackFn) }; | ||
} | ||
|
||
if (actionB != null) { | ||
document.querySelector('button#notificationbuttonB').textContent = actionB.message; | ||
notificationActionB = () => { closeNotification(actionB.callbackFn) }; | ||
} | ||
}) | ||
|
||
const startTimeout = () => { | ||
timer = setTimeout(closeNotification, 5000); | ||
}; | ||
|
||
const resetTimeout = () => { | ||
clearTimeout(timer); | ||
}; | ||
|
||
window.addEventListener('load', () => { | ||
startTimeout(); | ||
}); | ||
|
||
document.querySelector('div#notification').addEventListener('mouseenter', () => { | ||
resetTimeout(); | ||
}); | ||
|
||
document.querySelector('div#notification').addEventListener('mouseleave', () => { | ||
startTimeout(); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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