(Jamie, Kin, Reda and Roshan)
- Make a website that enables users to quickly find and select words from a list of suggestions, as they type ✅
- The list is dynamically generated from a pre-populated list of values, leveraging searching and filtering ✅
- A large data file is required to search through - (we chose an object of country: dish pairs) ✅
- Consider how implementation affects user experience and web performance ✅
- Submit button returns the national dish related to the country searched ✅
- Highlight untyped parts of the suggestions in list
- Further functionality (link to google or recipe search on the dish found)
- Utilise good UI practice from this week's design burst - eg colour li on hover ✅
- Add randomiser
- Return to Home upon h1 click ✅
Heroku link Otherwise:
- Clone the Github repo
- navigate to repo folder
- run npm install
- run npm start
- visit localhost:3000 in browser
An autocomplete widget site where you search for a country and discover its national dish.
-
After a little team deliberation we decided to use countries as a data set - it is small enough to quickly create the key value object ourselves and avoid making api calls to a live database.
-
We got to designing the architecture and file structure...
Desktop wireframe
Mobile wireframe
- Basic functionality using node and accounting for linked files
- Modular file structure - server.js, router.js, handler.js
- Be called on each keypress for the input field
- Send the search URL through the server to our data file and bring back array of filtered data
- Call a function to append the autofill suggestions to the DOM
- Passing the endpoint through the router
decodeURI
to correct the JSON string (spaces as%20
)toLowerCase
to homogenise casesfilter
to find results and append to an arraystringify
the array and send back to API
- We created a separate API request and handler function to get the name of the selected country's dish
- learnt that we have to
JSON.stringify
a string to pass it back to API
- learnt that we have to
- Function to refresh the suggestions list on every input to search field
- Tried everything, from selecting suggestions
<ul>
byclassName
, selecting bytagName
,for
loop,forEach
- From 20 lines of code to this
- HTML Collections and NodeLists
- Given more time we would have liked to create tests and refactor some code
- We had planned to separately write pure functions (such as
filter
for searching)
- Can't test pure functions if you don't have pure functions