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

Add a baseline-status code snippet for each feature #31

Open
jamesnw opened this issue Nov 8, 2024 · 9 comments
Open

Add a baseline-status code snippet for each feature #31

jamesnw opened this issue Nov 8, 2024 · 9 comments

Comments

@jamesnw
Copy link

jamesnw commented Nov 8, 2024

Related to #15, it would be useful to have a copyable code snippet on each feature page so people could easily use the baseline-status component for a feature.

We would also need to make it clear on how to install/load the component.

@caraya
Copy link

caraya commented Dec 13, 2024

Is there any updates on this?

If not is there any guidelines on how to gather this information from available data?

@jamesnw
Copy link
Author

jamesnw commented Dec 13, 2024

The <baseline-status> component hasn't been integrated into the explorer yet, but you can still use it! More info on component is in its repo, and then you can use the id in the URL here as the featureId attribute value.

For instance, If you're on https://web-platform-dx.github.io/web-features-explorer/features/anchor-positioning/ and want to use the component to show "Anchor Positioning" status, you would use the last part of the URL, and add this to your site-

<baseline-status featureId="anchor-positioning"></baseline-status>

@caraya
Copy link

caraya commented Dec 14, 2024

In currently use the baseline-status component but have a hard time identifying the ID for the feature to use

For instance, If you're on https://web-platform-dx.github.io/web-features-explorer/features/anchor-positioning/ and want to use the component to show "Anchor Positioning" status, you would use the last part of the URL, and add this to your site-

<baseline-status featureId="anchor-positioning"></baseline-status>

The problem is that there is no way to figure out the ID for a feature to use with the baseline component. For example, what would the feature ID be for addEventListener, CustomEvents, the Event and CustomEvent constructors?

If I look at MDN, the feature appears as widely available and I havent' been able to figure out what's the ID to use

@jamesnw
Copy link
Author

jamesnw commented Dec 15, 2024

You're looking for events- https://web-platform-dx.github.io/web-features-explorer/features/events

<baseline-status featureId="events"></baseline-status>.

Neither the explorer or MDN directly have a great way of surfacing this, but doing a search of the web-features/features directory should surface where those terms can be found.

@caraya
Copy link

caraya commented Dec 16, 2024

That didn't work.

I copied the example you provided into a page on my post and it still reports unknown compatibility.

I tried to pull data from web-features/features but the IDs don't match

@jamesnw
Copy link
Author

jamesnw commented Dec 16, 2024

I tried to pull data from web-features/features but the IDs don't match

Can you say more about what you tried here, and what didn't match?

Here's an example of the component with the events featureId- https://codepen.io/jamessw/pen/dPbNyep

@caraya
Copy link

caraya commented Dec 16, 2024

Events now work as intended. All the other features I wanted to use report unknown availability.

I forked your Codepen from your previous comment and used to add the other features that I wanted to use

https://codepen.io/caraya/pen/KwPawwL

@captainbrosset
Copy link
Contributor

That's because the web-features repository does not list all of the individual features of the web. For example, addEventListener, or CustomEvent are not separate features in the repo. Instead, they are grouped with other features that are closely related to them, under a slightly higher-level feature: events.

The way we define features on the repo is by making them match how most developers think about them. As a web developer, you want to know if events are supported as a whole.

MDN does show a baseline widget per reference page. That's why you see one on the addEventListener page. They are not using the baseline-status widget to do this, and instead use some code to compute the status of individual sub-features from our repo. Here is what they use: https://www.npmjs.com/package/compute-baseline

I think this raises a very valid question of whether the baseline-status widget should be allowed to display baseline information for individual BCD keys that are part of web-features. This particular question needs to move to the baseline-status repo. I'll create an issue there.

@caraya
Copy link

caraya commented Dec 16, 2024

Thank you :)

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

No branches or pull requests

3 participants