Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Add CompatGroup macro #650

Closed
wants to merge 4 commits into from
Closed

Add CompatGroup macro #650

wants to merge 4 commits into from

Conversation

wbamberg
Copy link

This PR adds a new macro CompatGroup. This macro takes as an argument the name of a CSS module (e.g. "CSS Animations"). It uses https://github.com/mdn/data/blob/master/css/properties.json to fetch the properties in that group, and renders a table containing JSON data for those properties. This enables us to embed a single table in pages like https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout that gives an overview of browser support for that area.

To do this is also splits the existing CompatBeta macro. At the moment this macro takes a path through the compat data object as an argument, resolves that into an array of JSON compat objects, then renders those objects.

To enable CompatGroup to share the rendering code (which is most of the work) this PR also splits out the rendering work from CompatBeta into a new macro CompatRender.

So now we have:

  1. CompatRender: given an array of JSON objects, one for each table row, render a table
  2. CompatBeta: given a path through the JSON data, get the JSON objects, flattening them if needed, then call CompatRender
  3. CompatGroup: given the name of a CSS module, get the JSON objects for the properties it contains, then call CompatRender

The macro is called CompatGroup even though it's much more specific than this, currently only dealing with CSS modules. Maybe in future it could do a similar trick with JS and Web APIs, but we'd need solid metadata first.

I've done some manual testing to try to confirm that we haven't regressed the existing Compat macro with this change.

@wbamberg wbamberg changed the title Group compat Add CompatGroup macro Mar 17, 2018
@Elchi3 Elchi3 added the bcd label Mar 21, 2018
@wbamberg
Copy link
Author

I've added some basic tests for this macro. Would love feedback on whether this is a good way to structure tests and whether there are any conditions I've missed that I should have got.

We should probably also have tests for CompatRender as well, I guess.

@a2sheppy
Copy link
Contributor

a2sheppy commented Aug 1, 2018

Would be lovely to see progress on this but am not sure if or how I can be of any help; I'm eager to see this eventually expand to API documentation.

@wbamberg
Copy link
Author

wbamberg commented Jun 5, 2019

It doesn't seem likely this will get merged.

@wbamberg wbamberg closed this Jun 5, 2019
@Elchi3
Copy link
Member

Elchi3 commented Jun 5, 2019

For the record: A more recent idea to maybe achieve this was notion to add keywords to things in BCD (or to stumptown). See this great comment by Will: mdn/browser-compat-data#4051 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants