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

[WIP] Added searchbar transition #82

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
33 changes: 29 additions & 4 deletions src/components/Home/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,36 @@ import user from '../../assets/user.svg';

const TopBar = () => {
const { Title } = Typography;
window.onscroll = function() {
scrollFunction();
};

function scrollFunction() {
if (
document.body.scrollTop > 0.08 ||
document.documentElement.scrollTop > 0.08
) {
document.getElementById('searchBar').style.width = '30%';
} else {
document.getElementById('searchBar').style.width = '100%';
}
}
return (
<Fragment>
<Fragment style={{ alignSelf: 'center' }}>
<Row className={styles.top}>
<Col span={24} style={{ height: 150 }}>
<Col
span={24}
style={{ height: 150, alignItems: 'center', alignSelf: 'center' }}
>
<br />
<Row style={{ paddingLeft: '10px', paddingRight: '10px' }}>
<Row
style={{
paddingLeft: '10px',
paddingRight: '10px',
alignItems: 'center',
alignSelf: 'center',
}}
>
<Col span={8}>
<img src={MenuIcon} alt="menu" />
</Col>
Expand All @@ -35,7 +59,8 @@ const TopBar = () => {
</Row>
<br />

<Row style={{ paddingLeft: '10px', paddingRight: '10px' }}>
{/* <Row id="header" style={{ paddingLeft: '10px', paddingRight: '10px' }}> */}
<Row id="searchBar" className={styles.searchBarRow}>
<Col span={24}>
<Input
size="small"
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const Home = () => {
const { Title } = Typography;
const scroll = useHasScrolled();
return (
<Fragment>
<Fragment style={{ alignItems: 'center' }}>
{scroll !== false ? console.log(scroll) : console.log('bye')}
{scroll === false ? <TopBar /> : <TopBarScroll />}
{/* {scroll === false ? <TopBar /> : <TopBarScroll />} */}
<TopBar />
<div className={styles.main}>
<br />
<Row>
Expand Down
5 changes: 5 additions & 0 deletions src/styles/Home.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
background: url('../assets/abstract_triangles.jpg') no-repeat center center
fixed #000;
background-position: 60% 60%;
align-items: center;
}

.topScroll {
Expand All @@ -15,6 +16,10 @@
border-color: #d7d7d7;
}

.searchBarRow {
transition: 0.5s;
}

.main {
border-radius: 24px;
position: relative;
Expand Down