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

Add Media queries #1673

Merged
merged 25 commits into from
Sep 18, 2024
Merged

Add Media queries #1673

merged 25 commits into from
Sep 18, 2024

Conversation

jamesnw
Copy link
Collaborator

@jamesnw jamesnw commented Aug 27, 2024

@github-actions github-actions bot added the feature definition Creating or defining new features or groups of features. label Aug 27, 2024
@@ -0,0 +1,6 @@
name: Update frequency media feature
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 was unsure about name here- the key is update but I think `Update frequency" is more useful as a description.

@jamesnw jamesnw marked this pull request as ready for review August 27, 2024 19:38
@@ -0,0 +1,18 @@
name: Media queries
description: CSS Media queries allow you to provide different styles based on the user's device and settings. For example, `@media (width <= 700px) and (orientation:portrait)` selects screens less than 700 pixels wide and also are taller than they are wide.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: CSS Media queries allow you to provide different styles based on the user's device and settings. For example, `@media (width <= 700px) and (orientation:portrait)` selects screens less than 700 pixels wide and also are taller than they are wide.
description: The `@media` CSS rule conditionally applies styles based on the output device type, its capabilities, and the user's preferences. For example, `@media (width <= 700px) and (orientation:portrait)` lets you apply styles only when the device screen is less than 700 pixels wide and is taller than wide.

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 took the first part of your suggestion, but replaced the example with the recommendation for describing media features here. I ran over the character limit otherwise.

@@ -0,0 +1,6 @@
name: color-gamut media feature
Copy link
Contributor

Choose a reason for hiding this comment

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

Applies to other files too: we don't explain here the difference between media query, media type, and media feature. I don't know that we need to do this, we're not a documentation website like MDN. But here, for example, the ID is media-queries-color-gamut while the name is color-gamut media feature.

Perhaps we should only use the term media-feature for media feature things, and then add a short mention in the main media-queries feature like "Media queries are composed of an optional media type such as screen or print, and one or more mandatory media features, such as prefers-reduced-animations".

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 struggled on the naming for this. I think media feature is perhaps more spec language than developer language, but I think your addition to media-queries makes sense.

For the id, I'm realizing that I was essentially adding the group to the file name, with the side benefit of being able to see them together in the file list. Would you recommend media-feature-color-gamut, color-gamut-media-feature, or just color-gamut?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's a good clarification to the media-queries feature, and still I would consider naming the individual features e.g. color-gamut media query as a more common way for developers to talk about these features.

I don't have a strong sense on IDs, but looking at what's there, I think we're past the point of naming things in a way that is nicely sorted. Folders by group would be more helpful on that front.

@@ -0,0 +1,6 @@
name: color-gamut media feature
description: The `color-gamut` media feature sets styles based on the colors a device can display. Values are `srgb` if the device can display at least sRGB, `p3` if the device can display at least Display P3, and `rec2020` if the device can display at least REC. 2020.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if color-gamut is a field that evolves quickly, but if it is, we might want to drop the "Values are ..." sentence, to avoid having to maintain this to always be complete.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Based on conversations with spec authors and implementors, this should be a rather stable list. There are privacy issues with going more granular, and it's unlikely that gamuts larger than rec2020 will be needed soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the color() function now supports a number of additional spaces with distinct gamuts, I do wonder if there will be a push for consistency?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I'll remove the values.

@@ -0,0 +1,7 @@
name: display-mode media feature
description: The `display-mode` CSS media feature sets styles based on whether the user's browser is in `fullscreen`, `standalone`, `minimal-ui,` `browser`, or `picture-in-picture` mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

"based on whether the user's browser" is a bit incorrect here. For example, standalone and minimal-ui only really make sense when the site was installed as a PWA on the device, in which case the user doesn't really consider the site as running in a "browser" any longer.

How about:

Suggested change
description: The `display-mode` CSS media feature sets styles based on whether the user's browser is in `fullscreen`, `standalone`, `minimal-ui,` `browser`, or `picture-in-picture` mode.
description: The `display-mode` CSS media feature sets styles based on whether the web page is in `fullscreen`, `standalone`, `minimal-ui,` `browser`, or `picture-in-picture` mode. For example, an installed Progressive Web App can be displayed in a standalone window by setting `"display": "standalone"` in its web app manifest file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point on "web page". I removed the example because it was over the 300 character limit, and it seemed more about a PWA feature than about the media query itself, but am not opposed to an example here.

features/media-queries-interaction.yml Outdated Show resolved Hide resolved
features/media-queries-prefers-reduced-transparency.yml Outdated Show resolved Hide resolved
features/media-queries-prefers-contrast.yml Outdated Show resolved Hide resolved
features/media-queries-update.yml Outdated Show resolved Hide resolved
Comment on lines +15 to +16
- css.at-rules.media.orientation
- css.at-rules.media.aspect-ratio
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we capture these 2 media features, and maybe others, as separate features?
I think keeping height and width here is fine, this is what the vast majority of media query usage happens. But the other features feel sufficiently specific to be in their own web-features files.

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 opted not to create separate features for pre-2015 media queries, thinking it would be easy to split if users requested it, but I could go either way.

features/prefers-color-scheme.yml Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@jamesnw jamesnw left a comment

Choose a reason for hiding this comment

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

Thanks for the review! I have a few comments/questions, and resolved all suggestions I accepted.

@@ -0,0 +1,6 @@
name: color-gamut media feature
description: The `color-gamut` media feature sets styles based on the colors a device can display. Values are `srgb` if the device can display at least sRGB, `p3` if the device can display at least Display P3, and `rec2020` if the device can display at least REC. 2020.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Based on conversations with spec authors and implementors, this should be a rather stable list. There are privacy issues with going more granular, and it's unlikely that gamuts larger than rec2020 will be needed soon.

@@ -0,0 +1,7 @@
name: display-mode media feature
description: The `display-mode` CSS media feature sets styles based on whether the user's browser is in `fullscreen`, `standalone`, `minimal-ui,` `browser`, or `picture-in-picture` mode.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point on "web page". I removed the example because it was over the 300 character limit, and it seemed more about a PWA feature than about the media query itself, but am not opposed to an example here.

@@ -0,0 +1,6 @@
name: color-gamut media feature
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 struggled on the naming for this. I think media feature is perhaps more spec language than developer language, but I think your addition to media-queries makes sense.

For the id, I'm realizing that I was essentially adding the group to the file name, with the side benefit of being able to see them together in the file list. Would you recommend media-feature-color-gamut, color-gamut-media-feature, or just color-gamut?

@@ -0,0 +1,6 @@
name: inverted-colors media feature
description: The `inverted-colors` CSS media feature sets styles based on whether the user has inverted all colors.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, it's an OS accessibility option.

@@ -0,0 +1,9 @@
name: Overflow media features
description: The `overflow-block` and `overflow-inline` CSS media features set styles based on how a user's device will show content that is larger than the screen. Options are `none` (for instance, a billboard), `scroll` (for instance, a laptop), or `paged` (for instance, a printer).
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 was confused by "container element" due to the overloaded term "element", so I used MDN's language around the initial containing block, "viewport or page area".

I'm ok not having an example for none here, but the idea is, if there is overflowing content on a webpage displayed on a billboard, there is no way a viewer can access the overflowed content.

features/media-queries-prefers-reduced-data.yml Outdated Show resolved Hide resolved
@@ -0,0 +1,18 @@
name: Media queries
description: CSS Media queries allow you to provide different styles based on the user's device and settings. For example, `@media (width <= 700px) and (orientation:portrait)` selects screens less than 700 pixels wide and also are taller than they are wide.
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 took the first part of your suggestion, but replaced the example with the recommendation for describing media features here. I ran over the character limit otherwise.

Comment on lines +15 to +16
- css.at-rules.media.orientation
- css.at-rules.media.aspect-ratio
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 opted not to create separate features for pre-2015 media queries, thinking it would be easy to split if users requested it, but I could go either way.

features/interaction.yml Outdated Show resolved Hide resolved
features/prefers-contrast.yml Outdated Show resolved Hide resolved
@@ -0,0 +1,6 @@
name: prefers-reduced-data media query
description: The `prefers-reduced-data` CSS media query detects whether the user has a preference for using less internet traffic. For example, you can use this media query to avoid loading large font files and use a system font instead.
Copy link
Collaborator

Choose a reason for hiding this comment

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

me dodging having to make a decision about Internet or internet:

Suggested change
description: The `prefers-reduced-data` CSS media query detects whether the user has a preference for using less internet traffic. For example, you can use this media query to avoid loading large font files and use a system font instead.
description: The `prefers-reduced-data` CSS media query detects whether the user has a preference for using less network traffic. For example, you can use this media query to avoid loading large font files and use a system font instead.

features/prefers-reduced-motion.yml Outdated Show resolved Hide resolved
features/prefers-reduced-motion.yml Outdated Show resolved Hide resolved
features/prefers-reduced-transparency.yml Outdated Show resolved Hide resolved
# firefox_android: "8"
# safari: "16"
# safari_ios: "16"
- css.at-rules.media.resolution
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm very suspicious of this data. MDN says a unit is required. I think this whole feature is actually busted in Safari, or at very least it hasn't been tested recently. See https://bugs.webkit.org/show_bug.cgi?id=78087

I suspect we'll want to land the rest of this, but split this feature into its own PR while we fix BCD.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved to #1798

features/scripting.yml Outdated Show resolved Hide resolved
features/scripting.yml Show resolved Hide resolved
features/update.yml Outdated Show resolved Hide resolved
@jamesnw jamesnw requested a review from ddbeck September 18, 2024 16:12
Copy link
Collaborator

@ddbeck ddbeck left a comment

Choose a reason for hiding this comment

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

Thank you!

@ddbeck ddbeck merged commit 57565b9 into web-platform-dx:main Sep 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature definition Creating or defining new features or groups of features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants