Skip to content

Commit

Permalink
🎉 Add some action buttons to open URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Schneegans committed Jun 15, 2023
1 parent d3fcc00 commit 0b1d6b6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ export class KandoApp {
ipcMain.on('move-pointer', (event, dist) => {
this.backend.movePointer(Math.floor(dist.x), Math.floor(dist.y));
});

ipcMain.on('open-uri', (event, uri) => {
this.window.hide();
shell.openExternal(uri);
});
}

// This is called when the user presses the shortcut. It will get the current
Expand Down
24 changes: 19 additions & 5 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,26 @@ <h2>Welcome to Kando.</h2>
</li>
</ul>

<div id="dev-tools-button" class="editor-circle-button">
<i class="material-icons-round">code</i> Show Developer Tools
</div>
<div id="editor-buttons-grid">
<div
id="dev-tools-button"
class="editor-circle-button"
style="grid-column-start: 1; grid-column-end: 3"
>
<i class="material-icons-round">code</i> Show Developer Tools
</div>

<div id="shortcut-button" class="editor-circle-button">
<i class="material-icons-round">keyboard</i> Fake Shortcut
</div>

<div id="url-button" class="editor-circle-button">
<i class="material-icons-round">public</i> Open URL
</div>

<div id="shortcut-button" class="editor-circle-button">
<i class="material-icons-round">keyboard</i> Simulate a Shortcut
<div id="uri-button" class="editor-circle-button">
<i class="material-icons-round">folder_open</i> Open Folder
</div>
</div>
</div>
</body>
Expand Down
8 changes: 8 additions & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ body.hidden #show-editor-button {
opacity: 0;
}

#editor-buttons-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-gap: 5px;
margin-top: 10px;
}

.editor-circle-button {
min-width: 40px;
height: 40px;
Expand All @@ -83,6 +90,7 @@ body.hidden #show-editor-button {
border-radius: 20px;
transition: all 150ms ease;
margin-bottom: 5px;
font-weight: bold;

// Center text.
display: flex;
Expand Down
3 changes: 3 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ contextBridge.exposeInMainWorld('api', {
movePointer: function (dist: { x: number; y: number }) {
ipcRenderer.send('move-pointer', dist);
},
openURI: function (uri: string) {
ipcRenderer.send('open-uri', uri);
},
itemSelected: function () {
ipcRenderer.send('item-selected');
},
Expand Down
1 change: 1 addition & 0 deletions src/renderer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IElectronAPI {
showDevTools: () => void;
simulateShortcut: () => void;
movePointer: (dist: { x: number; y: number }) => void;
openURI: (uri: string) => void;
itemSelected: () => void;
log: (message: string) => void;
showMenu: (func: (pos: { x: number; y: number }) => void) => void;
Expand Down
8 changes: 8 additions & 0 deletions src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ document.querySelector('#shortcut-button').addEventListener('click', () => {
window.api.simulateShortcut();
});

document.querySelector('#url-button').addEventListener('click', () => {
window.api.openURI('https://github.com/kando-menu/kando');
});

document.querySelector('#uri-button').addEventListener('click', () => {
window.api.openURI('file:///');
});

document.addEventListener('keyup', (ev) => {
if (ev.key === 'Escape') {
document.querySelector('body').classList.add('hidden');
Expand Down

0 comments on commit 0b1d6b6

Please sign in to comment.