Skip to content

Commit

Permalink
removes AlertIcon for simpler API
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitropoulos committed Dec 13, 2019
1 parent a8f3a38 commit bb5d4c6
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 147 deletions.
7 changes: 0 additions & 7 deletions docs/pages/api/alert-icon.js

This file was deleted.

47 changes: 0 additions & 47 deletions docs/pages/api/alert-icon.md

This file was deleted.

3 changes: 3 additions & 0 deletions docs/pages/api/alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">startIcon</span> | <span class="prop-type">node</span> | | Element placed before the children. |
| <span class="prop-name">color</span> | <span class="prop-type">'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'default'<br>&#124;&nbsp;'error'</span> | | |
| <span class="prop-name">elevation</span> | <span class="prop-type">number</span> | | |
| <span class="prop-name">variant</span> | <span class="prop-type">'text'<br>&#124;&nbsp;'filled'<br>&#124;&nbsp;'outline'<br>&#124;&nbsp;'banner'</span> | | |
Expand All @@ -39,6 +40,8 @@ Any other props supplied will be provided to the root element (native element).
- Style sheet details:

- `root`
- `alertContent`
- `startIcon`

You can override the style of the component thanks to one of these customization points:

Expand Down
7 changes: 4 additions & 3 deletions docs/src/pages/components/alert/SimpleAlert.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { Button } from '@material-ui/core';
import InfoIcon from '@material-ui/icons/Info';
import {
Alert,
AlertIcon,
AlertTitle,
AlertClose,
AlertDescription,
Expand All @@ -11,8 +11,9 @@ import {

export default function SimpleAlert() {
return (
<Alert>
<AlertIcon />
<Alert
startIcon={<InfoIcon />}
>
<AlertTitle>Sorry, results couldn&apos;t be loaded</AlertTitle>
<AlertClose />
<AlertDescription>
Expand Down
8 changes: 5 additions & 3 deletions docs/src/pages/components/alert/SimpleAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import { Button } from '@material-ui/core';
import { Alert, AlertIcon, AlertTitle, AlertClose, AlertDescription, AlertActions } from '@material-ui/lab';
import { Alert, AlertTitle, AlertClose, AlertDescription, AlertActions } from '@material-ui/lab';
import InfoIcon from '@material-ui/icons/Info';

export default function SimpleAlert() {
return (
<Alert>
<AlertIcon />
<Alert
startIcon={<InfoIcon />}
>
<AlertTitle>
Sorry, results couldn&apos;t be loaded
</AlertTitle>
Expand Down
35 changes: 32 additions & 3 deletions packages/material-ui-lab/src/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,41 @@ import { withStyles } from '@material-ui/core/styles';

export const styles = () => ({
root: {
padding: '1em 4em',
padding: '1em 4em 1em 1em',
border: '1px solid black',
position: 'relative',
display: 'flex',
},
alertContent: {
display: 'flex',
flexDirection: 'column',
},
startIcon: {
marginTop: '0.25em',
marginRight: '1em',
},
});

const Alert = React.forwardRef(function Alert(props, ref) {
const { children, classes, className } = props;
const {
children,
classes,
className,
startIcon: startIconProp,
} = props;

const startIcon = startIconProp && (
<span className={clsx(classes.startIcon)}>
{startIconProp}
</span>
);

return (
<div className={clsx(classes.root, className)} ref={ref}>
{children}
{startIcon}
<div className={clsx(classes.alertContent, className)}>
{children}
</div>
</div>
);
});
Expand All @@ -37,6 +61,11 @@ Alert.propTypes = {
*/
className: PropTypes.string,

/**
* Element placed before the children.
*/
startIcon: PropTypes.node,

/*
* Main color for the Alert, picked from theme palette
*/
Expand Down
11 changes: 0 additions & 11 deletions packages/material-ui-lab/src/AlertIcon/AlertIcon.d.ts

This file was deleted.

38 changes: 0 additions & 38 deletions packages/material-ui-lab/src/AlertIcon/AlertIcon.js

This file was deleted.

26 changes: 0 additions & 26 deletions packages/material-ui-lab/src/AlertIcon/AlertIcon.test.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/material-ui-lab/src/AlertIcon/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/material-ui-lab/src/AlertIcon/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/material-ui-lab/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ export * from './AlertClose';
export { default as AlertDescription } from './AlertDescription';
export * from './AlertDescription';

export { default as AlertIcon } from './AlertIcon';
export * from './AlertIcon';

export { default as AlertTitle } from './AlertTitle';
export * from './AlertTitle';

Expand Down
3 changes: 0 additions & 3 deletions packages/material-ui-lab/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ export * from './AlertClose';
export { default as AlertDescription } from './AlertDescription';
export * from './AlertDescription';

export { default as AlertIcon } from './AlertIcon';
export * from './AlertIcon';

export { default as AlertTitle } from './AlertTitle';
export * from './AlertTitle';

Expand Down

0 comments on commit bb5d4c6

Please sign in to comment.