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

[ENHANCEMENT] Provide SVG and/or HTML formats as alternative to JSON for web platform features #1217

Open
niutech opened this issue Feb 27, 2025 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@niutech
Copy link

niutech commented Feb 27, 2025

As suggested by @devnook in web-platform-dx/baseline-status#35 (comment), could you please provide an SVG image and/or basic HTML/CSS (without JS) as alternative formats to JSON for web platform features? They could be used as static baseline status widgets where JS is not supported, e.g. <img src="https://api.webstatus.dev/v1/features/xxx?format=svg"> and/or <iframe src="https://api.webstatus.dev/v1/features/xxx?format=html"></iframe>.
Thank you!

@niutech niutech added the enhancement New feature or request label Feb 27, 2025
@jcscottiii
Copy link
Collaborator

jcscottiii commented Feb 27, 2025

Thank you for the suggestion. Given that the /v1/features/{featureID} API provides a broad range of data beyond what's displayed in the widget, I believe generating SVG or HTML directly within the API service might lead to unnecessary complexity. This complexity arises from the fact that the API layer acts (and should continue to act) as a data provider, knowing nothing about the presentation layers, such as the webstatus.dev frontend or the baseline widget.

Instead, I propose we implement this rendering functionality within the separately hosted frontend service. Specifically, we could introduce an endpoint like webstatus.dev/features/anchor-positioning/widget?format=html. This endpoint would leverage the existing baseline-status widget from https://github.com/web-platform-dx/baseline-status for server-side rendering[1].

Given that the baseline-status widget is purely for displaying data and has no interactive elements, this server-side rendering approach will provide the static HTML output requested.

To achieve this, we may need some upstream changes to the baseline-status widget. Example: allowing it to accept a data property, thus bypassing its internal API fetch. This would enable server-side hydration. This approach prevents us from duplicating the widget's logic and ensures consistent rendering.

One benefit of this approach: It allows the webstatus.dev frontend or anyone in the community to host such a service

@jcscottiii
Copy link
Collaborator

jcscottiii commented Feb 27, 2025

Let me know your thoughts on the data property idea @devnook

@niutech
Copy link
Author

niutech commented Feb 27, 2025

@jcscottiii That would be awesome to have a static HTML (no JS) baseline status widget. Injecting data object should be straightforward, but if it wasn't, as an alternative you could reuse the Astro Embed Baseline Status. Thank you!

@jcscottiii jcscottiii added the good first issue Good for newcomers label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

2 participants