Skip to content

Commit

Permalink
[Snackbar] Fix anchorOrigin types (#12316)
Browse files Browse the repository at this point in the history
* remove number from snackbar anchorOrigin propTypes and TS declarations

* update Snackbar API docs

* prettier updates
  • Loading branch information
nmchaves authored and oliviertassinari committed Jul 28, 2018
1 parent aa27b0d commit 59759c2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StandardProps } from '..';
import { TypographyProps } from '../Typography';

export interface DialogContentTextProps
extends StandardProps<TypographyProps, DialogContentTextClassKey> {}
extends StandardProps<TypographyProps, DialogContentTextClassKey> {}

export type DialogContentTextClassKey = 'root';

Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Snackbar/Snackbar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { SnackbarContentProps } from '../SnackbarContent';
import { TransitionHandlerProps, TransitionProps } from '../transitions/transition';

export type SnackbarOrigin = {
horizontal: 'left' | 'center' | 'right' | number;
vertical: 'top' | 'center' | 'bottom' | number;
horizontal: 'left' | 'center' | 'right';
vertical: 'top' | 'center' | 'bottom';
};

export interface SnackbarProps
Expand Down
8 changes: 2 additions & 6 deletions packages/material-ui/src/Snackbar/Snackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,8 @@ Snackbar.propTypes = {
* The anchor of the `Snackbar`.
*/
anchorOrigin: PropTypes.shape({
horizontal: PropTypes.oneOfType([
PropTypes.number,
PropTypes.oneOf(['left', 'center', 'right']),
]).isRequired,
vertical: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['top', 'center', 'bottom'])])
.isRequired,
horizontal: PropTypes.oneOf(['left', 'center', 'right']).isRequired,
vertical: PropTypes.oneOf(['top', 'center', 'bottom']).isRequired,
}),
/**
* The number of milliseconds to wait before automatically calling the
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/test/typescript/components.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const DialogTest = () => {
</List>
</div>
<DialogContent>
<DialogContentText variant='body2' color='primary'>
<DialogContentText variant="body2" color="primary">
Some text
</DialogContentText>
</DialogContent>
Expand Down
2 changes: 1 addition & 1 deletion pages/api/snackbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ title: Snackbar API
| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">action</span> | <span class="prop-type">node |   | The action to display. |
| <span class="prop-name">anchorOrigin</span> | <span class="prop-type">{ horizontal: union:&nbsp;number&nbsp;&#124;<br>&nbsp;enum:&nbsp;'left'&nbsp;&#124;<br>&nbsp;'center'&nbsp;&#124;<br>&nbsp;'right'<br><br>, vertical: union:&nbsp;number&nbsp;&#124;<br>&nbsp;enum:&nbsp;'top'&nbsp;&#124;<br>&nbsp;'center'&nbsp;&#124;<br>&nbsp;'bottom'<br><br> } | <span class="prop-default">{ vertical: 'bottom', horizontal: 'center',}</span> | The anchor of the `Snackbar`. |
| <span class="prop-name">anchorOrigin</span> | <span class="prop-type">{ horizontal: enum:&nbsp;'left'&nbsp;&#124;<br>&nbsp;'center'&nbsp;&#124;<br>&nbsp;'right'<br>, vertical: enum:&nbsp;'top'&nbsp;&#124;<br>&nbsp;'center'&nbsp;&#124;<br>&nbsp;'bottom'<br> } | <span class="prop-default">{ vertical: 'bottom', horizontal: 'center',}</span> | The anchor of the `Snackbar`. |
| <span class="prop-name">autoHideDuration</span> | <span class="prop-type">number |   | The number of milliseconds to wait before automatically calling the `onClose` function. `onClose` should then set the state of the `open` prop to hide the Snackbar. This behavior is disabled by default with the `null` value. |
| <span class="prop-name">children</span> | <span class="prop-type">element |   | If you wish the take control over the children of the component you can use this property. When used, you replace the `SnackbarContent` component with the children. |
| <span class="prop-name">classes</span> | <span class="prop-type">object |   | Override or extend the styles applied to the component. See [CSS API](#css-api) below for more details. |
Expand Down

0 comments on commit 59759c2

Please sign in to comment.