@ant-design/compatible
Version:
Ant Design v3 to v4 compatible package
143 lines (126 loc) • 6.42 kB
JavaScript
"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useStyle;
var React = _interopRequireWildcard(require("react"));
var _cssinjs = require("@ant-design/cssinjs");
var _antd = require("antd");
var _style = require("antd/lib/style");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// ============================== Export ==============================
var genSharedButtonStyle = function genSharedButtonStyle(token) {
var _objectSpread2;
var componentCls = token.componentCls,
colorBgContainer = token.colorBgContainer,
fontSize = token.fontSize,
fontSizeSM = token.fontSizeSM,
padding = token.padding,
paddingXS = token.paddingXS,
marginSM = token.marginSM,
marginXXS = token.marginXXS,
controlHeight = token.controlHeight,
lineHeightSM = token.lineHeightSM,
colorText = token.colorText,
colorTextSecondary = token.colorTextSecondary,
colorTextTertiary = token.colorTextTertiary,
motionDurationSlow = token.motionDurationSlow;
return _defineProperty({}, componentCls, _objectSpread(_objectSpread({}, (0, _style.resetComponent)(token)), {}, (_objectSpread2 = {
position: 'relative',
backgroundColor: colorBgContainer
}, _defineProperty(_objectSpread2, "".concat(componentCls, "-inner"), {
display: 'flex',
paddingBlock: padding
}), _defineProperty(_objectSpread2, "".concat(componentCls, "-avatar"), {
position: 'relative',
flexShrink: 0,
marginInlineEnd: marginSM,
cursor: 'pointer',
img: {
width: controlHeight,
height: controlHeight,
borderRadius: '50%'
}
}), _defineProperty(_objectSpread2, "".concat(componentCls, "-content"), {
position: 'relative',
flex: 'auto',
minWidth: 0,
wordWrap: 'break-word',
'&-author': {
display: 'flex',
flexWrap: 'wrap',
justifyContent: 'flex-start',
marginBottom: marginXXS,
'& > a, & > span': {
paddingInlineEnd: paddingXS,
fontSize: fontSizeSM,
lineHeight: lineHeightSM
},
'&-name': {
color: colorTextSecondary,
fontSize: fontSize,
transition: "color ".concat(motionDurationSlow),
'> *': {
color: colorTextSecondary,
'&:hover': {
color: colorTextSecondary
}
}
},
'&-time': {
color: colorTextTertiary,
whiteSpace: 'nowrap',
cursor: 'auto'
}
},
'&-detail p': {
whiteSpace: 'pre-wrap',
marginBlock: 0
}
}), _defineProperty(_objectSpread2, "".concat(componentCls, "-actions"), {
marginTop: marginSM,
marginBottom: 0,
paddingInlineStart: 0,
'> li': {
display: 'inline-block',
color: colorTextSecondary,
'> span': {
marginInlineEnd: marginSM,
color: colorTextSecondary,
fontSize: fontSizeSM,
cursor: 'pointer',
transition: "color ".concat(motionDurationSlow),
userSelect: 'none',
'&:hover': {
color: colorText
}
}
}
}), _defineProperty(_objectSpread2, "".concat(componentCls, "-nested"), {
marginInlineStart: 44
}), _objectSpread2)));
};
function useStyle(prefixCls) {
var _antdTheme$useToken = _antd.theme.useToken(),
theme = _antdTheme$useToken.theme,
token = _antdTheme$useToken.token,
hashId = _antdTheme$useToken.hashId;
var _React$useContext = React.useContext(_antd.ConfigProvider.ConfigContext),
iconPrefixCls = _React$useContext.iconPrefixCls;
return [(0, _cssinjs.useStyleRegister)({
theme: theme,
token: token,
hashId: hashId,
path: ['compatible', 'Comment', prefixCls, iconPrefixCls]
}, function () {
var mergedToken = _objectSpread({
componentCls: ".".concat(prefixCls)
}, token);
return [genSharedButtonStyle(mergedToken)];
}), hashId];
}