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

Editorial review: Device Posture API #37595

Merged
merged 18 commits into from
Feb 7, 2025

Conversation

chrisdavidmills
Copy link
Contributor

@chrisdavidmills chrisdavidmills commented Jan 10, 2025

Description

Chrome 132 supports the Device Posture API, which provides functionality to create user interfaces that adapt to a foldable device's posture and respond to posture changes.

Specifically, it adds:

  • The DevicePosture interface, which is accessed via the navigator.devicePosture property.
  • The device-posture media query feature.

This PR adds docs for all the features of the API.

See https://chromestatus.com/feature/5185813744975872 for the data source.

Also see https://developer.chrome.com/blog/foldable-apis-ot for a tutorial with some info.

Also see mdn/dom-examples#292 for my PR to add a demo to the dom-examples repo

Motivation

Additional details

Related issues and pull requests

@chrisdavidmills chrisdavidmills requested review from a team as code owners January 10, 2025 17:49
@chrisdavidmills chrisdavidmills requested review from sideshowbarker, estelle and pepelsbey and removed request for a team January 10, 2025 17:49
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs Content:WebAPI Web API docs labels Jan 10, 2025
@chrisdavidmills chrisdavidmills marked this pull request as draft January 10, 2025 17:49
@github-actions github-actions bot added the size/m [PR only] 51-500 LoC changed label Jan 10, 2025
Copy link
Contributor

github-actions bot commented Jan 10, 2025

Preview URLs (10 pages)
Flaws (8)

Note! 7 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/API/Navigator
Title: Navigator
Flaw count: 1

  • macros:
    • Can't resolve /en-US/docs/Web/API/Navigator/standalone

URL: /en-US/docs/Web/CSS/@media
Title: @media
Flaw count: 2

  • broken_links:
    • Can't resolve /en-US/docs/Web/CSS/media-query-list
    • Can't resolve /en-US/docs/Web/CSS/rule-list

URL: /en-US/docs/Web/CSS/CSS_media_queries
Title: CSS media queries
Flaw count: 5

  • macros:
    • Can't resolve /en-US/docs/Web/CSS/@media/environment-blending
    • Can't resolve /en-US/docs/Web/CSS/@media/horizontal-viewport-segments
    • Can't resolve /en-US/docs/Web/CSS/@media/nav-controls
    • Can't resolve /en-US/docs/Web/CSS/@media/vertical-viewport-segments
    • Can't resolve /en-US/docs/Web/CSS/@media/video-color-gamut
External URLs (6)

URL: /en-US/docs/Web/API/DevicePosture
Title: DevicePosture


URL: /en-US/docs/Web/API/DevicePosture/type
Title: DevicePosture: type property


URL: /en-US/docs/Web/API/DevicePosture/change_event
Title: DevicePosture: change event


URL: /en-US/docs/Web/API/Device_Posture_API
Title: Device Posture API


URL: /en-US/docs/Web/CSS/@media/device-posture
Title: device-posture

(comment last updated: 2025-02-07 10:50:13)

@sideshowbarker sideshowbarker removed their request for review January 18, 2025 13:47
@estelle estelle removed their request for review January 27, 2025 19:19
@chrisdavidmills chrisdavidmills changed the title Device Posture API Technical review: Device Posture API Jan 31, 2025
@chrisdavidmills chrisdavidmills marked this pull request as ready for review January 31, 2025 10:47
@darktears
Copy link

LGTM

@chrisdavidmills chrisdavidmills changed the title Technical review: Device Posture API Editorial review: Device Posture API Feb 3, 2025
@chrisdavidmills
Copy link
Contributor Author

chrisdavidmills commented Feb 3, 2025

LGTM

Thanks for reviewing, @darktears!

@estelle, this is now ready for your editorial review.

Note that the dom-examples demo that I link to in this PR will 404 until mdn/dom-examples#292 is merged. You can see an example of the same demo at https://device-posture-test.glitch.me/.

@estelle estelle self-assigned this Feb 4, 2025
@estelle
Copy link
Member

estelle commented Feb 4, 2025

Screenshot 2025-02-04 at 2 50 12 PM Samsung Flip 6 running chrome 128 in default state.

edit: figured out the issue. 128 is origin trial, which this device is not part of

edit: reads as continuoius in chrome when emulating folded

edit: samsung internet has it on by default, so it works in the @browserstack emulator, but always says continuous (only options on emulator and browserstack are to have it fully flat (180deg) or folded (360deg), not folded at any other angle

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

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

I think "device posture" needs to be defined.
we can either define it in the intro of all of these pages, or create a glossary and link to it.

@@ -37,6 +37,7 @@ When designing reusable HTML components, you may also use [container queries](/e
- {{cssxref("@media/color-index", "color-index")}}
- {{cssxref("@media/device-aspect-ratio", "device-aspect-ratio")}}
- {{cssxref("@media/device-height", "device-height")}}
- {{cssxref("@media/device-posture", "device-posture")}}
Copy link
Member

Choose a reason for hiding this comment

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

because this is not in the css media queries specification, this gets added under "related concepts" rather than here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I appreciate why you are saying this, but I worry that this will make the device-posture descriptor hard to find on the page. It would surely be more useful to put it in the list.

Choose a reason for hiding this comment

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

The CSS media queries are defined in the Device Posture spec. In that regard in makes no difference than "being defined in the CSS spec". It's just so that the feature is defined in the spec it belongs to. It doesn't make it "less official".

Copy link
Member

Choose a reason for hiding this comment

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

these module landing pages are about the module - the spec - not about any individual features.
Those looking for a list of descriptors would go to the @media page.
those wanting to learn about the spec would to to this page. That is why this link has to be moved.

files/en-us/web/css/@media/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/@media/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/@media/device-posture/index.md Outdated Show resolved Hide resolved
files/en-us/web/css/@media/device-posture/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/device_posture_api/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/device_posture_api/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/device_posture_api/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/device_posture_api/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/device_posture_api/index.md Outdated Show resolved Hide resolved
chrisdavidmills and others added 12 commits February 5, 2025 11:50
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

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

a few edits and we're good to go

## Examples

```js
const postureOutput = document.querySelector("p");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const postureOutput = document.querySelector("p");
const postureOutput = document.querySelector("#currentPosture");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

}
```

To see the above code in action, view the [Device Posture API demo](https://mdn.github.io/dom-examples/device-posture-api/) on a foldable device.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To see the above code in action, view the [Device Posture API demo](https://mdn.github.io/dom-examples/device-posture-api/) on a foldable device.
To see the above code in action, view the [Device Posture API demo](https://mdn.github.io/dom-examples/device-posture-api/) on a foldable device. Your browser developer tools enable emulating foldable devices, but current tools don't include emulating partially folded devices, only fully open or closed devices, so they will always return `continuous`.

Copy link
Member

Choose a reason for hiding this comment

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

i am pretty confident this is true. (tested dev tools and browserStack)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, this sounds plausible. I have rewritten it a bit and included it here and on the Examples section of the main Device Posture API landing page.

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

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

Just need to address https://github.com/mdn/content/pull/37595/files#r1942113759 and this PR is good to go.

@chrisdavidmills
Copy link
Contributor Author

Just need to address https://github.com/mdn/content/pull/37595/files#r1942113759 and this PR is good to go.

OK, done

Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

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

Thanks! 🎉

@chrisdavidmills chrisdavidmills merged commit a3d19af into mdn:main Feb 7, 2025
9 checks passed
@chrisdavidmills chrisdavidmills deleted the device-posture-api branch February 7, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants