fix: image animation & zindex, close #6675
parent
e9d26f2a7d
commit
994707bd50
|
@ -8,15 +8,15 @@ import { resetComponent, textEllipsis } from '../../style';
|
||||||
|
|
||||||
export interface ComponentToken {
|
export interface ComponentToken {
|
||||||
zIndexPopup: number;
|
zIndexPopup: number;
|
||||||
|
previewOperationSize: number;
|
||||||
|
previewOperationColor: string;
|
||||||
|
previewOperationColorDisabled: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ImageToken extends FullToken<'Image'> {
|
export interface ImageToken extends FullToken<'Image'> {
|
||||||
previewCls: string;
|
previewCls: string;
|
||||||
modalMaskBg: string;
|
modalMaskBg: string;
|
||||||
imagePreviewOperationDisabledColor: string;
|
|
||||||
imagePreviewOperationSize: number;
|
|
||||||
imagePreviewSwitchSize: number;
|
imagePreviewSwitchSize: number;
|
||||||
imagePreviewOperationColor: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PositionType = 'static' | 'relative' | 'fixed' | 'absolute' | 'sticky' | undefined;
|
export type PositionType = 'static' | 'relative' | 'fixed' | 'absolute' | 'sticky' | undefined;
|
||||||
|
@ -45,19 +45,17 @@ export const genImageMaskStyle = (token: ImageToken): CSSObject => {
|
||||||
padding: `0 ${paddingXXS}px`,
|
padding: `0 ${paddingXXS}px`,
|
||||||
[iconCls]: {
|
[iconCls]: {
|
||||||
marginInlineEnd: marginXXS,
|
marginInlineEnd: marginXXS,
|
||||||
|
svg: {
|
||||||
|
verticalAlign: 'baseline',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
|
export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
|
||||||
const {
|
const { previewCls, modalMaskBg, paddingSM, previewOperationColorDisabled, motionDurationSlow } =
|
||||||
previewCls,
|
token;
|
||||||
modalMaskBg,
|
|
||||||
paddingSM,
|
|
||||||
imagePreviewOperationDisabledColor,
|
|
||||||
motionDurationSlow,
|
|
||||||
} = token;
|
|
||||||
|
|
||||||
const operationBg = new TinyColor(modalMaskBg).setAlpha(0.1);
|
const operationBg = new TinyColor(modalMaskBg).setAlpha(0.1);
|
||||||
const operationBgHover = operationBg.clone().setAlpha(0.2);
|
const operationBgHover = operationBg.clone().setAlpha(0.2);
|
||||||
|
@ -68,7 +66,7 @@ export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row-reverse',
|
flexDirection: 'row-reverse',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
color: token.imagePreviewOperationColor,
|
color: token.previewOperationColor,
|
||||||
listStyle: 'none',
|
listStyle: 'none',
|
||||||
background: operationBg.toRgbString(),
|
background: operationBg.toRgbString(),
|
||||||
pointerEvents: 'auto',
|
pointerEvents: 'auto',
|
||||||
|
@ -78,13 +76,14 @@ export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
|
||||||
padding: paddingSM,
|
padding: paddingSM,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
transition: `all ${motionDurationSlow}`,
|
transition: `all ${motionDurationSlow}`,
|
||||||
|
userSelect: 'none',
|
||||||
|
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
background: operationBgHover.toRgbString(),
|
background: operationBgHover.toRgbString(),
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-disabled': {
|
'&-disabled': {
|
||||||
color: imagePreviewOperationDisabledColor,
|
color: previewOperationColorDisabled,
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -100,7 +99,7 @@ export const genPreviewOperationsStyle = (token: ImageToken): CSSObject => {
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-icon': {
|
'&-icon': {
|
||||||
fontSize: token.imagePreviewOperationSize,
|
fontSize: token.previewOperationSize,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -110,7 +109,7 @@ export const genPreviewSwitchStyle = (token: ImageToken): CSSObject => {
|
||||||
const {
|
const {
|
||||||
modalMaskBg,
|
modalMaskBg,
|
||||||
iconCls,
|
iconCls,
|
||||||
imagePreviewOperationDisabledColor,
|
previewOperationColorDisabled,
|
||||||
previewCls,
|
previewCls,
|
||||||
zIndexPopup,
|
zIndexPopup,
|
||||||
motionDurationSlow,
|
motionDurationSlow,
|
||||||
|
@ -130,13 +129,14 @@ export const genPreviewSwitchStyle = (token: ImageToken): CSSObject => {
|
||||||
width: token.imagePreviewSwitchSize,
|
width: token.imagePreviewSwitchSize,
|
||||||
height: token.imagePreviewSwitchSize,
|
height: token.imagePreviewSwitchSize,
|
||||||
marginTop: -token.imagePreviewSwitchSize / 2,
|
marginTop: -token.imagePreviewSwitchSize / 2,
|
||||||
color: token.imagePreviewOperationColor,
|
color: token.previewOperationColor,
|
||||||
background: operationBg.toRgbString(),
|
background: operationBg.toRgbString(),
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
transform: `translateY(-50%)`,
|
transform: `translateY(-50%)`,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
transition: `all ${motionDurationSlow}`,
|
transition: `all ${motionDurationSlow}`,
|
||||||
pointerEvents: 'auto',
|
pointerEvents: 'auto',
|
||||||
|
userSelect: 'none',
|
||||||
|
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
background: operationBgHover.toRgbString(),
|
background: operationBgHover.toRgbString(),
|
||||||
|
@ -144,7 +144,7 @@ export const genPreviewSwitchStyle = (token: ImageToken): CSSObject => {
|
||||||
|
|
||||||
[`&-disabled`]: {
|
[`&-disabled`]: {
|
||||||
'&, &:hover': {
|
'&, &:hover': {
|
||||||
color: imagePreviewOperationDisabledColor,
|
color: previewOperationColorDisabled,
|
||||||
background: 'transparent',
|
background: 'transparent',
|
||||||
cursor: 'not-allowed',
|
cursor: 'not-allowed',
|
||||||
[`> ${iconCls}`]: {
|
[`> ${iconCls}`]: {
|
||||||
|
@ -153,7 +153,7 @@ export const genPreviewSwitchStyle = (token: ImageToken): CSSObject => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[`> ${iconCls}`]: {
|
[`> ${iconCls}`]: {
|
||||||
fontSize: token.imagePreviewOperationSize,
|
fontSize: token.previewOperationSize,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -295,17 +295,11 @@ const genPreviewMotion: GenerateStyle<ImageToken> = token => {
|
||||||
export default genComponentStyleHook(
|
export default genComponentStyleHook(
|
||||||
'Image',
|
'Image',
|
||||||
token => {
|
token => {
|
||||||
const imagePreviewOperationColor = new TinyColor(token.colorTextLightSolid);
|
|
||||||
const previewCls = `${token.componentCls}-preview`;
|
const previewCls = `${token.componentCls}-preview`;
|
||||||
|
|
||||||
const imageToken = mergeToken<ImageToken>(token, {
|
const imageToken = mergeToken<ImageToken>(token, {
|
||||||
previewCls,
|
previewCls,
|
||||||
imagePreviewOperationColor: imagePreviewOperationColor.toRgbString(),
|
|
||||||
imagePreviewOperationDisabledColor: new TinyColor(imagePreviewOperationColor)
|
|
||||||
.setAlpha(0.25)
|
|
||||||
.toRgbString(),
|
|
||||||
modalMaskBg: new TinyColor('#000').setAlpha(0.45).toRgbString(), // FIXME: Shared Token
|
modalMaskBg: new TinyColor('#000').setAlpha(0.45).toRgbString(), // FIXME: Shared Token
|
||||||
imagePreviewOperationSize: token.fontSizeIcon * 1.5, // FIXME: fontSizeIconLG
|
|
||||||
imagePreviewSwitchSize: token.controlHeightLG,
|
imagePreviewSwitchSize: token.controlHeightLG,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -318,5 +312,10 @@ export default genComponentStyleHook(
|
||||||
},
|
},
|
||||||
token => ({
|
token => ({
|
||||||
zIndexPopup: token.zIndexPopupBase + 80,
|
zIndexPopup: token.zIndexPopupBase + 80,
|
||||||
|
previewOperationColor: new TinyColor(token.colorTextLightSolid).toRgbString(),
|
||||||
|
previewOperationColorDisabled: new TinyColor(token.colorTextLightSolid)
|
||||||
|
.setAlpha(0.25)
|
||||||
|
.toRgbString(),
|
||||||
|
previewOperationSize: token.fontSizeIcon * 1.5, // FIXME: fontSizeIconLG
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
@ -311,12 +311,11 @@ const Preview = defineComponent({
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const { visible, prefixCls, rootClassName } = props;
|
const { visible, prefixCls, rootClassName } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
{...attrs}
|
{...attrs}
|
||||||
transitionName="zoom"
|
transitionName={props.transitionName}
|
||||||
maskTransitionName="fade"
|
maskTransitionName={props.maskTransitionName}
|
||||||
closable={false}
|
closable={false}
|
||||||
keyboard
|
keyboard
|
||||||
prefixCls={prefixCls}
|
prefixCls={prefixCls}
|
||||||
|
@ -327,19 +326,22 @@ const Preview = defineComponent({
|
||||||
rootClassName={rootClassName}
|
rootClassName={rootClassName}
|
||||||
getContainer={props.getContainer}
|
getContainer={props.getContainer}
|
||||||
>
|
>
|
||||||
<ul class={`${props.prefixCls}-operations`}>
|
<div class={[`${props.prefixCls}-operations-wrapper`, rootClassName]}>
|
||||||
{tools.map(({ icon: IconType, onClick, type, disabled }) => (
|
<ul class={`${props.prefixCls}-operations`}>
|
||||||
<li
|
{tools.map(({ icon: IconType, onClick, type, disabled }) => (
|
||||||
class={classnames(toolClassName, {
|
<li
|
||||||
[`${props.prefixCls}-operations-operation-disabled`]: disabled && disabled?.value,
|
class={classnames(toolClassName, {
|
||||||
})}
|
[`${props.prefixCls}-operations-operation-disabled`]:
|
||||||
onClick={onClick}
|
disabled && disabled?.value,
|
||||||
key={type}
|
})}
|
||||||
>
|
onClick={onClick}
|
||||||
{cloneVNode(IconType, { class: iconClassName })}
|
key={type}
|
||||||
</li>
|
>
|
||||||
))}
|
{cloneVNode(IconType, { class: iconClassName })}
|
||||||
</ul>
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
class={`${props.prefixCls}-img-wrapper`}
|
class={`${props.prefixCls}-img-wrapper`}
|
||||||
style={{
|
style={{
|
||||||
|
|
Loading…
Reference in New Issue