-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ui-bugs-party' of https://github.com/odigos-io/odigos
- Loading branch information
Showing
10 changed files
with
156 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 25 additions & 25 deletions
50
frontend/webapp/containers/main/destinations/add-destination/test-connection/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { PropsWithChildren, useCallback, useEffect, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import type { IStyledComponentBase, Keyframes, Substitute } from 'styled-components/dist/types'; | ||
|
||
interface HookProps { | ||
container: IStyledComponentBase<'web', Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, {}>> & string; | ||
animateIn: Keyframes; | ||
animateOut?: Keyframes; | ||
duration?: number; // in milliseconds | ||
} | ||
|
||
type TransitionProps = PropsWithChildren<{ | ||
enter: boolean; | ||
[key: string]: any; | ||
}>; | ||
|
||
export const useTransition = ({ container, animateIn, animateOut, duration = 300 }: HookProps) => { | ||
const Animated = styled(container)<{ $isEntering: boolean; $isLeaving: boolean }>` | ||
animation-name: ${({ $isEntering, $isLeaving }) => ($isEntering ? animateIn : $isLeaving ? animateOut : 'none')}; | ||
animation-duration: ${duration}ms; | ||
animation-fill-mode: forwards; | ||
`; | ||
|
||
const Transition = useCallback(({ children, enter, ...props }: TransitionProps) => { | ||
const [mounted, setMounted] = useState(false); | ||
|
||
useEffect(() => { | ||
const t = setTimeout(() => setMounted(enter), duration + 50); // +50ms to ensure the animation is finished | ||
return () => clearTimeout(t); | ||
}, [enter, duration]); | ||
|
||
return ( | ||
<Animated $isEntering={enter} $isLeaving={!enter && mounted} {...props}> | ||
{children} | ||
</Animated> | ||
); | ||
|
||
// do not add dependencies here, it will cause re-renders which we want to avoid | ||
}, []); | ||
|
||
return Transition; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.