-
Notifications
You must be signed in to change notification settings - Fork 106
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
fixed #445 by adding a animated search component #459
Merged
e-for-eshaan
merged 3 commits into
middlewarehq:main
from
KartikChawla09:KartikChawla09/AnimatedSearch
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
web-server/src/components/AnimatedInputWrapper/AnimatedInputWrapper.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
import styles from './slider.module.css'; | ||
|
||
const AnimatedInputWrapper = () => { | ||
return ( | ||
<div className={styles.placeholder}> | ||
<AnimatedPlaceHolderWrapper /> | ||
</div> | ||
); | ||
}; | ||
|
||
const popRepos = ['golang/go', 'mozilla/rust', 'apple/swift', 'oven-sh/bun']; | ||
const AnimatedPlaceHolderWrapper = () => { | ||
return ( | ||
<div className={styles.animationWrapper}> | ||
<span>Search for</span> | ||
<AnimatedRepos /> | ||
</div> | ||
); | ||
}; | ||
|
||
const AnimatedRepos = () => { | ||
const [animationIndex, setAnimationIndex] = useState(0); | ||
useEffect(() => { | ||
const interval = setInterval(() => { | ||
if (animationIndex < popRepos.length - 1) { | ||
setAnimationIndex(animationIndex + 1); | ||
} else { | ||
setAnimationIndex(0); | ||
} | ||
}, 2000); | ||
return () => clearInterval(interval); | ||
}); | ||
return ( | ||
<div className={styles.textslide}> | ||
<div | ||
className={styles.text} | ||
style={{ bottom: animationIndex * 1.4 + 'em' }} | ||
> | ||
{popRepos.map((item) => ( | ||
<div key={item} className={styles.repo}> | ||
<span>{item}</span> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AnimatedInputWrapper; |
29 changes: 29 additions & 0 deletions
29
web-server/src/components/AnimatedInputWrapper/slider.module.css
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,29 @@ | ||
.animationWrapper{ | ||
position: absolute; | ||
top: 50%; | ||
transform: translate(0%, -50%); | ||
font-size: 1em; | ||
display: flex; | ||
gap: 4px; | ||
} | ||
|
||
.placeholder{ | ||
height: 1.4em; | ||
width: 10rem; | ||
position: relative; | ||
} | ||
|
||
.repo{ | ||
height: 1.4em; | ||
} | ||
|
||
.text{ | ||
position: relative; | ||
transition: all 0.5s ease; | ||
} | ||
|
||
.textslide{ | ||
display: flex; | ||
height: 1.4em; | ||
align-items: flex-start; | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are using
absolute
position, but the parent (element wrapping this component) isn't havingrelative
position.this can cause unexpected behaviour when you are trying to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave
position:relative
to.placeholder
which was the parent element of.animationWrapper