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

Support banners/headers #350

Closed
wbamberg opened this issue Feb 5, 2020 · 6 comments · Fixed by #2181
Closed

Support banners/headers #350

wbamberg opened this issue Feb 5, 2020 · 6 comments · Fixed by #2181
Assignees

Comments

@wbamberg
Copy link
Collaborator

wbamberg commented Feb 5, 2020

There's a class of KS macros that we call "banners" or "headers".

They create a block element across the page warning that the item is (for example) deprecated. See e.g. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Expression_closures for a nice pile of these things.

At the moment, in Kuma, the fact that a method is deprecated is maintained in two (or more) places: the BCD for the item (under the status key) and the macro call itself. This makes our content hard to maintain.

We would like to maintain this info only in BCD, and have the stumptown-renderer automatically add the relevant banner(s) based on the BCD.

Since stumptown-renderer already gets BCD for each item, it can do this with no changes to stumptown-content. We might anyway choose to represent status more explicitly in the built JSON, via a top-level status property, say. Then there would be a small change to stumptown-content to add this.

Acceptance criteria

  • stumptown-renderer automatically adds "Deprecated", "Non-standard", or "Experimental" banners to pages, based on the information from BCD.
@peterbe
Copy link
Contributor

peterbe commented Feb 6, 2020

So this is one of those less-than-trivial areas when/if we switch stumptown-renderer to be about displaying and rendering Kuma HTML.

By the way, this is how that would look like in Yari:
Screen Shot 2020-02-06 at 2 54 52 PM

I'd love to develop another ingredient React component but whether it should be used should ideall come from the array of sections.

So, I think there should be something like

console.log(doc.sections.slice(0, 2))
// [{
//    "title": "Non-standard",
//    "content": "<p>This feature is non-standard and ...
//  },
//  {
//    "title": "Obsolete since Gecko 60 (Firefox 60 / Thunderbird 60 / SeaMonkey 2.57)",
//    "content": "<p>This feature is obsolete. Although it 
//  }] 

Note-to-self; here's what the Kuma HTML looks like this page that page:

<div>{{JSSidebar("Operators")}}{{Non-standard_Header}}{{Obsolete_Header("gecko60")}}
<div class="warning"><strong>Non-standard. Do not use!</strong><br>
The expression closure syntax is a deprecated Firefox-specific feature and has been removed starting with Firefox 60. For future-facing usages, consider using <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow functions</a>.</div>
</div>

So, apart from the sidebar, some of those things are KS macros and some are "plain prose content".

@wbamberg
Copy link
Collaborator Author

wbamberg commented Feb 7, 2020

It would be better if the JSON from stumptown-content contained just the data, not the HTML, and the renderer decided how to present that data to the user. This is in line with how we do it for other things we treat as data, like BCD (where we provide the JSON, not the rendered table) or specifications (where we provide the spec link and don't say how to present it.

That also makes it easier for other potential users of stumptown-content to use the content.

If it's important to the render to provide the content in a way the follows the order of items in the body, then the stumptown-content JSON could include an item like:

{
    "type": "status",
    "value": [
        "non-standard", "deprecated"
    ]
}

@peterbe
Copy link
Contributor

peterbe commented Feb 7, 2020

I'm cool with that.

I can write an ingredient that does what kumascript/macros/ObsoleteGeneric.ejs does.

@peterbe
Copy link
Contributor

peterbe commented Feb 7, 2020

Perhaps @kenrick95 would be interested?
We basically need a React component that can take an array like this ["non-standard", "deprecated"] and it should produce something like this:
Screen Shot 2020-02-07 at 11 23 44 AM

The macro https://github.com/mdn/kumascript/blob/master/macros/ObsoleteGeneric.ejs combined with https://github.com/mdn/kumascript/blob/master/macros/Obsolete_Header.ejs should be the inspiration. Together with https://github.com/mdn/kumascript/blob/master/macros/Non-standardGeneric.ejs for non-standard.

If you do get a chance @kenrick95 avoid localization and just go for plain English. We'll make these React ingredients localized some other day.

@wbamberg
Copy link
Collaborator Author

wbamberg commented Feb 7, 2020

I think it's still up for discussion exactly how this will look in the JSON (see mdn/stumptown-content#306, where this would get sorted out) but a couple of things:

  • there would be three possible things to indicate: "deprecated", "experimental", and "non-standard". So no separate "obsolete" (BCD doesn't distinguish "deprecated" and "obsolete" because nobody knows the difference anyway).
  • there would be no reference to Gecko versions, or any versions.

@wbamberg wbamberg self-assigned this Feb 12, 2020
@wbamberg wbamberg added this to the Alfa-Bravo (Q1 2020) milestone Feb 12, 2020
@chinikes chinikes removed this from the Charlie -Delta (Q2 2020) milestone Aug 2, 2020
@peterbe
Copy link
Contributor

peterbe commented Aug 12, 2020

Now moot.

@peterbe peterbe closed this as completed Aug 12, 2020
peterbe added a commit to peterbe/yari that referenced this issue Dec 17, 2020
peterbe added a commit to peterbe/yari that referenced this issue Dec 17, 2020
escattone pushed a commit that referenced this issue Dec 17, 2020
* wrong redirect in local server

Part of #350

* end-to-end tests
SphinxKnight referenced this issue in SphinxKnight/yari Dec 20, 2020
* wrong redirect in local server

Part of #350

* end-to-end tests
SphinxKnight referenced this issue in SphinxKnight/yari Dec 20, 2020
* wrong redirect in local server

Part of #350

* end-to-end tests
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 a pull request may close this issue.

3 participants