From 347d972096c07c97ffb8cfbd9e334e6211e1e3bb Mon Sep 17 00:00:00 2001 From: fuentesloic Date: Mon, 14 Aug 2017 13:47:04 -0400 Subject: [PATCH 1/6] move search bar into the header --- static/css/search-bar.css | 25 +++++++++++++++++++++++++ static/css/search.css | 33 --------------------------------- static/js/search.js | 16 ++++++++++++++++ templates/layout.html | 5 +++++ templates/search/list.html | 13 ++++++------- 5 files changed, 52 insertions(+), 40 deletions(-) create mode 100644 static/css/search-bar.css create mode 100644 static/js/search.js diff --git a/static/css/search-bar.css b/static/css/search-bar.css new file mode 100644 index 00000000..f7508906 --- /dev/null +++ b/static/css/search-bar.css @@ -0,0 +1,25 @@ +#search::before { + font-family: FontAwesome; + content: '\f002'; + font-size: 1.5rem; + position: relative; + left: 2.5rem; + color: #646464; + cursor: pointer; +} +#search > input:first-of-type { + padding: .75rem .75rem .75rem 3rem; + background: rgba(50, 50, 50, 0.2); + border: none; + border-radius: 1rem 0 0 1rem; +} +#search > input:last-of-type { + position: relative; + padding: .75rem; + left: -0.8rem; + border: none; + background-color: #3ba777; + color: #fafafa; + cursor: pointer; + border-radius: 0 1rem 1rem 0; +} diff --git a/static/css/search.css b/static/css/search.css index b4d84547..0f1da087 100644 --- a/static/css/search.css +++ b/static/css/search.css @@ -12,39 +12,6 @@ main > header { border-radius: 0.75rem; } -form { - margin: 4.5rem auto; -} -form::before { - font-family: FontAwesome; - content: '\f002'; - font-size: 2.5rem; - position: relative; - left: 4rem; - color: #646464; - cursor: pointer; -} -input { - font-size: 2rem; -} -input:first-of-type { - padding: 1rem 1.5rem 1rem 5rem; - background: rgba(50, 50, 50, 0.2); - border: 0 solid #dbdbdb; - width: 40%; - border-radius: 1rem 0 0 1rem; -} -input:last-of-type { - position: relative; - padding: 0.8rem 1.5rem; - left: -0.8rem; - border: 0.2rem solid #3ba777; - background-color: #3ba777; - color: #fafafa; - cursor: pointer; - border-radius: 0 1rem 1rem 0; -} - main > section { display: flex; justify-content: space-around; diff --git a/static/js/search.js b/static/js/search.js new file mode 100644 index 00000000..d46f5cf9 --- /dev/null +++ b/static/js/search.js @@ -0,0 +1,16 @@ +url = window.location.href + +searchField = url.split('?q=') + +if (searchField[1] === '') { + alert('no search detect', 'Fill the search field please', 2000) +} else { + search = searchField[1].replace('+', ' ') + + form = document.querySelectorAll('#search input') + form.forEach( input => { + if (input.placeholder) { + input.value = search + } + }) +} diff --git a/templates/layout.html b/templates/layout.html index 4d3d9d01..b598ad95 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -11,10 +11,15 @@ + {% block extra_css %}{% endblock %}

Neomad

+