-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
customization: CSS, String template, Row template #15
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this small but powerful addition allows a user of the element to define a custom <style> element inside of the custom element, which is then moved in to the Shadow DOM. The <style> tag can define arbitrary CSS of course, but the main (and supported) way of using it is to override CSS variables to customize the styling of the element. Example: <ge-autocomplete …> <style> :host { --input-bg: salmon; --loading-color: red; } </style> </ge-autocomplete>
this is the second (after CSS), very powerful customization feature: it allows a user of the element to define a <template row> tag inside the custom element, and inside of that they can create HTML markup as well as access the data of the row (the Feature) through the lodash template language. Example: <ge-autocomplete …> <template row> <div>${feature.properties.gid}: ${feature.properties.name}</div> </template> </ge-autocomplete>
this template allows customization of the way a Feature is converted into a string and can be used for "smaller" customization where a fully new template with custom styles would be overkill. Also this applies to the resulting string that is placed in the input field after an item is selected. this commit also refactors the way templates are passed to parse them both in a single function instead of duplicating the logic. This also allows easily adding more templates in the future.
2c94d84
to
c3e5419
Compare
orangejulius
reviewed
Jul 1, 2021
orangejulius
reviewed
Jul 1, 2021
README.md
Outdated
</ge-autocomplete> | ||
``` | ||
|
||
**Pro Tip™:** Use the `active` property to check if the current row is being hovered over or activated via arrow keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pro Tip™:
LOL 👍
orangejulius
reviewed
Jul 1, 2021
Co-authored-by: Julian Simioni <orangejulius@users.noreply.github.com>
e45182d
to
90193d0
Compare
by moving the actual feature data one level down we can add metadata to the top level of the object, such as `active`, `index`, and `searchTerm`, so the template can use ${item.feature.properties} ${item.active} that way the meta properties don’t conflict with the geo data itself
|
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds three different (but combinable) ways of customizing the visual style of the element:
As to not repeat everything in this PR description it’s best to read the documentation I wrote: https://github.com/geocodeearth/autocomplete-element/tree/feat/customization-templates#customization