UNPKG

@blueprintjs/core

Version:
46 lines 1.71 kB
/* * Copyright 2017 Palantir Technologies, Inc. All rights reserved. * * Licensed under the terms of the LICENSE file distributed with this project. */ import classNames from "classnames"; import * as React from "react"; import { Classes, DISPLAYNAME_PREFIX, Intent } from "../../common"; import { Icon } from "../../index"; import { H4 } from "../html/html"; export class Callout extends React.PureComponent { render() { const { className, children, icon, intent, title, ...htmlProps } = this.props; const iconName = this.getIconName(icon, intent); const classes = classNames(Classes.CALLOUT, Classes.intentClass(intent), { [Classes.CALLOUT_ICON]: iconName != null }, className); return (React.createElement("div", Object.assign({ className: classes }, htmlProps), iconName && React.createElement(Icon, { icon: iconName, iconSize: Icon.SIZE_LARGE }), title && React.createElement(H4, null, title), children)); } getIconName(icon, intent) { // 1. no icon if (icon === null) { return undefined; } // 2. defined iconName prop if (icon !== undefined) { return icon; } // 3. default intent icon switch (intent) { case Intent.DANGER: return "error"; case Intent.PRIMARY: return "info-sign"; case Intent.WARNING: return "warning-sign"; case Intent.SUCCESS: return "tick"; default: return undefined; } } } Callout.displayName = `${DISPLAYNAME_PREFIX}.Callout`; //# sourceMappingURL=callout.js.map