Skip to content

Commit

Permalink
change toaster height
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael18811380328 committed Sep 27, 2024
1 parent 98cf759 commit 77d13a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 7 additions & 9 deletions frontend/src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ export default class Toast extends React.PureComponent {

state = {
isShown: true,
height: 0
};

containerRef = React.createRef();

componentDidUpdate(prevProps) {
if (prevProps.isShown !== this.props.isShown) {
// eslint-disable-next-line react/no-did-update-set-state
Expand Down Expand Up @@ -116,12 +117,10 @@ export default class Toast extends React.PureComponent {

onRef = ref => {
if (ref === null) return;

const { height } = ref.getBoundingClientRect();

this.setState({
height
});
setTimeout(() => {
const { height } = ref.getBoundingClientRect();
this.containerRef.current.style.height = height + 'px';
}, 1);
};

render() {
Expand All @@ -140,10 +139,9 @@ export default class Toast extends React.PureComponent {
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
style={{
height: this.state.height,
zIndex: this.props.zIndex,
marginBottom: this.state.isShown ? 0 : -this.state.height
}}
ref={this.containerRef}
>
<div ref={this.onRef} style={{ padding: 8 }}>
<Alert
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/toast/toaster.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
flex-direction: column;
align-items: center;
height: 0;
transition: all 240ms cubic-bezier(0.0, 0.0, 0.2, 1);
margin-bottom: 0;
transition: all 100ms cubic-bezier(0.0, 0.0, 0.2, 1);
}

@keyframes openAnimation {
Expand Down

0 comments on commit 77d13a4

Please sign in to comment.