Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit c5cfa07

Browse files
author
vvo
committed
feat(style): inline default style within the JS library
This commit moves the default styling created by @LukyVj inside the places.js library. It also uses em units so that the height, margins, borders, shadows will all be computed given the initial font-size. I removed any very demo specific styling and moved it to the _inputs.scss file. We may need to tune again of course this default styling but here is a good start.
1 parent 6b08761 commit c5cfa07

File tree

14 files changed

+143
-133
lines changed

14 files changed

+143
-133
lines changed

.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "algolia"
2+
"extends": "algolia",
3+
"rules": {
4+
"func-style": [2, "declaration", {"allowArrowFunctions": true}]
5+
}
36
}

docs/source/index.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ title: Algolia Places
4141
%div.fl-right
4242
-#%img{src: "images/svg/places-illustration.svg", class: "hero-illustration"}
4343
<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="303" height="230" viewBox="0 0 323 230"> <title>Geosearch</title> <defs> <filter x="-50%" y="-50%" width="200%" height="200%" filterUnits="objectBoundingBox" id="b"> <feOffset dy="6" in="SourceAlpha" result="shadowOffsetOuter1"/> <feGaussianBlur stdDeviation="6" in="shadowOffsetOuter1" result="shadowBlurOuter1"/> <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.35 0" in="shadowBlurOuter1" result="shadowMatrixOuter1"/> <feOffset dy="9" in="SourceAlpha" result="shadowOffsetOuter2"/> <feGaussianBlur stdDeviation="13.5" in="shadowOffsetOuter2" result="shadowBlurOuter2"/> <feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.14 0" in="shadowBlurOuter2" result="shadowMatrixOuter2"/> <feMerge> <feMergeNode in="shadowMatrixOuter1"/> <feMergeNode in="shadowMatrixOuter2"/> <feMergeNode in="SourceGraphic"/> </feMerge> </filter> <path id="a" d="M130.62 1.387c-2.643-1.54-6.92-1.54-9.547 0L2.163 71.102c-2.63 1.542-2.614 4.02.038 5.536l118.834 67.927c2.652 1.515 6.96 1.516 9.605.01l119.436-67.948c2.653-1.51 2.672-3.978.02-5.525L130.618 1.387z"/> </defs> <g transform="translate(24.132 2.347)" fill="none" fill-rule="evenodd"> <g transform="translate(1 46)"> <mask id="c" fill="#fff"> <use xlink:href="#a"/> </mask> <use stroke="#2897C5" stroke-width="4.5" fill="#FFF" filter="url(#b)" xlink:href="#a"/> <g mask="url(#c)" stroke="#2897C5" stroke-opacity=".33" stroke-width="4.147"> <path d="M29.126 91.633l26.547 14.52 6.216-14.52H29.125zM87.428 22.49L.448 72.965l6.214 4.84H67.76L87.428 22.49zM86.644 65.36l-15.855 50.9 49.7 28.772c5.993-27.148 27.824-62.706 42.803-79.673h-76.65zM178.208 50.913c5.99-4.743 11.752-8.325 16.84-10.454l-45.564-28.266h-44.17L91.5 50.914h86.708zM179.167 115.413L161.57 92.25c-8.02 11.407-17.772 31.234-21.75 46.325M215.144 49.456c-11.523 4.846-38.12 21.31-46.328 30.17l24.293 27.218 63.78-33.88-41.746-23.508z"/> </g> </g> <ellipse fill-opacity=".6" fill="#A1C2D0" cx="124.745" cy="122.421" rx="29.979" ry="11.063" id="ellipse"/> <g stroke="#8962B2" id="pin"> <path d="M157.39 34.315c0 18.546-33.825 83.958-33.825 83.958S89.74 52.86 89.74 34.315C89.74 15.768 104.885.73 123.565.73c18.68 0 33.825 15.038 33.825 33.585z" stroke-width="5.53" fill="#E6D2FC"/> <path d="M123.565 49.13c-8.008 0-14.496-6.498-14.496-14.52 0-8.017 6.487-14.52 14.495-14.52s14.496 6.503 14.496 14.52c0 8.022-6.487 14.52-14.495 14.52z" stroke-width="2.765" fill="#FFF"/> </g> </g> </svg>
44-
%input{type: "text", id: "landing-demo", class: "hero-searchbar", placeholder: "Search a country, city or address…"}
44+
%input{type: "text", id: "landing-demo", class: "hero-searchbar", autofocus: true, placeholder: "Search a country, city or address…"}
4545
4646
%section
4747
.container

docs/source/stylesheets/components/_dropdown.scss

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
input {
22
outline: none;
33
}
4-
.algolia-autocomplete {
5-
width: 100%;
6-
position: relative;
4+
5+
.algolia-places {
76
top: 50px;
7+
font-family: 'Open Sans', helvetica Neue;
88

99
&:before {
1010
content:'Try me!';
@@ -28,48 +28,12 @@ input {
2828
}
2929
}
3030
}
31-
.algolia-autocomplete .aa-input, .algolia-autocomplete .aa-hint {
32-
width: 100%;
33-
}
34-
.algolia-autocomplete .aa-hint {
35-
}
36-
.algolia-autocomplete .aa-dropdown-menu {
37-
width: 100%;
38-
background: #fff;
39-
}
40-
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion {
41-
cursor: pointer;
42-
color: #000;
43-
}
44-
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor {
45-
background-color: #B2D7FF;
46-
}
47-
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion em {
48-
font-weight: bold;
49-
font-style: normal;
31+
32+
.algolia-places .aa-suggestion {
33+
color: #262626;
5034
}
51-
.hero-searchbar {
52-
max-width: 956px;
53-
display: block;
54-
color: #8F94AD;
55-
width: 100%;
56-
height: 56px;
57-
background-color: #fff;
58-
border-radius: 4px;
59-
border: 0;
60-
padding: 6px 24px 6px 16px;
61-
background: {
62-
image: url($icon-search);
63-
repeat: no-repeat;
64-
position: center right 15px;
65-
}
66-
-webkit-transition: .2s;
67-
transition: .2s;
68-
box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1);
69-
border: solid 1px rgba(255, 255, 255, 0.5);
70-
@include placeholder {
71-
font-size: 16px;
72-
font-family: 'Open Sans', Helvetica Neue, helvetica, sans-serif;
73-
}
7435

36+
.hero-searchbar {
37+
color: #8f94ad;
38+
font-family: "Raleway", Helvetica Neue, helvetica;
7539
}

docs/source/stylesheets/site.css.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
'components/buttons',
1414
'components/inputs',
1515
'components/fonts',
16-
'components/dropdown',
1716
'components/sidebar',
1817
'components/documentation';
1918

docs/source/stylesheets/vendors/_base.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,3 @@ p a {
3737
color: #21A4D7;
3838
text-decoration: none;
3939
}
40-
41-
42-
43-

docs/source/stylesheets/vendors/_mixins.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
}
88
}
99

10-
11-
1210
@mixin big-min-mq {
1311
@media (min-width: $bp-big){
1412
@content

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"babel-preset-stage-2": "^6.5.0",
3434
"babel-register": "^6.7.2",
3535
"conventional-changelog-cli": "^1.1.1",
36+
"css-loader": "^0.23.1",
3637
"doctoc": "^1.0.0",
3738
"eslint": "^1.6.0",
3839
"eslint-config-airbnb": "^0.1.0",
@@ -42,9 +43,12 @@
4243
"json": "^9.0.3",
4344
"mocha": "^2.4.5",
4445
"mversion": "^1.10.1",
46+
"node-sass": "^3.4.2",
4547
"pretty-bytes-cli": "^1.0.0",
4648
"raw-loader": "^0.5.1",
49+
"sass-loader": "^3.2.0",
4750
"semver": "^5.1.0",
51+
"style-loader": "^0.13.1",
4852
"uglify-js": "^2.6.1",
4953
"webpack": "^1.12.2"
5054
},

src/createHitFormatter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function createHitFormatter({formatAutocompleteSuggestion, format
1212

1313
// this is the value to put inside the input.value
1414
// autocomplete.js automatically takes hit.value as the underlying
15-
// input value when a suggestion is validated
15+
// input value when a suggestion is validated with enter or selected with the mouse
1616
formatted.value = formatInputValue({
1717
...formatted,
1818
name: hit.locale_names.default[0]

src/formatAutocompleteSuggestion.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-unused-vars: 0 */
21
// this ^^ line can be removed, just so travis test works
32
import icons from './icons.js';
43

0 commit comments

Comments
 (0)