diff --git a/assets/css/full-screen-morphing-search.css b/assets/css/full-screen-morphing-search.css index 34e4621..03d14af 100644 --- a/assets/css/full-screen-morphing-search.css +++ b/assets/css/full-screen-morphing-search.css @@ -389,21 +389,159 @@ input[type="search"] { } } -/* Autocomplete dropdown box styles */ +/* autoComplete styles */ -.ui-autocomplete { - width: 80% !important; - overflow-wrap: break-word; - box-shadow: 2px 2px 3px #888888; - background: #fff; - z-index: 99998; +.autoComplete_wrapper { + position: relative; + display: inline-block; + width: 370px; } -.ui-menu-item { - list-style-type: none; - padding: 10px; +#autoComplete { + height: 3rem; + width: 370px; + margin: 0; + padding: 0 2rem 0 3.2rem; + box-sizing: border-box; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + font-size: 1rem; + text-overflow: ellipsis; + color: rgba(255, 122, 122, 0.3); + outline: none; + border-radius: 10rem; + border: 0; + border: 0.05rem solid rgba(255, 122, 122, 0.5); + background-image: url(./images/search.svg); + background-size: 1.4rem; + background-position: left 1.05rem top 0.8rem; + background-repeat: no-repeat; + background-origin: border-box; + background-color: #fff; + transition: all 0.4s ease; + -webkit-transition: all -webkit-transform 0.4s ease; } -.ui-menu-item:hover { - background: #f1f1f1; +#autoComplete::placeholder { + color: rgba(255, 122, 122, 0.5); + transition: all 0.3s ease; + -webkit-transition: all -webkit-transform 0.3s ease; +} + +#autoComplete:hover::placeholder { + color: rgba(255, 122, 122, 0.6); + transition: all 0.3s ease; + -webkit-transition: all -webkit-transform 0.3s ease; +} + +#autoComplete:focus::placeholder { + padding: 0.1rem 0.6rem; + font-size: 0.95rem; + color: rgba(255, 122, 122, 0.4); +} + +#autoComplete:focus::selection { + background-color: rgba(255, 122, 122, 0.15); +} + +#autoComplete::selection { + background-color: rgba(255, 122, 122, 0.15); +} + +#autoComplete:hover { + color: rgba(255, 122, 122, 0.8); + transition: all 0.3s ease; + -webkit-transition: all -webkit-transform 0.3s ease; +} + +#autoComplete:focus { + color: rgba(255, 122, 122, 1); + border: 0.06rem solid rgba(255, 122, 122, 0.8); +} + +#autoComplete_list { + position: absolute; + top: 100%; + left: 0; + right: 0; + padding: 0; + margin-top: 0.5rem; + border-radius: 0.6rem; + background-color: #fff; + box-shadow: 0 3px 6px rgba(149, 157, 165, 0.15); + border: 1px solid rgba(33, 33, 33, 0.07); + z-index: 1000; + outline: none; +} + +.autoComplete_result { + margin: 0.3rem; + padding: 0.3rem 0.5rem; + list-style: none; + text-align: left; + font-size: 1.5em; + color: #212121; + transition: all 0.1s ease-in-out; + border-radius: 0.35rem; + background-color: rgba(255, 255, 255, 1); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + transition: all 0.2s ease; +} + +.autoComplete_result::selection { + color: rgba(#ffffff, 0); + background-color: rgba(#ffffff, 0); +} + +.autoComplete_result:hover { + cursor: pointer; + background-color: rgba(255, 122, 122, 0.15); +} + +.autoComplete_highlighted { + color: rgba(255, 122, 122, 1); + font-weight: bold; +} + +.autoComplete_highlighted::selection { + color: rgba(#ffffff, 0); + background-color: rgba(#ffffff, 0); +} + +.autoComplete_selected { + cursor: pointer; + background-color: rgba(255, 122, 122, 0.15); +} + +@media only screen and (max-width: 600px) { + .autoComplete_wrapper { + width: 320px; + } + + #autoComplete { + width: 18rem; + background-size: 1.6rem; + background-position: left 1.1rem top 0.75rem; + } + + #autoComplete_list { + margin: 10px; + } +} + +@media screen and (-webkit-min-device-pixel-ratio: 0) { + #autoComplete { + border-width: 1px; + } +} + +@-moz-document url-prefix() { + #autoComplete { + background-size: 1.2rem; + background-origin: border-box; + border-width: 1px; + background-position: left 1.1rem top 0.8rem; + } } diff --git a/assets/js/autoComplete.min.js b/assets/js/autoComplete.min.js new file mode 100644 index 0000000..6614fc2 --- /dev/null +++ b/assets/js/autoComplete.min.js @@ -0,0 +1 @@ +var a,b;a=this,b=function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,r=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}function u(e,t){for(var n=document.getElementsByClassName(e.resultsList.className),i=0;i=e.length&&(o=0),o<0&&(o=e.length-1),e[o].setAttribute("aria-selected","true"),e[o].classList.add("autoComplete_selected")},a=n.resultsList.navigation||function(e){var t=document.getElementById(n.resultsList.idName);if(!t)return n.inputField.removeEventListener("keydown",a);t=t.getElementsByTagName(n.resultItem.element),27===e.keyCode?(n.inputField.value="",u(n)):40===e.keyCode||9===e.keyCode?i(e,t,!0,n):38===e.keyCode||9===e.keyCode?i(e,t,!1,n):13===e.keyCode&&(e.preventDefault(),-1'.concat(a,""):a,o++),r.push(a)}if(o===e.length)return r.join("")}else if(i.includes(e))return e=new RegExp("".concat(e),"i").exec(t),n.highlight?t.replace(e,''.concat(e,"")):t}(s,t,o))&&e?a.push({key:e,index:n,match:t,value:i}):t&&!e&&a.push({index:n,match:t,value:i}))}var i=o.data.store[n];if(o.data.key){var t,r=l(o.data.key);try{for(r.s();!(t=r.n()).done;)e(t.value)}catch(e){r.e(e)}finally{r.f()}}else e()},t=0;t=r.threshold&&o.replace(/ /g,"").length)?a.dataStore().then(function(e){try{return u(a),a.start(n,i),s.call(a)}catch(e){return t(e)}},t):(u(a),s.call(a));function s(){return e()}})}},{key:"init",value:function(){var e,n,i,r,t=this;this.inputField="string"==typeof this.selector?document.querySelector(this.selector):this.selector(),(e=this).inputField.setAttribute("type","text"),e.inputField.setAttribute("role","combobox"),e.inputField.setAttribute("aria-haspopup",!0),e.inputField.setAttribute("aria-expanded",!1),e.inputField.setAttribute("aria-controls",e.resultsList.idName),e.inputField.setAttribute("aria-autocomplete","both"),this.placeHolder&&this.inputField.setAttribute("placeholder",this.placeHolder),this.hook=(n=function(){t.compose()},i=this.debounce,function(){var e=this,t=arguments;clearTimeout(r),r=setTimeout(function(){return n.apply(e,t)},i)}),this.trigger.event.forEach(function(e){t.inputField.removeEventListener(e,t.hook),t.inputField.addEventListener(e,t.hook)}),d(this.inputField,null,"init")}},{key:"preInit",value:function(){var o=this,s=document;new MutationObserver(function(e,t){var n,i=s.querySelector(o.selector),r=l(e);try{for(r.s();!(n=r.n()).done;){n.value;i&&(t.disconnect(),d(i,null,"connect"),o.init())}}catch(e){r.e(e)}finally{r.f()}}).observe(s,{childList:!0,subtree:!0})}},{key:"unInit",value:function(){this.inputField.removeEventListener("input",this.hook),d(this.inputField,null,"unInit")}}])&&e(n.prototype,i),h&&e(n,h),T},"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):(a="undefined"!=typeof globalThis?globalThis:a||self).autoComplete=b(); diff --git a/class-full-screen-morphing-search.php b/class-full-screen-morphing-search.php index b228c89..5050ffa 100644 --- a/class-full-screen-morphing-search.php +++ b/class-full-screen-morphing-search.php @@ -259,16 +259,18 @@ class Full_Screen_Morphing_Search { ?>