mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 20:01:10 +00:00
Merge pull request #87 from BinaryAlley/feature/add-client-side-dialogs
Implements client side dialogs styling
This commit is contained in:
7 files changed
+88
-20
No files matched your search
@@ -40,6 +40,10 @@ Several icons used in this project were adapted from icons sourced from [svgrepo
|
||||
- [`toggle-hidden.svg`](https://www.svgrepo.com/svg/470389/hidden) (MIT License)
|
||||
- [`delete.svg`](https://www.svgrepo.com/svg/488148/delete) (MIT License)
|
||||
- [`add-directory.svg`](https://www.svgrepo.com/svg/488040/add-folder) (MIT License)
|
||||
- [`information.svg`](https://www.svgrepo.com/svg/403685/information) (MIT License)
|
||||
- [`question.svg`](https://www.svgrepo.com/svg/486470/question-filled) (MIT License)
|
||||
- [`warning.svg`](https://www.svgrepo.com/svg/454067/warning) (MIT License)
|
||||
- [`error.svg`](https://www.svgrepo.com/svg/486408/error-filled) (MIT License)
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -36,11 +36,12 @@
|
||||
|
||||
.dialog-content {
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
padding-bottom: 15px;
|
||||
border-bottom: 1px solid #000;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -61,39 +62,46 @@
|
||||
}
|
||||
|
||||
.dialog-body {
|
||||
padding: 20px;
|
||||
border-top: 1px solid #000;
|
||||
border-left: 1px solid #000;
|
||||
border-right: 1px solid #505050;
|
||||
border-bottom: 1px solid #505050;
|
||||
padding: 5px;
|
||||
color: var(--text-foreground);
|
||||
font-family: monospace;
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
align-items: flex-start;
|
||||
display: block;
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
padding-left: 34px;
|
||||
}
|
||||
|
||||
.dialog-icon {
|
||||
position: sticky;
|
||||
top: 5px;
|
||||
float: left;
|
||||
margin-bottom: 5px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
flex-shrink: 0;
|
||||
margin-left: -29px;
|
||||
}
|
||||
|
||||
.dialog-icon.info {
|
||||
background-image: url('path-to-info-icon.svg');
|
||||
background-image: url('../images/ui/information.svg');
|
||||
}
|
||||
|
||||
.dialog-icon.warning {
|
||||
background-image: url('path-to-warning-icon.svg');
|
||||
background-image: url('../images/ui/warning.svg');
|
||||
}
|
||||
|
||||
.dialog-icon.error {
|
||||
background-image: url('path-to-error-icon.svg');
|
||||
background-image: url('../images/ui/error.svg');
|
||||
}
|
||||
|
||||
.dialog-icon.question {
|
||||
background-image: url('path-to-question-icon.svg');
|
||||
background-image: url('../images/ui/question.svg');
|
||||
}
|
||||
|
||||
.dialog-message {
|
||||
flex-grow: 1;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-word;
|
||||
hyphens: auto;
|
||||
@@ -105,7 +113,6 @@
|
||||
justify-content: flex-end;
|
||||
padding-top: 15px;
|
||||
gap: 10px;
|
||||
border-top: 1px solid #000;
|
||||
}
|
||||
|
||||
.dialog-button {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="24px" height="24px" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>error-filled</title>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="add" fill="#D41919" transform="translate(42.666667, 42.666667)">
|
||||
<path d="M213.333333,3.55271368e-14 C331.136,3.55271368e-14 426.666667,95.5306667 426.666667,213.333333 C426.666667,331.136 331.136,426.666667 213.333333,426.666667 C95.5306667,426.666667 3.55271368e-14,331.136 3.55271368e-14,213.333333 C3.55271368e-14,95.5306667 95.5306667,3.55271368e-14 213.333333,3.55271368e-14 Z M262.250667,134.250667 L213.333333,183.168 L164.416,134.250667 L134.250667,164.416 L183.168,213.333333 L134.250667,262.250667 L164.416,292.416 L213.333333,243.498667 L262.250667,292.416 L292.416,262.250667 L243.498667,213.333333 L292.416,164.416 L262.250667,134.250667 Z" id="Combined-Shape">
|
||||
|
||||
</path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="24px" height="24px" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--emojione-monotone" preserveAspectRatio="xMidYMid meet"><path d="M32 2C15.432 2 2 15.432 2 32s13.432 30 30 30s30-13.432 30-30S48.568 2 32 2m5 49.75H27v-24h10v24m-5-29.5a5 5 0 1 1 0-10a5 5 0 0 1 0 10" fill="#22B14C"></path></svg>
|
||||
|
After Width: | Height: | Size: 530 B |
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="24px" height="24px" viewBox="0 0 512 512" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>question-filled</title>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="red" fill-rule="evenodd">
|
||||
<g id="add" fill="#3F48CC" transform="translate(42.666667, 42.666667)">
|
||||
<path d="M213.333333,3.55271368e-14 C331.153707,3.55271368e-14 426.666667,95.51168 426.666667,213.333333 C426.666667,331.153707 331.153707,426.666667 213.333333,426.666667 C95.51296,426.666667 3.55271368e-14,331.153707 3.55271368e-14,213.333333 C3.55271368e-14,95.51168 95.51296,3.55271368e-14 213.333333,3.55271368e-14 Z M213.332053,282.666667 C198.60416,282.666667 186.665387,294.60544 186.665387,309.333333 C186.665387,324.061227 198.60416,336 213.332053,336 C228.059947,336 239.99872,324.061227 239.99872,309.333333 C239.99872,294.60544 228.059947,282.666667 213.332053,282.666667 Z M209.77344,93.3346133 C189.007787,93.3346133 171.554773,98.9922133 157.43488,110.274773 C140.703147,123.790507 132.34368,143.751253 132.34368,170.173227 L132.34368,170.173227 L177.7056,170.173227 L177.7056,169.868587 C177.7056,159.787733 179.829333,151.518293 184.065067,145.069013 C189.911467,136.398507 199.39328,132.059947 212.501333,132.059947 C220.56768,132.059947 227.4336,134.177067 233.070293,138.404907 C240.125013,144.26304 243.664,153.13024 243.664,165.028693 C243.664,172.49216 241.839787,179.143253 238.214827,184.994773 C235.188693,190.2368 230.350293,195.374933 223.686187,200.42048 C209.571627,210.098773 200.394453,219.679573 196.165333,229.162667 C192.53504,237.027413 190.710827,249.530027 190.710827,266.666667 L190.710827,266.666667 L233.376213,266.666667 C233.376213,255.371093 234.87744,246.90624 237.916587,241.257813 C240.331947,236.618667 245.378987,231.682347 253.042987,226.434987 C266.358187,216.549547 275.828267,207.371093 281.479253,198.90112 C288.33216,188.82176 291.76704,177.01952 291.76704,163.504 C291.76704,135.494827 280.37504,115.62624 257.571627,103.9232 C243.865813,96.86848 227.933653,93.3346133 209.77344,93.3346133 Z" id="Combined-Shape">
|
||||
|
||||
</path>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
␍<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="24px" height="24px" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" >
|
||||
␍<path d="M0 0h48v48H0z" fill="none"/>
|
||||
<g id="Shopicon">
|
||||
<path fill="#F8C515" d="M24,4C12.954,4,4,12.954,4,24s8.954,20,20,20s20-8.954,20-20S35.046,4,24,4z M24,36c-1.105,0-2-0.895-2-2
|
||||
c0-1.105,0.895-2,2-2c1.105,0,2,0.895,2,2C26,35.105,25.105,36,24,36z M26,28h-4V12h4V28z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 502 B |
@@ -97,10 +97,10 @@ class DialogService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and displays a dialog element in the DOM.
|
||||
* @private
|
||||
* @param {Object} dialog - The dialog configuration object.
|
||||
*/
|
||||
* Creates and displays a dialog element in the DOM.
|
||||
* @private
|
||||
* @param {Object} dialog - The dialog configuration object.
|
||||
*/
|
||||
displayDialog(dialog) {
|
||||
const modalBackground = document.getElementById('modal-background-article');
|
||||
modalBackground.style.display = 'block';
|
||||
@@ -126,19 +126,41 @@ class DialogService {
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
// add a resize observer to handle content height
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
const modalHeight = modalBackground.clientHeight;
|
||||
const dialogContent = dialogElement.querySelector('.dialog-content');
|
||||
dialogContent.style.maxHeight = `${modalHeight - 50}px`;
|
||||
dialogContent.style.overflowY = 'auto';
|
||||
});
|
||||
|
||||
resizeObserver.observe(modalBackground);
|
||||
|
||||
// cleanup observer when dialog is closed
|
||||
const cleanup = () => {
|
||||
resizeObserver.disconnect();
|
||||
document.removeEventListener('keydown', keyHandler);
|
||||
};
|
||||
|
||||
// add click handlers for buttons
|
||||
const buttons = dialogElement.querySelectorAll('.dialog-button');
|
||||
buttons.forEach(button => {
|
||||
button.addEventListener('click', () => this.handleButtonClick(button.dataset.button));
|
||||
button.addEventListener('click', () => {
|
||||
cleanup();
|
||||
this.handleButtonClick(button.dataset.button);
|
||||
});
|
||||
});
|
||||
|
||||
// add keyboard support
|
||||
const keyHandler = (e) => {
|
||||
if (e.key === 'Escape' && dialog.buttons.includes(DialogButton.CANCEL))
|
||||
if (e.key === 'Escape' && dialog.buttons.includes(DialogButton.CANCEL)) {
|
||||
cleanup();
|
||||
this.handleButtonClick(DialogButton.CANCEL);
|
||||
if (e.key === 'Enter' && dialog.buttons.includes(DialogButton.OK))
|
||||
}
|
||||
if (e.key === 'Enter' && dialog.buttons.includes(DialogButton.OK)) {
|
||||
cleanup();
|
||||
this.handleButtonClick(DialogButton.OK);
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', keyHandler);
|
||||
|
||||
|
||||
Reference in new issue
Block a user