forked from nrkno/sorensen
-
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
Showing
8 changed files
with
1,146 additions
and
313 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"javascript.suggest.autoImports": false, | ||
"javascript.suggest.includeCompletionsForImportStatements": false, | ||
"javascript.suggest.completeFunctionCalls": false, | ||
"javascript.suggest.names": false, | ||
"javascript.suggest.enabled": false | ||
} |
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,11 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe('Basic hotkey', () => { | ||
it('Activates when key pressed', () => { | ||
cy.visit('http://localhost:9000/') | ||
cy.window().then((win) => { | ||
//@ts-ignore | ||
win.bindCombo('KeyA', {}) | ||
}) | ||
}) | ||
}) |
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
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 |
---|---|---|
@@ -1,2 +1,54 @@ | ||
<!DOCTYPE html> | ||
<script src="simonsson.js"></script> | ||
<style> | ||
#result .binding { | ||
display: flex; | ||
} | ||
#result .binding .combo, | ||
#result .binding .hit { | ||
flex: 1 1; | ||
} | ||
#result .binding .hit.hot { | ||
background-color: black; | ||
font-weight: bold; | ||
color: white; | ||
} | ||
</style> | ||
<template id="binding"> | ||
<div class="binding"> | ||
<div class="combo"> | ||
<!-- Key combination --> | ||
</div> | ||
<div class="hit"> | ||
<!-- Was activated? --> | ||
</div> | ||
</div> | ||
</template> | ||
<p id="mounted">Not initialized</p> | ||
<div id="result"></div> | ||
<script> | ||
const bindings = [] | ||
Simonsson.init().then(() => { | ||
document.getElementById('mounted').textContent = 'Simonsson initialized' | ||
}) | ||
|
||
const bindCombo = (combo, options, clb) => { | ||
const template = document.getElementById('binding') | ||
const bindRow = template.content.cloneNode(true) | ||
bindRow.querySelector('.combo').textContent = combo | ||
bindRow.querySelector('.hit').textContent = 'No' | ||
document.getElementById('result').appendChild(bindRow) | ||
const inserted = document.getElementById('result').lastElementChild | ||
Simonsson.bind( | ||
combo, | ||
() => { | ||
const hitCell = inserted.querySelector('.hit') | ||
hitCell.textContent = 'Yes' | ||
hitCell.classList.add('hot') | ||
if (typeof clb === 'function') clb() | ||
}, | ||
options | ||
) | ||
} | ||
window.bindCombo = bindCombo | ||
</script> |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig.build.json", | ||
"include": ["src/**/*.ts"], | ||
"include": ["src/**/*.ts", "cypress/**/*.ts"], | ||
"exclude": ["node_modules/**"], | ||
"compilerOptions": { | ||
"sourceMap": true, | ||
"module": "UMD", | ||
"lib": ["dom", "es6", "es2016"], | ||
"types": [] | ||
"types": ["cypress"] | ||
} | ||
} |
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
Oops, something went wrong.