JSFiddle - React, Tailwind, and code Playground
HTML
<!doctype html>
<html>
<head>
<title>Encuéntralo en 123Compra</title>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.ion.rangeslider/2.0.12/css/ion.rangeSlider.css">
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.ion.rangeslider/2.0.12/css/ion.rangeSlider.skinFlat.css">
<link rel="stylesheet" type="text/css" href="/css/algolia.css">
<!-- /CSS -->
</head>
<body>
<!-- Header -->
<header>
<!--<img src="img/123logoSmall.png"/>-->
<input id="search-input" type="text" autocomplete="off" spellcheck="false" autocorrect="off" placeholder="Búsqueda por nombre, marca, id, or descripción..."/>
<div id="search-input-icon"></div>
</header>
<!-- /Header -->
<!-- Main -->
<main>
<!-- Left Column -->
<div id="left-column">
<div id="facets"></div>
</div>
<!-- Right Column -->
<div id="right-column">
<div id="sort-by">Ordenar por:
<select dir="rtl" id="sort-by-select">
<option value="" selected>Más relevante</option>
<option value="_price_asc">Precio más bajo</option>
<option value="_price_desc">Precio más alto</option>
</select>
<span class="caret"></span>
</div>
<div id="stats"></div>
<div id="hits"></div>
<div id="pagination"></div>
</div>
</main>
<!-- /Main -->
<!-- Hit template -->
<script type="text/template" id="hit-template">
{{#hits}}
<div class="hit">
<div class="hit-image">
<img src="{{ image }}" alt="{{ name }}">
</div>
<div class="hit-content">
<h3 class="hit-price">${{ price }}</h3>
<a href="/pid/{{objectID}}"><h2 class="hit-name">{{{ _highlightResult.title.value }}}</h2></a>
<p class="hit-description">{{body}}</p>
<table style="width:70%">
<tr>
<td>Condición: {{condition}}</td>
<td>Vendedor: {{seller}}</td>
<td>Producto...
CSS
/* GENERAL
// ------------------------- */
* {
font-family: 'Helvetica Neue', Helvetica, sans-serif;
}
html {
overflow-y: scroll;
}
header, main, #no-results, footer {
width: 1000px;
margin: 0 auto;
}
main {
min-height: 360px;
}
#left-column {
float: left;
width: 23%;
}
#right-column {
width: 74%;
margin-left: 26%;
}
/* SEARCH INPUT
// ------------------------- */
header {
position: relative;
height: 80px;
margin-top: 40px;
}
header img {
position: absolute;
top: 9px;
left: 0;
float: left;
max-width: 23%;
}
#search-input {
font-size: 28px;
font-weight: 100;
width: 74%;
margin-left: 26%;
padding: 10px 0 6px;
border: none;
border-bottom: 5px solid #eee;
}
#search-input, #search-input:focus {
transition: border-color .3s ease-in;
outline: 0;
}
#search-input:focus {
border-color: #ed5565;
}
#search-input::-webkit-input-placeholder, #search-input:-moz-placeholder, #search-input:-moz-placeholder, #search-input:-ms-input-placeholder {
font-weight: 100;
color: #999;
}
#search-input-icon {
position: relative;
}
#search-input-icon:before {
position: absolute;
right: 0;
bottom: 15px;
width: 20px;
height: 20px;
content: '';
cursor: default;
background: url(../img/search_icon.png) no-repeat;
}
#search-input-icon.empty:before {
cursor: pointer;
background-image: url(../img/delete_icon.png);
}
/* HITS
// ------------------------- */
#hits {
margin: 4px 0;
padding: 10px 0;
border-top: 2px solid #eee;
}
.hit {
font-size: 0;
padding: 8px 0;
border-bottom: 1px solid #eee;
}
.hit-image {
display: inline-block;
width: 16%;
}
.hit-image img {
max-width: 100%;
max-height: 180px;
}
.hit-content {
font-size: 13px;
font-weight: 300;
display: inline-block;
width: 83%;
margin-left: 1%;
vertical-align: top;
}
.hit-content .hit-price {
font-size: 20px;
float: right;
margin-left: 20px;
color: #ed5565;
}
.hit-content .hit-price, .hit-content .hit-name {
font-weight: normal;
margin-top: 0;
}
.hit-content em {
font-style:...
JavaScript
$(document).ready(function() {
// INITIALIZATION
// ==============
// Replace with your own values
var APPLICATION_ID = 'latency';
var SEARCH_ONLY_API_KEY = '6be0576ff61c053d5f9a3225e2a90f76';
var INDEX_NAME = 'instant_search';
var PARAMS = {
hitsPerPage: 20,
maxValuesPerFacet: 8,
facets: ['type'],
disjunctiveFacets: ['brand', 'condition', 'price'],
hierarchicalFacets: [{
name: 'categories',
attributes: ['hierarchicalCategories.lvl0', 'hierarchicalCategories.lvl1' , 'hierarchicalCategories.lvl2']
}]
};
var FACETS_SLIDER = ['price'];
var FACETS_ORDER_OF_DISPLAY = ['categories', 'brand', 'condition', 'price', 'type'];
var FACETS_LABELS = {categories: 'Categoría', brand: 'Marca', condition: 'Condición', price: 'Precio', type: 'Type'};
// Client + Helper initialization
var algolia = algoliasearch(APPLICATION_ID, SEARCH_ONLY_API_KEY);
var algoliaHelper = algoliasearchHelper(algolia, INDEX_NAME, PARAMS);
// DOM BINDING
$searchInput = $('#search-input');
$searchInputIcon = $('#search-input-icon');
$main = $('main');
$sortBySelect = $('#sort-by-select');
$hits = $('#hits');
$stats = $('#stats');
$facets = $('#facets');
$pagination = $('#pagination');
// Hogan templates binding
var hitTemplate = Hogan.compile($('#hit-template').text());
var statsTemplate = Hogan.compile($('#stats-template').text());
var facetTemplate = Hogan.compile($('#facet-template').text());
var sliderTemplate = Hogan.compile($('#slider-template').text());
var paginationTemplate = Hogan.compile($('#pagination-template').text());
var noResultsTemplate = Hogan.compile($('#no-results-template').text());
// SEARCH BINDING
// ==============
// Input binding
$searchInput
.on('input propertychange', function(e) {
var query = e.currentTarget.value;
toggleIconEmptyInput(query);
algoliaHelper.setQuery(query).search();
})
.focus();
// Search errors
algoliaHelper.on('error',...