Skip to content

Custom html render - #208

Merged
scottsfarley93 merged 5 commits into
version4from
custom-render
Mar 20, 2019
Merged

scottsfarley93 merged 5 commits into
version4from
custom-render

Conversation

@scottsfarley93

Copy link
Copy Markdown

This PR approaches #153 by exposing two new constructor options render and getItemValue.

  • render is a function that accepts a carmen geojson function and returns an html string to display in the dropdown menu. This function can be customized by setting options.render so that any html can be rendered in the dropdown. This improves the customizability of the style/display of the results.
  • getItemValue is a function that accepts a carmen geojson feature and returns a string to use in the search bar after a selection has been made. This method currently retains the old name, but perhaps we should name it something more intuitive in this context.

Note: This requires the changes in tristen/suggestions#25 -- so we'll wait here until this upstream PR lands.

\cc @katydecorah @yuletide @kbauhaus

Comment thread lib/index.js
},
getItemValue: function(item) {
return item.place_name
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just for your testing, or are you intending to default to showing an icon?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still just a WIP -- I'm planning on changing this back to match the existing functionality before merge.

It might be helpful to use this as an example here since it would demonstrate the custom render function and be a use case I suspect people are pretty familiar with.

@scottsfarley93 scottsfarley93 mentioned this pull request Mar 20, 2019
4 tasks done

@katydecorah katydecorah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I tested it out locally in #211 to create multiline results and it's super smooth 😎

@scottsfarley93
scottsfarley93 merged commit 9902ad7 into version4 Mar 20, 2019
@katydecorah katydecorah mentioned this pull request Mar 20, 2019
16 of 17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants