@neo4j-ndl/react
Version:
React implementation of Neo4j Design System
74 lines • 3.59 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Callout = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const react_1 = __importDefault(require("react"));
const defaultImports_1 = require("../_common/defaultImports");
const icons_1 = require("../icons");
const typography_1 = require("../typography");
/**
*
*
* Helpers
*
*
*/
const getStatusIcon = (iconType) => {
let iconComponent;
switch (iconType) {
case 'important':
iconComponent = ((0, jsx_runtime_1.jsx)(icons_1.ExclamationTriangleIconOutline, { className: "ndl-callout-important-icon" }));
break;
case 'example':
iconComponent = ((0, jsx_runtime_1.jsx)(icons_1.BeakerIconOutline, { className: "ndl-callout-example-icon" }));
break;
case 'tip':
iconComponent = (0, jsx_runtime_1.jsx)(icons_1.LightBulbIconOutline, { className: "ndl-callout-tip-icon" });
break;
case 'note':
default:
iconComponent = ((0, jsx_runtime_1.jsx)(icons_1.InformationCircleIconOutline, { className: "ndl-callout-note-icon" }));
}
return (0, jsx_runtime_1.jsx)("div", { className: "ndl-callout-icon", children: iconComponent });
};
/**
*
*
* Callout Component
*
*
*/
exports.Callout = react_1.default.forwardRef(function Callout({ as, type = 'note', header = null, children, description = null, className, style, htmlAttributes, }, ref) {
const Component = as || 'div';
const classes = (0, defaultImports_1.classNames)('ndl-callout', className, {
'ndl-callout-note': type === 'note',
'ndl-callout-important': type === 'important',
'ndl-callout-example': type === 'example',
'ndl-callout-tip': type === 'tip',
});
return ((0, jsx_runtime_1.jsxs)(Component, Object.assign({ ref: ref, className: classes, style: style }, htmlAttributes, { children: [(0, jsx_runtime_1.jsx)("div", { className: "ndl-callout-rectangle" }), (0, jsx_runtime_1.jsxs)("div", { className: "ndl-callout-wrapper", children: [getStatusIcon(type), (0, jsx_runtime_1.jsxs)("div", { className: "ndl-callout-content", children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "h6", className: "ndl-callout-title", children: type.toUpperCase() }), header && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "subheading-medium", className: "ndl-callout-header", children: header })), (description || children) && ((0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-medium", className: "ndl-callout-description", children: children || description }))] })] })] })));
});
//# sourceMappingURL=Callout.js.map