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

Consider replacing/revising EmbedLiveSample's API #5016

Open
wbamberg opened this issue Nov 29, 2021 · 1 comment
Open

Consider replacing/revising EmbedLiveSample's API #5016

wbamberg opened this issue Nov 29, 2021 · 1 comment
Labels
🧑‍🤝‍🧑 community contributions by our wonderful community idle live-samples issues related to live samples (EmbedLiveSample macro) macros tracking issues related to kumascript macros p4 Not urgent, only if time allows

Comments

@wbamberg
Copy link
Collaborator

This comes out of #4971.

To make it easier to write live samples, especially in Markdown and especially for translated content, we have a new way for the live sample macro to find the code blocks to use. In this new way the macro looks for code blocks in the same section of the document as the macro call itself. That makes the id argument to EmbedLiveSample redundant.

We've been experimenting with removing this argument an replacing it with an empty string, and fixing macros where this doesn't work (e.g. mdn/content#10758).

At this point the EmbedLiveSample interface seems in need of some rework. It currently accepts 7 arguments:

  • $0 - The ID of the header block containing the sample: this would be made redundant
  • $1 - The width of the iframe (optional): this is already redundant
  • $2 - The height of the iframe (optional): this is still in use (although I would love it if Yari could calculate a sensible default for this from the content height).
  • $3 - The url of a screenshot of the sample working as intended (optional): this is occasionally used but we could perhaps look at deprecating it.
  • $4 - The slug from which to load the sample (optional; current page used if not provided): this is occasionally used but it would be great if we could deprecate it - Ryan told me it, (along with the {{page}} macro) is one of the most difficult bits of KS (because it introduces a build dependency)
  • $5 - The class name of the frame; defaults to "sample-code-frame": this used to be used to suppress the "Open in CodePen/JSFiddle" buttons, but now has no visible effect.
  • $6 - Allowed features, separated by semicolons (optional): this is used in a few places, to grant microphone, camera, and geolocation access to certain live samples. We could consider just giving all live samples the access needed here, but maybe it would be safer to keep this option.

So if we make the id redundant, of those 7 arguments:

  • 3 no longer do anything
  • we might want to deprecate or remove any or possibly even all of the remaining 4.
@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 29, 2021
@schalkneethling schalkneethling added engineering-request enahncement requests from community, writers and partners 🚉 platform keeping the platform healthy and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Nov 30, 2021
@schalkneethling schalkneethling added the 🧑‍🤝‍🧑 community contributions by our wonderful community label Apr 15, 2022
@nschonni
Copy link
Collaborator

Notice from the HTML validation that the height/width values are allowing units like 100%, but those properties are supposed to be only numbers in pixels without units. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
There may be a need for these other unit values, but then it probably needs to set it as a style="width: 100%" instead

@github-actions github-actions bot added the 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. label Jun 5, 2022
@caugner caugner added p4 Not urgent, only if time allows macros tracking issues related to kumascript macros live-samples issues related to live samples (EmbedLiveSample macro) and removed 🚉 platform keeping the platform healthy engineering-request enahncement requests from community, writers and partners labels Nov 15, 2022
@github-actions github-actions bot removed the 🐌 idle Issues and PRs without recent activity. Flagged for maintainer follow-up. label Nov 15, 2022
@github-actions github-actions bot added the idle label Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍🤝‍🧑 community contributions by our wonderful community idle live-samples issues related to live samples (EmbedLiveSample macro) macros tracking issues related to kumascript macros p4 Not urgent, only if time allows
Projects
Development

No branches or pull requests

4 participants