Reuse the settings panel's scroll area for both explanation and actions while the close button stays in the header. Focusing the default deny action no longer scrolls the explanation away. Real rendered narrow/zoomed controls can scroll to Allow, close or cancel with Escape; no permission policy changes.
94 lines
4.9 KiB
HTML
94 lines
4.9 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'">
|
|
<title>Piik</title>
|
|
<style>
|
|
__PIIK_PALETTE__
|
|
__PIIK_BUTTONS__
|
|
__PIIK_PANEL__
|
|
* { box-sizing: border-box; }
|
|
html, body { margin: 0; height: 100%; }
|
|
body { background: var(--paper); color: var(--ink); font: 15px/1.5 system-ui; }
|
|
button { font-family: inherit; cursor: pointer; app-region: no-drag; }
|
|
button:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }
|
|
.c3-settings-dialog { position: static; width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
|
|
.c3-settings-dialog-heading { align-items: center; padding-block: 8px; app-region: drag; }
|
|
.c3-settings-dialog-heading .lr-btn { flex: none; }
|
|
.permission-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; letter-spacing: -.03em; }
|
|
.permission-brand > svg { width: 28px; height: 28px; }
|
|
.permission-body { display: flex; flex-direction: column; flex: 1; gap: 16px; }
|
|
.permission-request { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; flex: none; }
|
|
.permission-request > div { flex: 1 1 10em; min-width: 0; overflow-wrap: anywhere; }
|
|
.permission-request h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.35; }
|
|
.permission-origin { overflow-wrap: anywhere; user-select: text; }
|
|
.permission-scope { margin: 6px 0 0; font-size: 13px; }
|
|
.permission-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; flex: none; margin-top: auto; }
|
|
.permission-actions .lr-btn { min-width: 96px; }
|
|
.permission-glyph { flex: none; width: 36px; height: 36px; margin-top: 2px; }
|
|
.permission-glyph, #close svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
#close svg { width: 18px; height: 18px; }
|
|
</style>
|
|
<dialog open class="c3-settings-dialog" aria-labelledby="permission-title" aria-describedby="permission-origin">
|
|
<header class="c3-settings-dialog-heading">
|
|
<div class="permission-brand">__PIIK_BRAND_MARK__<strong>Piik</strong></div>
|
|
<button id="close" class="lr-btn is-quiet is-compact" type="button"><svg viewBox="0 0 24 24" aria-hidden="true"></svg></button>
|
|
</header>
|
|
<div class="c3-settings-panels permission-body">
|
|
<div class="permission-request">
|
|
<svg class="permission-glyph" viewBox="0 0 24 24" aria-hidden="true"></svg>
|
|
<div>
|
|
<h2 id="permission-title"></h2>
|
|
<div id="permission-origin" class="permission-origin" dir="ltr"></div>
|
|
<p id="permission-scope" class="permission-scope" hidden></p>
|
|
</div>
|
|
</div>
|
|
<footer class="permission-actions">
|
|
<button id="deny" class="lr-btn is-compact" type="button"></button>
|
|
<button id="allow" class="lr-btn is-primary is-compact" type="button"></button>
|
|
</footer>
|
|
</div>
|
|
</dialog>
|
|
<script>
|
|
const controls = __PIIK_WINDOW_CONTROLS__;
|
|
const request = window.piikPermission;
|
|
const close = document.getElementById('close');
|
|
const deny = document.getElementById('deny');
|
|
const allow = document.getElementById('allow');
|
|
const scope = document.getElementById('permission-scope');
|
|
if (!request.filename) {
|
|
scope.hidden = false;
|
|
document.querySelector('dialog').setAttribute('aria-describedby', 'permission-origin permission-scope');
|
|
}
|
|
for (const [selector, icon] of [['#close svg', 'close'], ['.permission-glyph', request.filename ? 'folder' : request.camera ? 'camera' : 'microphone']]) {
|
|
for (const geometry of controls.icons[icon]) {
|
|
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
path.setAttribute('d', geometry);
|
|
document.querySelector(selector).append(path);
|
|
}
|
|
}
|
|
document.getElementById('permission-origin').textContent = request.filename ?? request.origin;
|
|
window.updateAppearance = (theme, language) => {
|
|
document.documentElement.dataset.theme = theme;
|
|
document.documentElement.style.colorScheme = theme;
|
|
document.documentElement.lang = language;
|
|
const copy = controls.labels[language];
|
|
document.getElementById('permission-title').textContent = request.filename ? copy.revealQuestion : request.camera ? copy.camera : copy.microphone;
|
|
if (!request.filename) scope.textContent = controls.permissionScope[language] ?? controls.permissionScope.en;
|
|
close.title = copy.permissionClose;
|
|
close.setAttribute('aria-label', copy.permissionClose);
|
|
deny.textContent = request.filename ? copy.permissionClose : copy.deny;
|
|
allow.textContent = request.filename ? copy.reveal : copy.allow;
|
|
};
|
|
const answer = allowed => window.ipc.postMessage(allowed ? 'allow' : 'deny');
|
|
close.onclick = deny.onclick = () => answer(false);
|
|
allow.onclick = () => answer(true);
|
|
document.addEventListener('keydown', event => {
|
|
if (event.key === 'Escape') { event.preventDefault(); answer(false); }
|
|
});
|
|
window.updateAppearance(request.theme, request.language);
|
|
deny.focus({ preventScroll: true });
|
|
window.ipc.postMessage('ready');
|
|
</script>
|
|
</html>
|