import React, { Component } from "react";
export default class Admonition extends Component {
render() {
const { type, iconType, title, children, addIfmClass } = this.props;
let wrapperClasses = ["admonition", `admonition-${type}`];
if (addIfmClass) {
wrapperClasses.push("alert")
wrapperClasses.push(`alert--${ifmClassMap[type]}`)
}
return (
{returnIcon(type, iconType)}
{title || type}
{children}
);
}
}
Admonition.defaultProps = {
addIfmClass: true,
};
const ifmClassMap = {
warning: "danger",
important: "info",
caution: "warning",
tip: "success",
note: "secondary",
};
var emojisMap = {
warning: "⚠️",
important: "❗️",
caution: "🔥",
tip: "💡",
note: "ℹ️"
};
/**
* Octicons Icons by GitHub released under MIT License
* https://github.com/primer/octicons/
*/
const svgMap = {
warning: (
),
important: (
),
caution: (
),
tip: (
),
note: (
),
};
function returnIcon(admonition, iconType) {
if (iconType === "emoji") {
return emojisMap[admonition];
}
return svgMap[admonition];
}