Skip to content

Commit

Permalink
Merge pull request mozilla#6259 from mozilla/jh/settings-header-shado…
Browse files Browse the repository at this point in the history
…w-updates

refactor(settings): remove header shadow on scroll
  • Loading branch information
jodyheavener committed Aug 21, 2020
2 parents 06992a2 + d653ee8 commit b08d0e0
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions packages/fxa-settings/src/components/HeaderLockup/index.tsx
Expand Up @@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import React, { useEffect, useState } from 'react';
import classNames from 'classnames';
import React from 'react';
import LogoLockup from 'fxa-react/components/LogoLockup';
import Header from 'fxa-react/components/Header';
import LinkExternal from 'fxa-react/components/LinkExternal';
Expand All @@ -13,27 +12,8 @@ import { ReactComponent as Bento } from './bento.svg';
import { ReactComponent as Menu } from './menu.svg';
import { useAccount } from '../../models';

const SHADOW_SCROLL_THRESHOLD = 5;

export const HeaderLockup = () => {
const { avatarUrl } = useAccount();
const [showShadow, setShowShadow] = useState<boolean>(false);

useEffect(() => {
function handleScroll() {
const scrollTop =
window.pageYOffset || document.documentElement.scrollTop;
const shouldShow = scrollTop > SHADOW_SCROLL_THRESHOLD;
if (shouldShow !== showShadow) {
setShowShadow(shouldShow);
}
}

window.addEventListener('scroll', handleScroll);
handleScroll();
return () => window.removeEventListener('scroll', handleScroll);
}, [showShadow]);

const left = (
<>
<button
Expand Down Expand Up @@ -84,15 +64,7 @@ export const HeaderLockup = () => {
</>
);

return (
<Header
{...{ left, right }}
className={classNames(
'sticky top-0 bg-grey-10 transition-shadow ease-in duration-100',
showShadow && 'shadow-md'
)}
/>
);
return <Header {...{ left, right }} />;
};

export default HeaderLockup;

0 comments on commit b08d0e0

Please sign in to comment.