Skip to content
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
42 changes: 42 additions & 0 deletions packages/patternfly-4/react-core/src/components/Alert/Alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,47 @@ propComponents: ['Alert', 'AlertActionCloseButton', 'AlertActionLink']
import { Alert, AlertActionLink, AlertActionCloseButton } from '@patternfly/react-core';
import './examples/alert.scss';

## Default alert
```js
import React from 'react';
import { Alert, AlertActionLink, AlertActionCloseButton } from '@patternfly/react-core';

class DefaultAlert extends React.Component {
constructor(props) {
super(props);
this.state = { alertOneVisible: true, alertTwoVisible: true };
this.hideAlertOne = () => this.setState({ alertOneVisible: false });
this.hideAlertTwo = () => this.setState({ alertTwoVisible: false });
}

render() {
const { alertOneVisible, alertTwoVisible } = this.state;
return (
<React.Fragment>
{alertOneVisible && (
<Alert
variant="default"
title="Default alert title"
action={<AlertActionCloseButton onClose={this.hideAlertOne} />}
>
Info alert description. <a href="#">This is a link.</a>
</Alert>
)}
{alertTwoVisible && (
<Alert
variant="default"
title="Default alert title"
action={<AlertActionCloseButton onClose={this.hideAlertTwo} />}
/>
)}
<Alert variant="default" title="Default alert title" action={<AlertActionLink>Action Button</AlertActionLink>} />
<Alert variant="default" title="Default alert title" />
</React.Fragment>
);
}
}
```

## Info alert
```js
import React from 'react';
Expand Down Expand Up @@ -185,6 +226,7 @@ class InlineAlert extends React.Component {
render() {
return (
<React.Fragment>
<Alert variant="default" isInline title="Default inline alert title"/>
<Alert variant="info" isInline title="Info inline alert title"/>
<Alert variant="success" isInline title="Success inline alert title" />
<Alert variant="warning" isInline title="Warning inline alert title" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ export enum AlertVariant {
success = 'success',
danger = 'danger',
warning = 'warning',
info = 'info'
info = 'info',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

feel like these should be in alphabetical order ...

default = 'default'
}

export interface AlertProps
extends Omit<React.HTMLProps<HTMLDivElement>, 'action' | 'title'> {
/** Adds Alert variant styles */
variant?: 'success' | 'danger' | 'warning' | 'info';
variant?: 'success' | 'danger' | 'warning' | 'info' | 'default';
/** Flag to indicate if the Alert is inline */
isInline?: boolean;
/** Title of the Alert */
Expand Down Expand Up @@ -51,7 +52,7 @@ export const Alert: React.FunctionComponent<AlertProps> = ({
</React.Fragment>
);

const customClassName = css(styles.alert, isInline && styles.modifiers.inline, getModifier(styles, variant, styles.modifiers.info), className);
const customClassName = css(styles.alert, isInline && styles.modifiers.inline, (variant !== AlertVariant.default ) && getModifier(styles, variant, styles.modifiers.info), className);

return (
<div {...props} className={customClassName} aria-label={ariaLabel}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ import {
CheckCircleIcon,
ExclamationCircleIcon,
ExclamationTriangleIcon,
InfoCircleIcon
InfoCircleIcon,
BellIcon
} from '@patternfly/react-icons';

export const variantIcons = {
success: CheckCircleIcon,
danger: ExclamationCircleIcon,
warning: ExclamationTriangleIcon,
info: InfoCircleIcon
info: InfoCircleIcon,
default: BellIcon
};

export interface AlertIconProps extends React.HTMLProps<HTMLDivElement> {
/** variant */
variant: 'success' | 'danger' | 'warning' | 'info';
variant: 'success' | 'danger' | 'warning' | 'info' | 'default';
/** className */
className?: string;
};
Expand Down
Loading