Skip to content

Instantly share code, notes, and snippets.

@mcnemesis
Created November 23, 2020 19:03
Show Gist options
  • Save mcnemesis/2ba25d9c1613a80cd3939ed04255cd63 to your computer and use it in GitHub Desktop.
Save mcnemesis/2ba25d9c1613a80cd3939ed04255cd63 to your computer and use it in GitHub Desktop.
SQUIZ Book Search
<div class="container">
<span class="hbar"></span>
<input type="text" placeholder="Search..." id="query" onkeypress="return runScript(event)" >
<div class="search"></div>
<div class="results">
<div class="rlist">
<h4 id="status">Welcome to the SQUIZ book search interface.</h4>
<ul id="list">
</ul>
<small>Designed by <a class="alink" href="https://nuchwezi.com" target="_blank">NuChwezi</a></small>
</div>
</div>
</div>
function runScript(e) {
if (e.keyCode == 13) {
var tb = document.getElementById("query");
console.log(tb.value);
document.activeElement.blur();
renderResults(tb.value);
return false;
}
}
function renderResults(q){
var list = document.getElementById("list");
while( list.firstChild ){
list.removeChild( list.firstChild );
}
$.get('https://www.googleapis.com/books/v1/volumes', {
key: "AIzaSyB79XR8NY-zYLrRxw-9CqHCZX0sx5AGYks",
q: q
}, function(data){
console.log(data);
var items = data.items;
for(s=0;s<items.length; s++){
list.innerHTML += "<li><a target=\"_blank\" href=\"" + items[s].accessInfo.webReaderLink + "\" />"+ items[s].volumeInfo.title + "</li>" ;
}
});
}
function onElementFocused(e)
{
if (e && e.target)
document.activeElement = e.target == document ? null : e.target;
}
if (document.addEventListener)
document.addEventListener("focus", onElementFocused, true);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

SQUIZ Book Search

origin:{Animated search bar } -> transform |:| potential(naeu service UI)

A Pen by JWL on CodePen.

License.

@import url('https://fonts.googleapis.com/css?family=Inconsolata:700');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
}
body {
background: #252525;
}
.container {
position: relative;
margin: auto;
top: 0;
left: -10vw;
right: 0;
bottom: 0;
width: 300px;
height: 100px;
.search {
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 80px;
height: 80px;
background: crimson;
border-radius: 50%;
transition: all 1s;
z-index: 4;
box-shadow: 0 0 25px 0 rgba(0, 0, 0, 0.4);
// box-shadow: 0 0 25px 0 crimson;
&:hover {
cursor: pointer;
}
&::before {
content: "";
position: absolute;
margin: auto;
top: 22px;
right: 0;
bottom: 0;
left: 22px;
width: 12px;
height: 2px;
background: white;
transform: rotate(45deg);
transition: all .5s;
}
&::after {
content: "";
position: absolute;
margin: auto;
top: -5px;
right: 0;
bottom: 0;
left: -5px;
width: 25px;
height: 25px;
border-radius: 50%;
border: 2px solid white;
transition: all .5s;
}
}
input {
font-family: 'Inconsolata', monospace;
position: absolute;
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 50px;
height: 50px;
outline: none;
border: none;
// border-bottom: 1px solid rgba(255, 255, 255, 0.2);
background: crimson;
color: white;
text-shadow: 0 0 10px crimson;
padding: 0 80px 0 20px;
border-radius: 30px;
box-shadow: 0 0 25px 0 crimson,
0 20px 25px 0 rgba(0, 0, 0, 0.2);
// box-shadow: inset 0 0 25px 0 rgba(0, 0, 0, 0.5);
transition: all 1s;
opacity: 0;
z-index: 5;
font-weight: bolder;
letter-spacing: 0.1em;
&:hover {
cursor: pointer;
}
&:focus {
width: 300px;
opacity: 1;
cursor: text;
}
&:focus ~ .search {
right: -250px;
background: #151515;
z-index: 6;
&::before {
top: 0;
left: 0;
width: 25px;
}
&::after {
top: 0;
left: 0;
width: 25px;
height: 2px;
border: none;
background: white;
border-radius: 0%;
transform: rotate(-45deg);
}
}
&::placeholder {
color: white;
opacity: 0.5;
font-weight: bolder;
}
}
}
/*
alter... transform:
*/
.hbar {
display: block;
background: crimson;
position: relative;
left:180px;
top:45px;
width: 25vw;
height: 2vh;
border-radius: 6px;
}
#list {
margin-top: 20px;
}
.results {
position: absolute;
margin: auto;
top: 100px;
right: 0;
bottom: 0;
left: 0;
width: 50vw;
height: 80vh;
overflow-y: auto;
background: crimson;
border-radius: 3%;
transition: all 1s;
z-index: 3;
box-shadow: 0 0 25px 0 rgba(0, 0, 0, 0.4);
background: rgba(44,45,54,.6);
color: silver;
padding: 20px;
margin: 10px;
text-align: center;
}
a.alink {
text-decoration: none;
color: gold;
}
li a {
text-decoration: none;
color: white;
font-size: 27px;
}
/* tabular lists : https://codepen.io/stratboy/pen/CxgiH */
ul{
list-style:none;
width: 100%;
}
ul li{
width: inherit;
float:left;
padding:10px;
border-bottom:1px solid #000;
border-right:1px solid #000;
}
ul li:nth-child(3n){
background-color:#888;
}
ul li:nth-child(3n+1){
clear:both;
border-left:1px solid #000;
background-color:#FF796B;
}
ul li:nth-child(-n+3){
border-top:1px solid #000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment