-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Toast component in option page to display success or error message
- Loading branch information
Showing
3 changed files
with
309 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
let h = React.createElement; | ||
|
||
class Toast extends React.Component { | ||
render() { | ||
const {variant, title, message, onClose} = this.props; | ||
|
||
// Construct the theme and icon class based on the variant | ||
const themeClass = `slds-theme_${variant}`; | ||
const iconClass = `slds-icon-utility-${variant === "success" ? "success" : variant === "error" ? "error" : "info"}`; | ||
|
||
return h("div", {className: "slds-notify_container"}, | ||
h("div", { | ||
className: `slds-notify slds-notify_toast ${themeClass}`, | ||
role: "status" | ||
}, | ||
h("span", {className: "slds-assistive-text"}, title), | ||
h("span", { | ||
className: `slds-icon_container ${iconClass} slds-m-right_small slds-no-flex slds-align-top`, | ||
title: "Description of icon when needed" | ||
}, | ||
h("svg", {className: "slds-icon slds-icon_small", "aria-hidden": "true"}, | ||
h("use", {xlinkHref: `symbols.svg#${variant === "success" ? "success" : variant === "error" ? "error" : "info"}`}) | ||
) | ||
), | ||
h("div", {className: "slds-notify__content"}, | ||
h("h2", {className: "slds-text-heading_small"}, title), | ||
h("p", {}, message) | ||
), | ||
h("div", {className: "slds-notify__close"}, | ||
h("button", { | ||
className: "slds-button slds-button_icon slds-button_icon-inverse", | ||
title: "Close", | ||
onClick: onClose | ||
}, | ||
h("svg", {className: "slds-button__icon slds-button__icon_large", "aria-hidden": "true"}, | ||
h("use", {xlinkHref: "symbols.svg#close"}) | ||
), | ||
h("span", {className: "slds-assistive-text"}, "Close") | ||
) | ||
) | ||
) | ||
); | ||
} | ||
} | ||
export default Toast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters