| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- "use strict";
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.genPreviewSwitchStyle = exports.genPreviewOperationsStyle = exports.genImagePreviewStyle = exports.genImageMaskStyle = exports.genBoxStyle = exports.default = void 0;
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
- require("../../_util/cssinjs");
- var _tinycolor = require("@ctrl/tinycolor");
- var _style = require("../../modal/style");
- var _motion = require("../../style/motion");
- var _internal = require("../../theme/internal");
- var _style2 = require("../../style");
- const genBoxStyle = position => ({
- position: position || 'absolute',
- inset: 0
- });
- exports.genBoxStyle = genBoxStyle;
- const genImageMaskStyle = token => {
- const {
- iconCls,
- motionDurationSlow,
- paddingXXS,
- marginXXS,
- prefixCls
- } = token;
- return {
- position: 'absolute',
- inset: 0,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- color: '#fff',
- background: new _tinycolor.TinyColor('#000').setAlpha(0.5).toRgbString(),
- cursor: 'pointer',
- opacity: 0,
- transition: `opacity ${motionDurationSlow}`,
- [`.${prefixCls}-mask-info`]: (0, _extends2.default)((0, _extends2.default)({}, _style2.textEllipsis), {
- padding: `0 ${paddingXXS}px`,
- [iconCls]: {
- marginInlineEnd: marginXXS,
- svg: {
- verticalAlign: 'baseline'
- }
- }
- })
- };
- };
- exports.genImageMaskStyle = genImageMaskStyle;
- const genPreviewOperationsStyle = token => {
- const {
- previewCls,
- modalMaskBg,
- paddingSM,
- previewOperationColorDisabled,
- motionDurationSlow
- } = token;
- const operationBg = new _tinycolor.TinyColor(modalMaskBg).setAlpha(0.1);
- const operationBgHover = operationBg.clone().setAlpha(0.2);
- return {
- [`${previewCls}-operations`]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style2.resetComponent)(token)), {
- display: 'flex',
- flexDirection: 'row-reverse',
- alignItems: 'center',
- color: token.previewOperationColor,
- listStyle: 'none',
- background: operationBg.toRgbString(),
- pointerEvents: 'auto',
- '&-operation': {
- marginInlineStart: paddingSM,
- padding: paddingSM,
- cursor: 'pointer',
- transition: `all ${motionDurationSlow}`,
- userSelect: 'none',
- '&:hover': {
- background: operationBgHover.toRgbString()
- },
- '&-disabled': {
- color: previewOperationColorDisabled,
- pointerEvents: 'none'
- },
- '&:last-of-type': {
- marginInlineStart: 0
- }
- },
- '&-progress': {
- position: 'absolute',
- left: {
- _skip_check_: true,
- value: '50%'
- },
- transform: 'translateX(-50%)'
- },
- '&-icon': {
- fontSize: token.previewOperationSize
- }
- })
- };
- };
- exports.genPreviewOperationsStyle = genPreviewOperationsStyle;
- const genPreviewSwitchStyle = token => {
- const {
- modalMaskBg,
- iconCls,
- previewOperationColorDisabled,
- previewCls,
- zIndexPopup,
- motionDurationSlow
- } = token;
- const operationBg = new _tinycolor.TinyColor(modalMaskBg).setAlpha(0.1);
- const operationBgHover = operationBg.clone().setAlpha(0.2);
- return {
- [`${previewCls}-switch-left, ${previewCls}-switch-right`]: {
- position: 'fixed',
- insetBlockStart: '50%',
- zIndex: zIndexPopup + 1,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- width: token.imagePreviewSwitchSize,
- height: token.imagePreviewSwitchSize,
- marginTop: -token.imagePreviewSwitchSize / 2,
- color: token.previewOperationColor,
- background: operationBg.toRgbString(),
- borderRadius: '50%',
- transform: `translateY(-50%)`,
- cursor: 'pointer',
- transition: `all ${motionDurationSlow}`,
- pointerEvents: 'auto',
- userSelect: 'none',
- '&:hover': {
- background: operationBgHover.toRgbString()
- },
- [`&-disabled`]: {
- '&, &:hover': {
- color: previewOperationColorDisabled,
- background: 'transparent',
- cursor: 'not-allowed',
- [`> ${iconCls}`]: {
- cursor: 'not-allowed'
- }
- }
- },
- [`> ${iconCls}`]: {
- fontSize: token.previewOperationSize
- }
- },
- [`${previewCls}-switch-left`]: {
- insetInlineStart: token.marginSM
- },
- [`${previewCls}-switch-right`]: {
- insetInlineEnd: token.marginSM
- }
- };
- };
- exports.genPreviewSwitchStyle = genPreviewSwitchStyle;
- const genImagePreviewStyle = token => {
- const {
- motionEaseOut,
- previewCls,
- motionDurationSlow,
- componentCls
- } = token;
- return [{
- [`${componentCls}-preview-root`]: {
- [previewCls]: {
- height: '100%',
- textAlign: 'center',
- pointerEvents: 'none'
- },
- [`${previewCls}-body`]: (0, _extends2.default)((0, _extends2.default)({}, genBoxStyle()), {
- overflow: 'hidden'
- }),
- [`${previewCls}-img`]: {
- maxWidth: '100%',
- maxHeight: '100%',
- verticalAlign: 'middle',
- transform: 'scale3d(1, 1, 1)',
- cursor: 'grab',
- transition: `transform ${motionDurationSlow} ${motionEaseOut} 0s`,
- userSelect: 'none',
- pointerEvents: 'auto',
- '&-wrapper': (0, _extends2.default)((0, _extends2.default)({}, genBoxStyle()), {
- transition: `transform ${motionDurationSlow} ${motionEaseOut} 0s`,
- // https://github.com/ant-design/ant-design/issues/39913
- // TailwindCSS will reset img default style.
- // Let's set back.
- display: 'flex',
- justifyContent: 'center',
- alignItems: 'center',
- '&::before': {
- display: 'inline-block',
- width: 1,
- height: '50%',
- marginInlineEnd: -1,
- content: '""'
- }
- })
- },
- [`${previewCls}-moving`]: {
- [`${previewCls}-preview-img`]: {
- cursor: 'grabbing',
- '&-wrapper': {
- transitionDuration: '0s'
- }
- }
- }
- }
- },
- // Override
- {
- [`${componentCls}-preview-root`]: {
- [`${previewCls}-wrap`]: {
- zIndex: token.zIndexPopup
- }
- }
- },
- // Preview operations & switch
- {
- [`${componentCls}-preview-operations-wrapper`]: {
- position: 'fixed',
- insetBlockStart: 0,
- insetInlineEnd: 0,
- zIndex: token.zIndexPopup + 1,
- width: '100%'
- },
- '&': [genPreviewOperationsStyle(token), genPreviewSwitchStyle(token)]
- }];
- };
- exports.genImagePreviewStyle = genImagePreviewStyle;
- const genImageStyle = token => {
- const {
- componentCls
- } = token;
- return {
- // ============================== image ==============================
- [componentCls]: {
- position: 'relative',
- display: 'inline-block',
- [`${componentCls}-img`]: {
- width: '100%',
- height: 'auto',
- verticalAlign: 'middle'
- },
- [`${componentCls}-img-placeholder`]: {
- backgroundColor: token.colorBgContainerDisabled,
- backgroundImage: "url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",
- backgroundRepeat: 'no-repeat',
- backgroundPosition: 'center center',
- backgroundSize: '30%'
- },
- [`${componentCls}-mask`]: (0, _extends2.default)({}, genImageMaskStyle(token)),
- [`${componentCls}-mask:hover`]: {
- opacity: 1
- },
- [`${componentCls}-placeholder`]: (0, _extends2.default)({}, genBoxStyle())
- }
- };
- };
- const genPreviewMotion = token => {
- const {
- previewCls
- } = token;
- return {
- [`${previewCls}-root`]: (0, _motion.initZoomMotion)(token, 'zoom'),
- [`&`]: (0, _motion.initFadeMotion)(token, true)
- };
- };
- // ============================== Export ==============================
- var _default = exports.default = (0, _internal.genComponentStyleHook)('Image', token => {
- const previewCls = `${token.componentCls}-preview`;
- const imageToken = (0, _internal.mergeToken)(token, {
- previewCls,
- modalMaskBg: new _tinycolor.TinyColor('#000').setAlpha(0.45).toRgbString(),
- imagePreviewSwitchSize: token.controlHeightLG
- });
- return [genImageStyle(imageToken), genImagePreviewStyle(imageToken), (0, _style.genModalMaskStyle)((0, _internal.mergeToken)(imageToken, {
- componentCls: previewCls
- })), genPreviewMotion(imageToken)];
- }, token => ({
- zIndexPopup: token.zIndexPopupBase + 80,
- previewOperationColor: new _tinycolor.TinyColor(token.colorTextLightSolid).toRgbString(),
- previewOperationColorDisabled: new _tinycolor.TinyColor(token.colorTextLightSolid).setAlpha(0.25).toRgbString(),
- previewOperationSize: token.fontSizeIcon * 1.5 // FIXME: fontSizeIconLG
- }));
|