Skip to content

Create doc for common attributes to most/all AMP components#276

Merged
3 commits merged intomasterfrom
docs-common-attributes
Dec 22, 2016
Merged

Create doc for common attributes to most/all AMP components#276
3 commits merged intomasterfrom
docs-common-attributes

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Dec 21, 2016

A doc that will be linked/referred from amp component docs that describe the common attributes for AMP components.

to: @pbakaus
cc: @cramforce

In a different PR, I'll show how an amp component's doc "attributes" section will refer to this doc. Example - ampproject/amphtml#6772


## fallback

The `fallback` attribute can be set on any HTML element, not just AMP elements. A fallback is a convention that allows the element to communicate to the reader that the browser does not support the element. If specified, a fallback element must be a direct child of the AMP element. The exact behavior with respect to the fallback is up to the element's implementation.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

… does not support the element or that loading the underlying resource failed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to the end:, but typically the fallback element would be shown in place of the regular element.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done


For more information, see [Placeholders & fallbacks](https://www.ampproject.org/docs/guides/responsive/placeholders).

## height
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe make width and height one paragraph? It is a bit weird to have them far apart.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done


## noloading

The `noloading` attribute indicates whether the "loading indicator" should be turned **off** for this element. Many AMP elements are white-listed to show a "loading indicator", which is a basic animation that shows that the element has not yet fully loaded.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove are white-listed to

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done


## placeholder

The `placeholder` attribute can be set on any HTML element, not just AMP elements. The placeholder attribute indicates that the element marked with this attribute acts as a placeholder for the parent AMP element. If specified, a placeholder element must be a direct child of the AMP element.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The first sentence here and for fallback is a bit misleading.

Maybe lead with what they are for and then say "The attribute can be placed on any HTML element that is a direct child of an amp element that supports placeholders."

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Collaborator

@pbakaus pbakaus left a comment

Choose a reason for hiding this comment

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

Looks good, just a few nits!


## heights

All AMP elements that support the `responsive` layout, also support the `heights` attribute. The value of this attribute is a sizes expression based on media expressions, similar to the [img sizes attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img) but with two key differences:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd reword as: "Similar to the sizes attribute on <img> tags"

1. The value applies to the height, not the width of the element.
2. Percent values are allowed. A percent value indicates the percent of the element's width. For example, a value of `80%` indicates that the height of the element will be 80% of the element's width.

When the `heights` attribute is specified along with `width` and `height`, the `layout` is defaulted to `responsive`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This could be a note.

</amp-img>
[/sourcecode]

For more information, see [Art direction with srcset, sizes & heights](https://www.ampproject.org/docs/guides/responsive/art_direction).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I usually styled these as callouts (see styling guides), but up to you :) I'm torn, would like a better, more distinct way of telling people there's a continuation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In this case, I'm going to avoid callouts as there's many FYIs will make the doc too busy.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

SGTM.

height="193" layout="responsive"></amp-img>
[/sourcecode]

For more information, see [Layout & Media queries](https://www.ampproject.org/docs/guides/responsive/control_layout).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Link to the actual section, e.g. add #element-media-queries to the link.

</amp-lightbox>
[/sourcecode]

For more information, see [Actions and Events in AMP](https://github.com/ampproject/amphtml/blob/master/spec/amp-actions-and-events.md).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be good to migrate this doc into a guide, e.g. "Adding interactions" or something. Just a reminder, no blocker for this PR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will make note (in my docs list)


The `placeholder` attribute can be set on any HTML element, not just AMP elements. The placeholder attribute indicates that the element marked with this attribute acts as a placeholder for the parent AMP element. If specified, a placeholder element must be a direct child of the AMP element.

By default, the placeholder is immediately shown for the AMP element, even if the AMP element's resources have not been downloaded or initialized. Once ready, the AMP element typically hides its placeholder and shows the content. The exact behavior with respect to the placeholder is up to the element's implementation.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We usually use the term "component" instead of "element". I'm torn, I prefer elements but components reminds of web components, which is the underlying technology. WDYT @cramforce?

There's also the word tag, tag often gets used to describe the abstract, e.g. the -tag. Element often gets used to describe actual instances of tags on a page, e.g. "These 5 elements should not be here" (you wouldn't use tag in that scenario).


## sizes

All AMP elements that support the `responsive` layout, also support the `sizes` attribute. The value of the `sizes` attribute is a sizes expression as described in [img sizes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img), but extended to all elements, not just images.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above, would reword "img sizes" to something like the -tag's sizes attribute.

@ghost ghost dismissed cramforce’s stale review December 22, 2016 16:27

Cramforce is on holidays; changes implemented.

@ghost ghost merged commit aa9ebd0 into master Dec 22, 2016
@ghost ghost deleted the docs-common-attributes branch December 22, 2016 16:28
This pull request was closed.
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 this pull request may close these issues.

2 participants