geocodeearth / autocomplete-element Goto Github PK
View Code? Open in Web Editor NEWA custom element for use with the Geocode Earth Autocomplete API.
Home Page: https://geocode.earth
License: MIT License
A custom element for use with the Geocode Earth Autocomplete API.
Home Page: https://geocode.earth
License: MIT License
When running npm install
on the repo I'm getting an "Incorrect or missing password" error from npm
.
Deleting the package-lock.json
file resolves the issue and allows me to install the dependencies.
/code/ge/autocomplete-element main ❯ git log -1
commit 581c95f8d1ff6f81a9effb1fdf819afaf9b98599 (HEAD -> main, tag: v0.0.9, origin/main, origin/HEAD)
/code/ge/autocomplete-element main ❯ npm install
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/peter/.npm/_logs/2021-06-22T11_57_29_872Z-debug.log
For now I have only implemented a single event, select
, which is fired when the user selects a suggested item in the autocomplete. What other events (if any) do we want to fire?
Possible options/suggestions:
I have implemented all autocomplete API params, but I think we should add a couple more customization options, more specifically:
300 ms
)Do we need anything else to be customizable? This excludes visual changes like styling, dark mode, icons, etc, see below
Do we want to add any of this? Notably Algolia Places does not have any either. I personally like not having animations as they very easily make the UI feel sluggish.
We could add a little x
button on the right to clear the input field.
We could add a spinner animation for when the component is fetching results (#2)
We don’t currently show a "no results found" message (and neither does the algolia places demo). Is this necessary?
Briefly discussed in Slack, we could vary the icon next to a result depending on its type. For example a train for train stations, a city for cities, etc.
We could allow using the user’s location through the browser API as is implemented in the component on our website.
autofocus
attribute as is expected for text input fieldswe could add a header to every request which would contain the version of the autocomplete component, which we could use to gain some insight into how many requests are made using the component as well if people upgrade the version etc
failed to get the value of input
use-deep-compare-effect.esm.js:10 Uncaught Error: useDeepCompareEffect should not be used with dependencies that are all primitive values. Use React.useEffect instead.
at checkDeps (use-deep-compare-effect.esm.js:10:11)
at useDeepCompareEffect (use-deep-compare-effect.esm.js:32:5)
at autocomplete_default3 (autocomplete.js:46:3)
at renderWithHooks (react-dom.development.js:14985:18)
at mountIndeterminateComponent (react-dom.development.js:17811:13)
at beginWork (react-dom.development.js:19049:16)
at HTMLUnknownElement.callCallback2 (react-dom.development.js:3945:14)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:16)
at invokeGuardedCallback (react-dom.development.js:4056:31)
at beginWork$1 (react-dom.development.js:23964:7)
Appears to be introduced in 9f7d82b
@mxlje do you know why this used to work but now doesn't? I tried pinning earlier versions of use-deep-compare-effect
without success.
I've been playing around with doing some zany visual customisation which highlighted some minor issues with the templating/css vars.
None of this is urgent to fix, I'm just writing it down here so I don't forget ;)
" "
<li>
no longer has the result-item
and result-item-active
classes, this makes it difficult/impossible to style the full width/height background-color
of each row.white-space: nowrap; overflow: hidden;
with optional text-overflow: ellipsis;
, this is not possible by default, it can be achieved with row templates but requires nesting an additional <span>
otherwise the icon width throws off the ellipsis calc. It would be even better if this didn't require using the private APIToday I was trying to write some new examples of customizing the autocomplete element, and wanted to provide examples that slightly modified either the string or (especially) row templates.
This turns out to be pretty hard, because the default templates are not written in plain HTML, as a custom template would be, but instead directly in a React component.
For the row template, I settled on the following HTML, which is probably close but not quite right:
<template row>
<li class="result-item">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"
class="result-item-icon"><path fill-rule="evenodd" d="M5.05 4.05a7 7 0 119.9 9.9L10
18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z"
clip-rule="evenodd"></path></svg>
${item.feature.properties.label}
</li>
</template>
If its not too difficult, we might want to provide a good starting point for customization in our docs.
The first keypress(es) do not generate requests until after the debounceWait
period has passed.
I noticed in testing that responses were coming back in 140ms
but the UI was taking ~1s
to refresh.
This can be reproduced in development by setting
debounceWait
to a higher interval such as5000
.
There is a user-experience tradeoff to be made here, on one hand single character specificity usually won't yield relevant results, on the other hand the initial delay makes the interface feel slow.
empty data attributes generate empty querystring params, eg:
<ge-autocomplete sources="" />
will add ?sources=
to the querystring.
use of this library from templating is easier if the data attributes are always rendered in the HTML but only populated when required.
this ticket is to investigate solutions to detecting empty data attributes and avoiding generating querystring params.
In the case where the component is rolled out widely across a medium/large website, the HTML code may exist in multiple views across the codebase.
Changing the API key in this scenario becomes a bit of a chore.
Would it be possible to define the api_key
parameter once per installation and then omit the api_key
attribute when embedding the component?
As discussed today on our call, it would be amazing to have the ability for advanced users to have more control over how the CSS styles and markup are generated.
The scope of the feature would be:
As noted on the call, it may be beneficial to abstract the CSS variables used for padding etc away from the DOM structure and specific class naming which may change over time. This may either be done as part of this work or as a subsequent feature. For Example.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.