chowa
Version:
UI component library based on React
39 lines (38 loc) • 1.3 kB
JavaScript
/**
* @license chowa v1.1.3
*
* Copyright (c) Chowa Techonlogies Co.,Ltd.(http://www.chowa.cn).
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const PropTypes = require("prop-types");
const utils_1 = require("../utils");
const classNames = require("classnames");
const prism = require("prismjs");
const Code = (props) => {
const { className, style, lang, children } = props;
const comonentClass = classNames({
[utils_1.preClass('typography-code')]: true,
[className]: utils_1.isExist(className)
});
return (React.createElement("pre", Object.assign({ className: comonentClass, style: style }, utils_1.omitProps(props, ['className', 'style', 'lang'])),
React.createElement("code", { ref: (ele) => {
if (!ele) {
return;
}
prism.highlightElement(ele);
}, className: `language-${lang}` }, children)));
};
Code.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
lang: PropTypes.string
};
Code.defaultProps = {
lang: 'javascript'
};
exports.default = Code;