Skip to content

Commit

Permalink
Import demo
Browse files Browse the repository at this point in the history
  • Loading branch information
pespantelis committed May 20, 2016
1 parent c48abb8 commit 639531c
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 0 deletions.
142 changes: 142 additions & 0 deletions demo/Typeahead.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<template>
<div class="Typeahead">
<i class="fa fa-spinner fa-spin" v-if="loading"></i>
<template v-else>
<i class="fa fa-search" v-show="isEmpty"></i>
<i class="fa fa-times" v-show="isDirty" @click="reset"></i>
</template>

<input type="text"
class="Typeahead__input"
placeholder="Search twitter user"
autocomplete="off"
v-model="query"
@keydown.down="down"
@keydown.up="up"
@keydown.enter="hit"
@keydown.esc="reset"
@blur="reset"
@input="update"/>

<ul v-show="hasItems">
<li v-for="item in items" :class="activeClass($index)" @mousedown="hit" @mousemove="setActive($index)">
<span class="name" v-text="item.name"></span>
<span class="screen-name" v-text="item.screen_name"></span>
</li>
</ul>
</div>
</template>



<script>
import VueTypeahead from '../src/main'
export default {
extends: VueTypeahead,
data () {
return {
limit: 5,
src: 'https://typeahead-js-twitter-api-proxy.herokuapp.com/demo/search'
}
},
methods: {
onHit (item) {
window.location.href = 'http://twitter.com/' + item.screen_name
}
}
}
</script>



<style>
.Typeahead {
position: relative;
}
.Typeahead__input {
width: 100%;
font-size: 14px;
color: #2c3e50;
line-height: 1.42857143;
box-shadow: inset 0 1px 4px rgba(0,0,0,.4);
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
font-weight: 300;
padding: 12px 26px;
border: none;
border-radius: 22px;
letter-spacing: 1px;
box-sizing: border-box;
}
.Typeahead__input:focus {
border-color: #4fc08d;
outline: 0;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px #4fc08d;
}
.fa-times {
cursor: pointer;
}
i {
float: right;
position: relative;
top: 30px;
right: 29px;
opacity: 0.4;
}
ul {
position: absolute;
padding: 0;
margin-top: 8px;
min-width: 100%;
background-color: #fff;
list-style: none;
border-radius: 4px;
box-shadow: 0 0 10px rgba(0,0,0, 0.25);
z-index: 1000;
}
li {
padding: 10px 16px;
border-bottom: 1px solid #ccc;
cursor: pointer;
}
li:first-child {
border-radius: 4px 4px 0 0;
}
li:last-child {
border-radius: 0 0 4px 4px;
border-bottom: 0;
}
span {
display: block;
color: #2c3e50;
}
.active {
background-color: #3aa373;
}
.active span {
color: white;
}
.name {
font-weight: 700;
font-size: 18px;
}
.screen-name {
font-style: italic;
}
</style>
Binary file added demo/assets/favicon.ico
Binary file not shown.
63 changes: 63 additions & 0 deletions demo/assets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
body {
margin: 0;
padding: 0 20px;
font-family: 'Source Sans Pro', 'Helvetica Neue', sans-serif;
border-top: 2px solid #4fc08d;
}

h1, h4 {
cursor: default;
}

a {
text-decoration: none;
}

h1 {
font-family: 'Dosis', 'Source Sans Pro', 'Helvetica Neue', sans-serif;
font-weight: 300;
font-size: 4em;
color: #2c3e50;
}

h4, a {
font-weight: 400;
font-size: 15px;
color: #7f8c8d;
}

.container {
width: 100%;
max-width: 600px;
margin: 0 auto;
text-align: center;
}

.button {
display: inline-block;
width: 180px;
margin: 0.5em;
padding: 12px 14px;
background-color: #4fc08d;
font-weight: 700;
color: #fff;
border-bottom: 2px solid #3aa373;
border-radius: 4px;
-webkit-transition: all 0.15s ease;
transition: all 0.15s ease;
}

.button:hover {
background-color: #5dc596;
-webkit-transform: translate(0, -2px);
-ms-transform: translate(0, -2px);
transform: translate(0, -2px);
}

#social {
margin: 2em 0 3em;
}

#social iframe {
margin: 0 4px;
}
29 changes: 29 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Typeahead | Vue.js</title>
<meta name="description" content="Typeahead component for Vue.js.">
<link rel="icon" href="assets/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400|Dosis:300">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<div class="container">
<h1>Typeahead</h1>
<h4>Vue.js component</h4>
<a href="https://github.com/pespantelis/vue-typeahead" class="button">Source on GitHub</a>

<div id="social">
<a href="https://twitter.com/share" class="twitter-share-button" data-text="VueTypeahead - A @vuejs component" data-via="pespantelis">Tweet</a>
<iframe src="https://ghbtns.com/github-btn.html?user=pespantelis&amp;repo=vue-typeahead&amp;type=star&amp;count=true" frameborder="0" scrolling="0" width="84px" height="20px"></iframe>
</div>

<typeahead></typeahead>
</div>

<script src="build/build.js"></script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
</body>
</html>
12 changes: 12 additions & 0 deletions demo/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Vue from 'vue'
import VueResource from 'vue-resource'
import Typeahead from './Typeahead.vue'

Vue.use(VueResource)

new Vue({
el: 'body',
components: {
Typeahead
}
})

0 comments on commit 639531c

Please sign in to comment.