Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance Profiler: use fade in and out animation for tips #95473

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 10 additions & 34 deletions client/performance-profiler/pages/loading-screen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,8 @@ const TipWrapper = styled.div< { isActive: boolean } >`
top: 0;
left: 0;
width: 100%;
animation: ${ ( props ) => ( props.isActive ? 'slideInRight' : 'slideOutLeft' ) } 0.5s ease
forwards;

@keyframes slideInRight {
from {
transform: translateX( 100% );
opacity: 0;
}
to {
transform: translateX( 0 );
opacity: 1;
}
}

@keyframes slideOutLeft {
from {
transform: translateX( 0 );
opacity: 1;
}
to {
transform: translateX( -100% );
opacity: 0;
}
}
opacity: ${ ( props ) => ( props.isActive ? 1 : 0 ) };
transition: opacity 0.5s ease;
`;

export const LoadingScreen = ( { isSavedReport }: LoadingScreenProps ) => {
Expand Down Expand Up @@ -110,18 +88,16 @@ export const LoadingScreen = ( { isSavedReport }: LoadingScreenProps ) => {
},
];
const [ currentTip, setCurrentTip ] = useState( 0 );
const [ previousTip, setPreviousTip ] = useState( 0 );

useEffect( () => {
const updateCurrentTip = () => {
setTimeout( () => {
const randomTip = Math.floor( Math.random() * tips.length );
setCurrentTip( randomTip );

updateCurrentTip();
}, 10000 );
};
const intervalId = setInterval( () => {
setPreviousTip( currentTip );
const randomTip = Math.floor( Math.random() * tips.length );
setCurrentTip( randomTip );
}, 10000 );

updateCurrentTip();
return () => clearInterval( intervalId );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}, [] );

return (
Expand All @@ -132,7 +108,7 @@ export const LoadingScreen = ( { isSavedReport }: LoadingScreenProps ) => {
<PerformanceReportLoadingProgress isSavedReport={ isSavedReport } />
<TipContainer>
{ tips.map( ( tip, index ) => (
<TipWrapper key={ index } isActive={ index === currentTip }>
<TipWrapper key={ index } isActive={ index === currentTip || index === previousTip }>
<Tip title={ tip.heading } content={ tip.description } link={ tip.link } />
</TipWrapper>
) ) }
Expand Down
Loading