Skip to content

docs(cdk/layout): better explain how layout breakpoints work #22821

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

Merged
merged 1 commit into from
May 27, 2021

Conversation

jelbourn
Copy link
Member

I'm copying the actual breakpoints here for reference because it's much
easier to parse than looking at the archived Material Design site.

I'm also working on a follow-up to add an overview example for
BreakpointObserver.

Fixes #11788

@jelbourn jelbourn added docs This issue is related to documentation merge safe target: patch This PR is targeted for the next patch release area: cdk/layout labels May 26, 2021
@jelbourn jelbourn requested a review from andrewseguin May 26, 2021 23:18
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 26, 2021
size ranges between breakpoints correspond to different standard screen sizes.

`BreakpointObserver` lets you evaluate media queries to determine the current screen size and
react to changes when the viewport size changes and crosses a breakpoint.
Copy link
Member

@crisbeto crisbeto May 27, 2021

Choose a reason for hiding this comment

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

Should we mention that the BreakpointObserver isn't limited to just screen size queries? You can use it for things like detecting dark mode or reduced motion.

Copy link
Member Author

Choose a reason for hiding this comment

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

My thinking is that those things are unlikely to change in the middle of the app running, so you could just use MediaMatcher directly.

```ts
const isSmallScreen = breakpointObserver.isMatched('(max-width: 599px)');
```

#### React to changes to the viewport
The `observe` method is used to get an observable stream that will emit whenever one of the given
media queries would have a different result.
You can use the `observe` method to get an observable stream emits whenever the viewport size
Copy link
Member

Choose a reason for hiding this comment

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

observable stream emits -> observable stream that emits

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

The `observe` method is used to get an observable stream that will emit whenever one of the given
media queries would have a different result.
You can use the `observe` method to get an observable stream emits whenever the viewport size
changes and crosses a breakpoint.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this should say just "crosses a breakpoint"? It isn't going to fire on any viewport resize.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

I'm copying the actual breakpoints here for reference because it's much
easier to parse than looking at the archived Material Design site.

I'm also working on a follow-up to add an overview example for
`BreakpointObserver`.

Fixes angular#11788
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label May 27, 2021
@mmalerba mmalerba merged commit f68a1dc into angular:master May 27, 2021
mmalerba pushed a commit that referenced this pull request May 27, 2021
I'm copying the actual breakpoints here for reference because it's much
easier to parse than looking at the archived Material Design site.

I'm also working on a follow-up to add an overview example for
`BreakpointObserver`.

Fixes #11788

(cherry picked from commit f68a1dc)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: cdk/layout cla: yes PR author has agreed to Google's Contributor License Agreement docs This issue is related to documentation target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better explaination of Breakpoints
3 participants