Add test data for LocationSearchBox
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Textbox from '$lib/components/Textbox.svelte';
|
import Textbox from '$lib/components/ui/Textbox.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
interface LocationRecord {
|
interface LocationRecord {
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function search(query: string) {
|
function search(query: string) {
|
||||||
if (query.length < 2) {
|
if (query.length < 3) {
|
||||||
results = [];
|
results = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
showResults = false;
|
showResults = false;
|
||||||
selectedIndex = -1;
|
selectedIndex = -1;
|
||||||
|
|
||||||
// emit event later if needed
|
console.log("Selected Location: ", JSON.stringify(loc))
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKey(e: KeyboardEvent) {
|
function handleKey(e: KeyboardEvent) {
|
||||||
@@ -80,9 +80,10 @@
|
|||||||
<div class="location-search">
|
<div class="location-search">
|
||||||
<Textbox
|
<Textbox
|
||||||
bind:value
|
bind:value
|
||||||
placeholder="Search for a station or TIPLOC"
|
placeholder="Enter Location"
|
||||||
oninput={() => showResults = true}
|
oninput={() => showResults = true}
|
||||||
onkeydown={handleKey}
|
onkeydown={handleKey}
|
||||||
|
capital
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if showResults && results.length}
|
{#if showResults && results.length}
|
||||||
@@ -101,4 +102,11 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.suggestions {
|
||||||
|
background-color: var(--color-title);
|
||||||
|
color: var(--color-bg-dark);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Button from '$lib/components/ui/Button.svelte';
|
import Button from '$lib/components/ui/Button.svelte';
|
||||||
|
import LocationSearchBox from '$lib/components/ui/LocationSearchBox.svelte';
|
||||||
import Textbox from '$lib/components/ui/Textbox.svelte';
|
import Textbox from '$lib/components/ui/Textbox.svelte';
|
||||||
import BaseCard from '$lib/components/ui/cards/BaseCard.svelte';
|
import BaseCard from '$lib/components/ui/cards/BaseCard.svelte';
|
||||||
|
|
||||||
@@ -16,4 +17,6 @@
|
|||||||
|
|
||||||
<BaseCard header={"Hello"} helpText={"This is help text"}>Hello</BaseCard>
|
<BaseCard header={"Hello"} helpText={"This is help text"}>Hello</BaseCard>
|
||||||
|
|
||||||
|
<LocationSearchBox />
|
||||||
|
|
||||||
<h2>OwlBoard</h2>
|
<h2>OwlBoard</h2>
|
||||||
|
|||||||
42
static/api/tiplocs
Normal file
42
static/api/tiplocs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
[
|
||||||
|
{"n":"Manchester Piccadilly","t":"MANPICD","c":"MAN","s":"manchester piccadilly man manpicd"},
|
||||||
|
{"n":"Manchester Victoria","t":"MCV","c":"MCV","s":"manchester victoria mcv"},
|
||||||
|
{"n":"Manchester Oxford Road","t":"MCOR","c":"MCO","s":"manchester oxford road mco mcor"},
|
||||||
|
{"n":"Manchester Airport","t":"MANAPTL","c":"MIA","s":"manchester airport mia manaptl"},
|
||||||
|
{"n":"London Euston","t":"EUSTON","c":"EUS","s":"london euston eus euston"},
|
||||||
|
{"n":"London Kings Cross","t":"KGX","c":"KGX","s":"london kings cross kgx kingscross"},
|
||||||
|
{"n":"London St Pancras International","t":"STPANCR","c":"STP","s":"london st pancras international stp stpancr"},
|
||||||
|
{"n":"London Paddington","t":"PADTON","c":"PAD","s":"london paddington pad padton"},
|
||||||
|
{"n":"London Victoria","t":"VIC","c":"VIC","s":"london victoria vic"},
|
||||||
|
{"n":"London Liverpool Street","t":"LIVST","c":"LST","s":"london liverpool street lst livst"},
|
||||||
|
{"n":"London Bridge","t":"LONGBR","c":"LBG","s":"london bridge lbg longbr"},
|
||||||
|
{"n":"Birmingham New Street","t":"BHMNEWST","c":"BHM","s":"birmingham new street bhm bhmnewst bham"},
|
||||||
|
{"n":"Birmingham Moor Street","t":"BHMMRS","c":"BMO","s":"birmingham moor street bmo bhmmrs"},
|
||||||
|
{"n":"Birmingham Snow Hill","t":"BHMSH","c":"BSW","s":"birmingham snow hill bsw bhmsh"},
|
||||||
|
{"n":"Leeds","t":"LEEDS","c":"LDS","s":"leeds lds"},
|
||||||
|
{"n":"York","t":"YORK","c":"YRK","s":"york yrk"},
|
||||||
|
{"n":"Liverpool Lime Street","t":"LIVLST","c":"LIV","s":"liverpool lime street liv livlst"},
|
||||||
|
{"n":"Liverpool Central","t":"LIVCEN","c":"LVC","s":"liverpool central lvc livcen"},
|
||||||
|
{"n":"Sheffield","t":"SHEFFLD","c":"SHF","s":"sheffield shf sheffld"},
|
||||||
|
{"n":"Nottingham","t":"NOTTM","c":"NOT","s":"nottingham not nottm"},
|
||||||
|
{"n":"Derby","t":"DERBY","c":"DBY","s":"derby dby"},
|
||||||
|
{"n":"Leicester","t":"LEICEST","c":"LEI","s":"leicester lei leicest"},
|
||||||
|
{"n":"Bristol Temple Meads","t":"BRSTLTM","c":"BRI","s":"bristol temple meads bri brstltm"},
|
||||||
|
{"n":"Cardiff Central","t":"CDFCEN","c":"CDF","s":"cardiff central cdf cdfcen"},
|
||||||
|
{"n":"Newcastle","t":"NEWCAST","c":"NCL","s":"newcastle ncl newcast"},
|
||||||
|
{"n":"Edinburgh Waverley","t":"EDINBUR","c":"EDB","s":"edinburgh waverley edb edinbur"},
|
||||||
|
{"n":"Glasgow Central","t":"GLASCEN","c":"GLC","s":"glasgow central glc glascen"},
|
||||||
|
{"n":"Glasgow Queen Street","t":"GLAQS","c":"GLQ","s":"glasgow queen street glq glaqs"},
|
||||||
|
{"n":"Reading","t":"READING","c":"RDG","s":"reading rdg"},
|
||||||
|
{"n":"Oxford","t":"OXFORD","c":"OXF","s":"oxford oxf"},
|
||||||
|
{"n":"Cambridge","t":"CAMBRDG","c":"CBG","s":"cambridge cbg cambrdg"},
|
||||||
|
{"n":"Peterborough","t":"PBOUGH","c":"PBO","s":"peterborough pbo pbough"},
|
||||||
|
{"n":"Doncaster","t":"DONCAST","c":"DON","s":"doncaster don doncast"},
|
||||||
|
{"n":"Crewe","t":"CREWE","c":"CRE","s":"crewe cre"},
|
||||||
|
{"n":"Preston","t":"PRESTON","c":"PRE","s":"preston pre"},
|
||||||
|
{"n":"Blackpool North","t":"BPLNOR","c":"BPN","s":"blackpool north bpn bplnor"},
|
||||||
|
{"n":"Bolton","t":"BOLTON","c":"BON","s":"bolton bon"},
|
||||||
|
{"n":"Huddersfield","t":"HUDDSFD","c":"HUD","s":"huddersfield hud huddsfd"},
|
||||||
|
{"n":"Stockport","t":"STOCKPT","c":"SPT","s":"stockport spt stockpt"},
|
||||||
|
{"n":"Wigan North Western","t":"WIGNW","c":"WGN","s":"wigan north western wgn wignw"}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user