Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 715e001

Browse files
authored
Merge pull request #1 from Azure/master
sync
2 parents f797181 + 58e7d3a commit 715e001

File tree

5 files changed

+26
-35
lines changed

5 files changed

+26
-35
lines changed

lib/components/Alert/Alert.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ______________________________________________________________________________
4040

4141
```jsx
4242
let onClose = () => alert('Alert close button pushed!');
43-
<Alert icon='error' type={2} onClose={onClose}>This is an error alert with a close button! pp This is an error alert with a close button! This is an error alert with a close button! This is an error alert with a close button!</Alert>
43+
<Alert icon='error' type={2} onClose={onClose} attr={{closeButtonTitle: 'dismiss'}}>This is an error alert with a close button! pp This is an error alert with a close button! This is an error alert with a close button! This is an error alert with a close button!</Alert>
4444
```
4545

4646
#### Multiline alert

lib/components/Alert/Alert.scss

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,12 @@ $icon-margin-top: 3px;
4545
overflow: hidden;
4646
text-overflow: ellipsis;
4747
white-space: nowrap;
48-
48+
4949
& + .close {
5050
margin-left: 2*$grid-size;
5151
}
5252
}
5353

54-
.alert-close {
55-
flex: 0 0 4*$grid-size;
56-
margin-top: 1.5*$grid-size;
57-
margin-left: auto;
58-
margin-right: 2*$grid-size;
59-
line-height: $line-height-close;
60-
cursor: pointer;
61-
}
62-
6354
&.alert-fixed {
6455
width: 71*$grid-size;
6556
}

lib/components/Alert/Alert.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as React from 'react';
22
import * as classNames from 'classnames/bind';
33
import {DivProps, Elements as Attr} from '../../Attributes';
44
import {Icon, IconSize, IconAttributes} from '../Icon';
5+
import { ActionTriggerAttributes } from '../ActionTrigger/ActionTrigger';
6+
import ActionTriggerButton from '../ActionTrigger/ActionTriggerButton';
57
const css = classNames.bind(require('./Alert.scss'));
68

79
export enum AlertType {
@@ -16,31 +18,31 @@ export interface AlertAttributes {
1618
container?: DivProps;
1719
icon?: IconAttributes;
1820
contents?: DivProps;
19-
closeIcon?: IconAttributes;
21+
closeButtonTitle?: string;
2022
}
2123

2224
export interface AlertProps extends React.Props<AlertComponentType> {
2325
/** Icon name (from Segoe UI MDL font) */
2426
icon?: string;
2527
/**
2628
* Alert type described using `AlertType` enum
27-
*
29+
*
2830
* (`AlertType.[Information | Warning | Error]`)
2931
*/
3032
type?: AlertType;
31-
32-
/**
33+
34+
/**
3335
* Callback for close button
34-
*
36+
*
3537
* (If empty, the close button is not displayed)
36-
*/
38+
*/
3739
onClose?: () => void;
38-
40+
3941
/** Fixed width (284 pixels) */
4042
fixed?: boolean;
4143
/**
4244
* Alert displays multiple lines
43-
*
45+
*
4446
* (By default, alerts only show one line with ellipsis overflow)
4547
*/
4648
multiline?: boolean;
@@ -53,7 +55,7 @@ export interface AlertProps extends React.Props<AlertComponentType> {
5355

5456
/**
5557
* Alert showing Information, Warning, or Error with text, icon, and optional close button
56-
*
58+
*
5759
* @param props Control properties (defined in `AlertProps` interface)
5860
*/
5961
export const Alert: React.StatelessComponent<AlertProps> = (props: AlertProps) => {
@@ -79,7 +81,7 @@ export const Alert: React.StatelessComponent<AlertProps> = (props: AlertProps) =
7981

8082
const iconClassName = css('alert-icon');
8183
const icon = <Icon
82-
className={iconClassName}
84+
className={iconClassName}
8385
size={IconSize.xsmall}
8486
icon={iconName}
8587
attr={props.attr.icon}
@@ -97,17 +99,16 @@ export const Alert: React.StatelessComponent<AlertProps> = (props: AlertProps) =
9799

98100
let close;
99101
if (props.onClose) {
100-
const closeClassName = css('alert-close');
101-
const closeProps = {
102-
...props.attr.closeIcon,
103-
container: {onClick: props.onClose}
104-
};
102+
const closeButtonTitle = props.attr && props.attr.closeButtonTitle ? props.attr.closeButtonTitle : undefined;
105103
close = (
106-
<Icon
107-
className={closeClassName}
108-
size={IconSize.xsmall}
109-
icon='cancelLegacy'
110-
attr={closeProps}
104+
<ActionTriggerButton
105+
onClick={props.onClose}
106+
icon={'cancelLegacy'}
107+
attr={{
108+
button: {
109+
title: closeButtonTitle
110+
}
111+
}}
111112
/>
112113
);
113114
}
@@ -126,8 +127,7 @@ Alert.defaultProps = {
126127
attr: {
127128
container: {},
128129
icon: {},
129-
contents: {},
130-
closeIcon: {},
130+
contents: {}
131131
}
132132
};
133133

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@microsoft/azure-iot-ux-fluent-controls",
3-
"version": "1.0.1",
3+
"version": "2.0.0",
44
"description": "Azure IoT Fluent React Controls",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",

0 commit comments

Comments
 (0)