style modifications / escape closes the sidebar
This commit is contained in:
+47
-36
@@ -23,7 +23,7 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
color: #111;
|
color: #222;
|
||||||
font-family: 'Lato', sans-serif;
|
font-family: 'Lato', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,14 +40,11 @@
|
|||||||
letter-spacing: 6px;
|
letter-spacing: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
form {
|
|
||||||
margin-top: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
input {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
max-width: 310px;
|
max-width: 310px;
|
||||||
padding: 10px 15px;
|
margin-top: 20px;
|
||||||
|
padding: 12px;
|
||||||
background-color: #222;
|
background-color: #222;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@@ -64,44 +61,55 @@
|
|||||||
|
|
||||||
aside {
|
aside {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: -180px;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 180px;
|
max-width: 190px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 15px 25px;
|
padding: 15px 0 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.4);
|
box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.2);
|
||||||
transition: transform 700ms;
|
transition: 700ms;
|
||||||
|
transform: translateX(-190px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
aside[data-toggled='true'] {
|
aside[data-toggled='true'] {
|
||||||
transform: translateX(180px);
|
transform: translateX(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: 0 0 15px;
|
margin: 0 25px 15px;
|
||||||
line-height: 1rem;
|
line-height: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
margin: 0;
|
margin: 0 0 15px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
line-height: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-family: 'Courier New', monospace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #000;
|
display: block;
|
||||||
font-size: 0.8rem;
|
padding: 0 25px;
|
||||||
|
color: #222;
|
||||||
|
line-height: 1.7rem;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover span:last-of-type {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
span:first-of-type {
|
||||||
|
font-family: 'Courier New', monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
span:last-of-type {
|
||||||
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -146,36 +154,35 @@
|
|||||||
|
|
||||||
opts.commands.forEach(function(command) {
|
opts.commands.forEach(function(command) {
|
||||||
var li = document.createElement('li');
|
var li = document.createElement('li');
|
||||||
var key = document.createElement('span');
|
|
||||||
var link = document.createElement('a');
|
var link = document.createElement('a');
|
||||||
|
var key = document.createElement('span');
|
||||||
|
var name = document.createElement('span');
|
||||||
|
|
||||||
key.innerHTML = command.key + ': ';
|
key.innerHTML = command.key + ': ';
|
||||||
|
name.innerHTML = command.name;
|
||||||
|
|
||||||
link.href = command.url;
|
link.href = command.url;
|
||||||
link.innerHTML = command.name;
|
link.appendChild(key);
|
||||||
|
link.appendChild(name);
|
||||||
|
|
||||||
li.appendChild(key);
|
|
||||||
li.appendChild(link);
|
li.appendChild(link);
|
||||||
|
|
||||||
searchHelp.appendChild(li);
|
searchHelp.appendChild(li);
|
||||||
});
|
});
|
||||||
|
|
||||||
searchForm.addEventListener('keyup', function() {
|
|
||||||
var q = searchInput.value;
|
|
||||||
|
|
||||||
if (q === '?') {
|
|
||||||
sidebar.setAttribute('data-toggled', true);
|
|
||||||
searchInput.value = '';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
searchForm.addEventListener('submit', function(event) {
|
searchForm.addEventListener('submit', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (searchInput.value === '') return false;
|
var q = searchInput.value
|
||||||
|
|
||||||
|
if (q === '' || q === '?') {
|
||||||
|
sidebar.setAttribute('data-toggled', true);
|
||||||
|
searchInput.value = '';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var redirect = opts.defaultCommand + encodeURIComponent(q);
|
var redirect = opts.defaultCommand + encodeURIComponent(q);
|
||||||
var q = searchInput.value.split(opts.delimiter);
|
q = q.split(opts.delimiter);
|
||||||
|
|
||||||
opts.commands.forEach(function(command) {
|
opts.commands.forEach(function(command) {
|
||||||
if (q[0] === command.key) {
|
if (q[0] === command.key) {
|
||||||
@@ -191,8 +198,12 @@
|
|||||||
|
|
||||||
window.location.href = redirect;
|
window.location.href = redirect;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
document.addEventListener('keydown', function(event) {
|
||||||
|
if (event.keyCode === 27) sidebar.removeAttribute('data-toggled');
|
||||||
|
});
|
||||||
})({
|
})({
|
||||||
delimiter: ' ',
|
delimiter: ':',
|
||||||
defaultCommand: 'https://www.google.com/search?q=',
|
defaultCommand: 'https://www.google.com/search?q=',
|
||||||
commands: [
|
commands: [
|
||||||
{ key: 'a', name: 'Amazon', url: 'https://www.amazon.com', search: '/s/?field-keywords=' },
|
{ key: 'a', name: 'Amazon', url: 'https://www.amazon.com', search: '/s/?field-keywords=' },
|
||||||
|
|||||||
Reference in New Issue
Block a user