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

[AppBar] Add support for position="sticky" #10090

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pages/api/app-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ filename: /src/AppBar/AppBar.js
| <span style="color: #31a148">children *</span> | node | | The content of the component. |
| classes | object | | Useful to extend the style applied to components. |
| color | enum:&nbsp;'inherit'&nbsp;&#124;<br>&nbsp;'primary'&nbsp;&#124;<br>&nbsp;'secondary'&nbsp;&#124;<br>&nbsp;'default'<br> | 'primary' | The color of the component. It's using the theme palette when that makes sense. |
| position | enum:&nbsp;'static'&nbsp;&#124;<br>&nbsp;'fixed'&nbsp;&#124;<br>&nbsp;'absolute'<br> | 'fixed' | The positioning type. |
| position | enum:&nbsp;'fixed'&nbsp;&#124;<br>&nbsp;'absolute'&nbsp;&#124;<br>&nbsp;'sticky'&nbsp;&#124;<br>&nbsp;'static'<br> | 'fixed' | The positioning type. The behavior of the different options is described [here](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning). Note: `sticky` is not universally supported and will fall back to `static` when unavailable. |

Any other properties supplied will be [spread to the root element](/guides/api#spread).

Expand All @@ -26,6 +26,7 @@ This property accepts the following keys:
- `root`
- `positionFixed`
- `positionAbsolute`
- `positionSticky`
- `positionStatic`
- `colorDefault`
- `colorPrimary`
Expand Down
3 changes: 2 additions & 1 deletion src/AppBar/AppBar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { PaperProps, PaperClassKey } from '../Paper/Paper';

export interface AppBarProps extends StandardProps<PaperProps, AppBarClassKey> {
color?: PropTypes.Color;
position?: 'static' | 'fixed' | 'absolute';
position?: 'fixed' | 'absolute' | 'sticky' | 'static';
}

export type AppBarClassKey =
| PaperClassKey
| 'positionFixed'
| 'positionAbsolute'
| 'positionSticky'
| 'positionStatic'
| 'colorDefault'
| 'colorPrimary'
Expand Down
12 changes: 10 additions & 2 deletions src/AppBar/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ export const styles = theme => {
left: 'auto',
right: 0,
},
positionSticky: {
position: 'sticky',
top: 0,
left: 'auto',
right: 0,
},
positionStatic: {
position: 'static',
flexShrink: 0,
Expand Down Expand Up @@ -89,9 +95,11 @@ AppBar.propTypes = {
*/
color: PropTypes.oneOf(['inherit', 'primary', 'secondary', 'default']),
/**
* The positioning type.
* The positioning type. The behavior of the different options is described
* [here](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Positioning).
* Note: `sticky` is not universally supported and will fall back to `static` when unavailable.
*/
position: PropTypes.oneOf(['static', 'fixed', 'absolute']),
position: PropTypes.oneOf(['fixed', 'absolute', 'sticky', 'static']),
};

AppBar.defaultProps = {
Expand Down