💫(ap-impress) improve transition
Improve transition on Box component.
This commit is contained in:
@@ -47,11 +47,22 @@ export const Box = styled('div')<BoxProps>`
|
||||
${({ $minWidth }) => $minWidth && `min-width: ${$minWidth};`}
|
||||
${({ $css }) => $css && `${$css};`}
|
||||
${({ $effect }) => {
|
||||
let effect;
|
||||
switch ($effect) {
|
||||
case 'show':
|
||||
return showEffect;
|
||||
effect = showEffect;
|
||||
break;
|
||||
case 'hide':
|
||||
return hideEffect;
|
||||
effect = hideEffect;
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
effect &&
|
||||
`
|
||||
transition: all 0.3s ease-in-out;
|
||||
${effect}
|
||||
`
|
||||
);
|
||||
}}
|
||||
`;
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
import { css, keyframes } from 'styled-components';
|
||||
|
||||
const show = keyframes`
|
||||
0% { transform: scaleY(0); opacity: 0; max-height: 0; }
|
||||
100% { transform: scaleY(1); opacity: 1; max-height: 150px;}
|
||||
export const showEffect = `
|
||||
transform: scaleY(1);
|
||||
opacity: 1;
|
||||
max-height: 150px;
|
||||
`;
|
||||
|
||||
const hide = keyframes`
|
||||
0% { transform: scaleY(1); opacity: 1; max-height: 150px;}
|
||||
100% { display:none; transform: scaleY(0); opacity: 0; max-height: 0; }
|
||||
`;
|
||||
|
||||
export const showEffect = css`
|
||||
animation: ${show} 0.3s ease-in-out;
|
||||
`;
|
||||
|
||||
export const hideEffect = css`
|
||||
animation: ${hide} 0.3s ease-in-out;
|
||||
animation-fill-mode: forwards;
|
||||
export const hideEffect = `
|
||||
transform: scaleY(0);
|
||||
opacity: 0;
|
||||
max-height: 0;
|
||||
`;
|
||||
|
||||
@@ -31,17 +31,17 @@ export const TemplateEditor = ({ template }: TemplateEditorProps) => {
|
||||
},
|
||||
});
|
||||
const [editor, setEditor] = useState<Editor>();
|
||||
const [showWarning, setShowWarning] = useState(false);
|
||||
|
||||
const html = editor?.getHtml();
|
||||
|
||||
const [showWarning, setShowWarning] = useState(!!html);
|
||||
|
||||
useEffect(() => {
|
||||
if (showWarning || !html) {
|
||||
if (!html) {
|
||||
return;
|
||||
}
|
||||
|
||||
setShowWarning(html.includes('{{body}}') === false);
|
||||
}, [html, showWarning]);
|
||||
setShowWarning(!html.includes('{{body}}'));
|
||||
}, [html]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!editor?.loadProjectData || !editor?.Storage) {
|
||||
@@ -106,17 +106,15 @@ export const TemplateEditor = ({ template }: TemplateEditorProps) => {
|
||||
{t('Save template')}
|
||||
</Button>
|
||||
</Box>
|
||||
{showWarning && html && (
|
||||
<Box
|
||||
className="m-b"
|
||||
$css="margin-top:0;"
|
||||
$effect={html.includes('{{body}}') ? 'hide' : 'show'}
|
||||
>
|
||||
<Alert
|
||||
type={VariantType.WARNING}
|
||||
>{`The {{body}} tag is necessary to works with the pads.`}</Alert>
|
||||
</Box>
|
||||
)}
|
||||
<Box
|
||||
className="m-b"
|
||||
$css="margin-top:0;"
|
||||
$effect={showWarning ? 'show' : 'hide'}
|
||||
>
|
||||
<Alert
|
||||
type={VariantType.WARNING}
|
||||
>{`The {{body}} tag is necessary to works with the pads.`}</Alert>
|
||||
</Box>
|
||||
|
||||
{!template.abilities.partial_update && (
|
||||
<Box className="m-b" $css="margin-top:0;">
|
||||
|
||||
Reference in New Issue
Block a user