Skip to content
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

feat(website): support HTML custom display of table entries #3576

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

chaoran-chen
Copy link
Member

preview URL: https://html-custom-display.loculus.org

Summary

This adds a new type of custom display "html" that allows the maintainer to provide an HTML template to render a table entry.

Background: I'd like to use that to improve the display of the frequency JSONs here.

To demonstrate the feature, the feature was used to make the country bold in the below screenshot.

Screenshot

image

PR Checklist

  • [ ] All necessary documentation has been adapted. Documentation is missing for the custom display feature and I propose adding it separately (Document customDisplay config #3574).
  • [ ] The implemented feature is covered by an appropriate test. We don't have any tests for the other custom displays and I hope it's ok that we don't have one in this PR.

@chaoran-chen chaoran-chen added the preview Triggers a deployment to argocd label Jan 26, 2025
@chaoran-chen chaoran-chen self-assigned this Jan 26, 2025
Copy link
Member

@theosanderson theosanderson left a comment

Choose a reason for hiding this comment

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

happy with this. I think if we decide to actually support tables we should actually implement a table feature directly - and I'd be uncertain as to whether Loculus should document the idea of using a custom element for this, but in terms of having the raw feature - sounds fair!

@chaoran-chen
Copy link
Member Author

Thanks for reviewing, @theosanderson! (As it's not urgent, I'll keep the PR open for another day to see whether someone else has comments.)

@fhennig
Copy link
Contributor

fhennig commented Jan 27, 2025

In the files it seems like the config option is still called html (not htmlTemplate).

I see how this is useful for this JSON thing! Can you maybe come up with more examples? I think having more could be nice to document this feature better.

@chaoran-chen
Copy link
Member Author

@fhennig, I think it's fine to keep the value just html and call the type htmlTemplate? But no strong preference, let me know if you think it's better to change.

This can be used for all kinds of things: to embed an image, a video, map, plot, tree – whatever you can imagine!

additionalHeadHTML: '<script defer data-domain="loculus.org" src="https://plausible.io/js/script.js"></script>'
additionalHeadHTML: '<script defer data-domain="loculus.org" src="https://plausible.io/js/script.js"></script><script src="https://chaoran-chen.github.io/test-custom-display/frequency-custom-display.js"></script>'
Copy link
Member Author

Choose a reason for hiding this comment

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

Revert before merge

Comment on lines +171 to +173
customDisplay:
type: htmlTemplate
html: "<frequency-custom-display>__value__</frequency-custom-display>"
Copy link
Member Author

Choose a reason for hiding this comment

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

Revert before merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Triggers a deployment to argocd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants