Skip to content

Commit

Permalink
[keebs] regression fixes (#136)
Browse files Browse the repository at this point in the history
* regression fix: keeb emulation
* update keeb SVGs
* match x-keyboard and svg colors
  • Loading branch information
fabi1cazenave authored Mar 15, 2024
1 parent f532ab5 commit cb74782
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 317 deletions.
32 changes: 15 additions & 17 deletions code/keebs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* <div class="keyboard">
* <object data="/img/ergol.svg" class="dk"></object>
* <p>
* <span>powered by <a
* href="https://github.com/OneDeadKey/x-keyboard">x-keyboard</a></span>
* <small>géométrie :</small>
* <select>
* <option>ISO</option> <!-- filled when loaded -->
* </select>
* </p>
* <div>
* <object data="/img/ergol.svg" class="odk"></object>
* </div>
* <form>
* <fieldset><input type="radio" name="layers"/>…</fieldset>
* <fieldset><input type="radio" name="geopetry"/>…</fieldset>
* </form>
* <dialog>
* <input></input>
* <input placeholder="…"/>
* <x-keyboard></x-keyboard>
* </dialog>
* </div>
Expand Down Expand Up @@ -54,7 +52,7 @@ for (const keeb of document.querySelectorAll('.keyboard')) {
const dialog = keeb.querySelector('dialog');
const keyboard = keeb.querySelector('x-keyboard');
const preview = keeb.querySelector('object');
const input = keeb.querySelector('input');
const input = keeb.querySelector('input[placeholder]');
const form = keeb.querySelector('form');
const geometry = keeb.querySelector('select') || document.getElementById('geometry');
const button = keeb.querySelector('button');
Expand Down Expand Up @@ -101,15 +99,15 @@ for (const keeb of document.querySelectorAll('.keyboard')) {
/**
* Open/Close modal
*/
if (button) button.onclick = () => {
button?.addEventListener('click', () => {
dialog?.showModal();
input.value = '';
input.focus();
}
input.onblur = () => {
});
input.addEventListener('blur', () => {
keyboard.clearStyle()
dialog?.close();
}
});

/**
* Keyboard highlighting & layout emulation
Expand All @@ -119,7 +117,7 @@ for (const keeb of document.querySelectorAll('.keyboard')) {
const pressedKeys = {};

// highlight keyboard keys and emulate the selected layout
input.onkeydown = event => {
input.addEventListener('keydown', event => {
pressedKeys[event.code] = true;
const value = keyboard.keyDown(event);

Expand All @@ -131,7 +129,7 @@ for (const keeb of document.querySelectorAll('.keyboard')) {
return true; // don't intercept special keys or key shortcuts
}
return false; // event has been consumed, stop propagation
};
});

input.addEventListener('keyup', event => {
if (pressedKeys[event.code]) {
Expand Down
2 changes: 1 addition & 1 deletion code/x-keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ const themes = `
.dk .level4 { display: none; }
@media (prefers-color-scheme: dark) {
rect, path { stroke: #777; fill: #444; }
rect, path { stroke: #777; fill: #4d4d4d; }
.specialKey, .specialKey rect, .specialKey path { fill: #333; }
g:target rect, .press rect, g:target path, .press path { fill: #558; }
text { fill: #bbb; }
Expand Down
9 changes: 9 additions & 0 deletions www/assets/css/keebs.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
* ╰───────────────────────────────────────────────────────────────╯
**/

.keyboard [hidden] {
visibility: hidden;
}

.keyboard form {
display: flex;
justify-content: right;
Expand Down Expand Up @@ -79,6 +83,11 @@
cursor: pointer;
}

.keyboard form input:hover {
background-color: var(--bg-accent);
opacity: 1;
}

.keyboard form input:checked {
background-image: linear-gradient(180deg, var(--bg-letter), var(--bg-home));
background-color: var(--bg-normal);
Expand Down
8 changes: 0 additions & 8 deletions www/layouts/shortcodes/x-keyboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
</fieldset>
</form>

<!-- <p>
<span>powered by <a
href="https://onedeadkey.github.io/x-keyboard/">x-keyboard</a>
</span>
<small>géométrie :</small>
<select><option>ISO</option></select>
</p> -->

{{ if $name }}
{{ with .Get "data" }}
<dialog>
Expand Down
174 changes: 108 additions & 66 deletions www/static/img/bepolar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 90 additions & 63 deletions www/static/img/colemak-french-touch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
257 changes: 145 additions & 112 deletions www/static/img/erglace.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 35 additions & 35 deletions www/static/img/ergol_1dfh.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cb74782

Please sign in to comment.