focus-pro
Version:
focus-pro 中台前端组件库
75 lines (73 loc) • 4.1 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import { useContext } from 'react';
import classnames from 'classnames';
import { forwardRef } from 'react';
import { globalCtx } from "../ConfigProvider";
import "./index.module.less";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var Comment = function Comment(props, ref) {
var className = props.className,
style = props.style,
author = props.author,
afterAuthor = props.afterAuthor,
avatar = props.avatar,
content = props.content,
datetime = props.datetime,
actions = props.actions,
_props$align = props.align,
align = _props$align === void 0 ? 'left' : _props$align,
children = props.children;
var _ref = useContext(globalCtx),
prefixCls = _ref.prefixCls,
dark = _ref.dark,
globalColor = _ref.globalColor;
var classFirstName = dark ? 'focus-comment dark-mode' : 'focus-comment';
var classNames = classnames(prefixCls, classFirstName, className, _defineProperty({}, "date-".concat(align), align));
var commentStyle = _objectSpread(_objectSpread({}, style), {}, {
backgroundColor: globalColor // 将 globalColor 应用到背景颜色
});
return (
/*#__PURE__*/
// <ProConfigProvider>
_jsxs("div", {
className: classNames,
style: commentStyle,
ref: ref,
children: [/*#__PURE__*/_jsx("div", {
className: "avatar",
children: avatar
}), /*#__PURE__*/_jsxs("div", {
className: "comment-content",
children: [/*#__PURE__*/_jsxs("div", {
className: "comment-content-header",
children: [/*#__PURE__*/_jsxs("div", {
className: "author",
children: [/*#__PURE__*/_jsx("span", {
children: author
}), /*#__PURE__*/_jsx("div", {
className: "extra-header",
children: afterAuthor
})]
}), /*#__PURE__*/_jsx("span", {
className: "date-time",
children: datetime
})]
}), /*#__PURE__*/_jsx("div", {
className: "content",
children: content
}), /*#__PURE__*/_jsx("div", {
className: "comment-content-actions",
children: actions
}), children]
})]
})
// </ProConfigProvider>
);
};
export default /*#__PURE__*/forwardRef(Comment);