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

Replace alert() in Web/API live samples #7570

Merged
merged 3 commits into from
Sep 13, 2021
Merged

Conversation

wbamberg
Copy link
Collaborator

@wbamberg wbamberg commented Aug 4, 2021

This PR should eventually be a fix for #7566.

I don't think it's worth spending a ton of time on this, but it's worth thinking a little bit about having a really simple but usable pattern for replacing alert() in live samples.

So this PR currently implements one approach to this on a single page, so I can get some feedback :). In this approach I just have an <hr> after the main part of the example, and under that I have an "Output" <div> that I can write output into, instead of putting it in an alert.

@wbamberg wbamberg requested a review from a team as a code owner August 4, 2021 04:07
@wbamberg wbamberg requested review from jpmedley and removed request for a team August 4, 2021 04:07
@wbamberg wbamberg marked this pull request as draft August 4, 2021 04:07
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 2021

Preview URLs

Flaws

None! 🎉

External URLs

URL: /en-US/docs/Web/API/Document/queryCommandState
Title: Document.queryCommandState()
on GitHub

No new external URLs

(this comment was updated 2021-09-10 00:05:57.363584)

@wbamberg wbamberg changed the title Example replacement for alert Replace alert() in Web/API live samples Aug 4, 2021
Copy link
Collaborator

@Ryuno-Ki Ryuno-Ki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put my developer hat on while reviewing.

&lt;div id="output"&gt;&lt;/div&gt;
</pre>

<pre class="brush: css hidden">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the hidden do here?
(My gut feeling would be suppressing it from showing up on the page).
In that case, I'd suggest to add a CSS comment that this styling is meant to provide feedback into what's going on behind the scenes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't done this because using hidden (which, as you guessed, hides code blocks in the rendered output) is a very common thing to do in MDN live samples, and as a matter of convention we don't signal it using a comment.

}

#output:before {
content: "Output:";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see why you did it that way, but the value feels like „non-decorative” to me. I'd suggest to move that to the .textContent assignment instead (for example, using a template literal and interpolate the message).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, makes sense.


#output:before {
content: "Output:";
padding-right: .5rem;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use logical properties here?

It's a matter of taste, but I find it harder to read .5 than 0.5.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:before is removed, so this isn't relevant any more.

margin: 1rem 0;
}

#output:before {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#output:before {
#output::before {

Personally, I prefer to use two colons to separate pseudo elements from pseudo classes, but both ways are valid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:before is removed, so this isn't relevant any more.

* upstream/main: (87 commits)
  Update formdata and touchstart macros (mdn#7713)
  Corrected sentence in Streams API overview (mdn#7712)
  Fix broken link (mdn#7711)
  Replace SVGMatrix with DOMMatrix (mdn#7710)
  Removed example covered by other examples (mdn#7706)
  Remove last link to NameList (mdn#7708)
  Delete DOMObject (mdn#7701)
  Remove <dl> list for return value of DOMException() (mdn#7699)
  Fix broken links in Glossary (mdn#7692)
  Fix broken link to NSS/FAQ (mdn#7709)
  Update DOM intro (DOM is no more different in each browsers) (mdn#7705)
  Update Touch() contructor syntax (mdn#7702)
  Replace usage of alert() in File.name(mdn#7703)
  Replace usage of alert() in KeyboardEvent.metaKey(mdn#7704)
  Replace usage of alert() in DOMException() (mdn#7698)
  Remove unnecessary <code> tag (mdn#7697)
  Fix mixin example in Object.create() article (mdn#7631)
  Replace usage of alert() in EventListener (mdn#7690)
  Fix link from Element to Document.querySelectorAll (mdn#7688)
  Replace usage of alert() in Window.find() (mdn#7686)
  ...
@wbamberg wbamberg marked this pull request as ready for review September 10, 2021 00:03
@wbamberg
Copy link
Collaborator Author

Thanks @Ryuno-Ki ! I think I have addressed your comments.

@teoli2003
Copy link
Contributor

@Ryuno-Ki, given that this PR will "rot" later tonight with the conversion to Markdown, I think we should land this and eventually address problems in follow-ups.

I know you are busy these days, so I will proceed to merge it in a few hours if you don't have time to answer.

@teoli2003 teoli2003 added the Content:WebAPI Web API docs label Sep 13, 2021
Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's land this so it doesn't block markdown conversion

@Elchi3 Elchi3 merged commit bb82805 into mdn:main Sep 13, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2022
@wbamberg wbamberg deleted the remove-alert-webapi branch April 5, 2023 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants