feat: Add basic keyboard navigation
This commit is contained in:
parent
cc6e47372e
commit
1111bf72d6
7 changed files with 50 additions and 11 deletions
2
public/css/app.css
vendored
2
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
2
public/js/app.js
vendored
2
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
4
public/mix-manifest.json
generated
4
public/mix-manifest.json
generated
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"/css/app.css": "/css/app.css?id=fb9e13c65ffee8ba7340",
|
||||
"/js/app.js": "/js/app.js?id=6ae33b54881f793f30af"
|
||||
"/css/app.css": "/css/app.css?id=52588253d9a6d5c5e6a1",
|
||||
"/js/app.js": "/js/app.js?id=a6c1d3a18516685e7b15"
|
||||
}
|
||||
|
|
35
resources/assets/js/keyBindings.js
vendored
Normal file
35
resources/assets/js/keyBindings.js
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
const focusSearch = event => {
|
||||
const searchInput = document.querySelector('input[name="q"]');
|
||||
if (searchInput) {
|
||||
event.preventDefault();
|
||||
searchInput.focus();
|
||||
}
|
||||
};
|
||||
|
||||
const openFirstNonHiddenItem = event => {
|
||||
if (event.target !== document.querySelector('input[name="q"]')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const item = document.querySelector('#sortable section.item-container:not([style="display: none;"]) a');
|
||||
|
||||
if ('href' in item) {
|
||||
event.preventDefault();
|
||||
window.open(item.href);
|
||||
}
|
||||
};
|
||||
|
||||
const KEY_BINDINGS = {
|
||||
'/': focusSearch,
|
||||
'Enter': openFirstNonHiddenItem
|
||||
};
|
||||
|
||||
document.addEventListener('keydown', function (event) {
|
||||
try {
|
||||
if (event.key in KEY_BINDINGS) {
|
||||
KEY_BINDINGS[event.key](event);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
});
|
|
@ -470,6 +470,9 @@ body {
|
|||
z-index: 1;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.link:focus {
|
||||
background-color: rgba(10,10,10,.4);
|
||||
}
|
||||
.title {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
|
|
@ -98,16 +98,16 @@
|
|||
|
||||
|
||||
@if(Route::is('dash') || Route::is('tags.show'))
|
||||
<a id="config-button" class="config" href=""><i class="fas fa-exchange"></i></a>
|
||||
<a id="config-button" class="config" href="" title="Configuration"><i class="fas fa-exchange"></i></a>
|
||||
@endif
|
||||
|
||||
<a id="dash" class="config" href="{{ route('dash', []) }}"><i class="fas fa-th"></i></a>
|
||||
<a id="dash" class="config" href="{{ route('dash', []) }}" title="Dashboard"><i class="fas fa-th"></i></a>
|
||||
@if($current_user->id === 1)
|
||||
<a id="users" class="config" href="{{ route('users.index', []) }}"><i class="fas fa-user"></i></a>
|
||||
<a id="users" class="config" href="{{ route('users.index', []) }}" title="Users"><i class="fas fa-user"></i></a>
|
||||
@endif
|
||||
<a id="items" class="config" href="{{ route('items.index', []) }}"><i class="fas fa-list"></i></a>
|
||||
<a id="folder" class="config" href="{{ route('tags.index', []) }}"><i class="fas fa-tag"></i></a>
|
||||
<a id="settings" class="config" href="{{ route('settings.index', []) }}"><i class="fas fa-cogs"></i></a>
|
||||
<a id="items" class="config" href="{{ route('items.index', []) }}" title="Items"><i class="fas fa-list"></i></a>
|
||||
<a id="folder" class="config" href="{{ route('tags.index', []) }}" title="Tags"><i class="fas fa-tag"></i></a>
|
||||
<a id="settings" class="config" href="{{ route('settings.index', []) }}" title="Settings"><i class="fas fa-cogs"></i></a>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
|
3
webpack.mix.js
vendored
3
webpack.mix.js
vendored
|
@ -14,7 +14,8 @@ let mix = require('laravel-mix');
|
|||
mix.babel([
|
||||
//'resources/assets/js/jquery-ui.min.js',
|
||||
'resources/assets/js/huebee.js',
|
||||
'resources/assets/js/app.js'
|
||||
'resources/assets/js/app.js',
|
||||
'resources/assets/js/keyBindings.js',
|
||||
], 'public/js/app.js')
|
||||
.sass('resources/assets/sass/app.scss', 'public/css').options({
|
||||
processCssUrls: false
|
||||
|
|
Loading…
Reference in a new issue