Skip to content

Commit

Permalink
Merge pull request elastic#19 from Elastic-AWP-Platform/remove-emotio…
Browse files Browse the repository at this point in the history
…n-animation-workaround

Remove detail panel animation workaround
  • Loading branch information
Jack authored Dec 1, 2021
2 parents 94bf3ef + 561e712 commit 0c2c821
Showing 1 changed file with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,62 @@
*/

import { useMemo } from 'react';
import { useEuiTheme } from '@elastic/eui';
import { keyframes, CSSObject } from '@emotion/react';

interface StylesDeps {
height: number | undefined;
}

export const useStyles = ({ height = 500 }: StylesDeps) => {
const { euiTheme } = useEuiTheme();

const cached = useMemo(() => {
const { animation } = euiTheme;
const detailPanelSize = '424px';

const slideIn = keyframes({
from: {
left: '100%',
},
to: {
right: '0',
left: `calc(100% - ${detailPanelSize})`,
},
});

const slideOut = keyframes({
from: {
right: '0',
left: `calc(100% - ${detailPanelSize})`,
},
to: {
right: '-100%',
left: '100%',
},
});

const detailPanel: CSSObject = {
width: '424px',
width: detailPanelSize,
height: `${height}px`,
overflowY: 'auto',
position: 'absolute',
top: '8px',
right: '-100%',
left: '100%',
};

const detailPanelIn: Array<string | CSSObject> = [
slideIn.styles,
{
...detailPanel,
animation: `${slideIn.name} 200ms ease forwards`,
},
];
const detailPanelIn: CSSObject = {
...detailPanel,
animation: `${slideIn} ${animation.normal} ease forwards`,
};

const detailPanelOut: Array<string | CSSObject> = [
slideOut.styles,
{
...detailPanel,
animation: `${slideOut.name} 150ms ease`,
},
];
const detailPanelOut: CSSObject = {
...detailPanel,
animation: `${slideOut} ${animation.fast} ease forwards`,
};

return {
detailPanelIn,
detailPanelOut,
};
}, [height]);
}, [height, euiTheme]);

return cached;
};

0 comments on commit 0c2c821

Please sign in to comment.