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

Change navbar and footer to a reusable component #2902

Merged
merged 1 commit into from
May 14, 2024
Merged
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
24 changes: 24 additions & 0 deletions docs/src/components/FooterBackground/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import usePageType from '@site/src/hooks/usePageType';
import { useColorMode } from '@docusaurus/theme-common';

import Moon from '@site/src/components/Moon/MoonIcon';
import DarkMoon from '@site/src/components/Moon/MoonIconDark';
import styles from './styles.module.css';

const FooterBackground = () => {
const { isLanding } = usePageType();
const currentSvgComponent =
useColorMode().colorMode === 'dark' ? <DarkMoon /> : <Moon />;

return (
<div className={styles.moonContainer}>
{isLanding && (
<>{ExecutionEnvironment.canUseViewport && currentSvgComponent}</>
)}
</div>
);
};

export default FooterBackground;
8 changes: 8 additions & 0 deletions docs/src/components/FooterBackground/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.moonContainer {
position: relative;
margin-top: 106px;
}

[class*='footerLanding'] {
margin-top: -106px;
}
20 changes: 20 additions & 0 deletions docs/src/components/Hero/LandingBackground/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import Planets from '@site/src/components/Hero/Planets';
import Stars from '@site/src/components/Hero/Stars';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import styles from './styles.module.css';

const LandingBackground = () => {
return (
<div className={styles.heroBackground}>
{ExecutionEnvironment.canUseViewport && (
<>
<Planets />
<Stars />
</>
)}
</div>
);
};

export default LandingBackground;
42 changes: 42 additions & 0 deletions docs/src/components/Hero/LandingBackground/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.heroBackground {
position: absolute;
top: 0;

background: linear-gradient(
180deg,
var(--swm-blue-light-40) 0%,
var(--swm-blue-light-20) 23%,
#ffffff 46%
);
width: 100%;
height: 130vh;
min-height: 70vw;
overflow: hidden;
z-index: -20;
}

[data-theme='dark'] .heroBackground {
background: none;
background-color: var(--swm-navy-dark-140);
}

@media (max-width: 996px) {
[class*='logoWrapperLanding'] {
width: 50px;
height: 50px;
display: flex;
justify-content: center;
}
}

@media (max-width: 768px) {
.heroBackground {
height: 70vh;
}
}

@media (max-width: 420px) {
.navbarLanding {
padding: 0 1.5rem;
}
}
4 changes: 4 additions & 0 deletions docs/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import styles from './styles.module.css';
import Wave from '@site/src/components/Wave';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import HomepageStartScreen from '@site/src/components/Hero/StartScreen';
import LandingBackground from '@site/src/components/Hero/LandingBackground';
import FooterBackground from '../components/FooterBackground';
import Playground from '@site/src/components/Playground';
import GestureFeatures from '@site/src/components/GestureFeatures';
import Testimonials from '@site/src/components/Testimonials';
Expand All @@ -18,6 +20,7 @@ function Home() {
<Layout
title={`React Native Gesture Handler`}
description="Declarative API exposing platform native touch and gesture system to React Native.">
<LandingBackground />
<div className={styles.container}>
<HomepageStartScreen />
<Playground />
Expand All @@ -31,6 +34,7 @@ function Home() {
<Sponsors />
<HireUsSection />
</div>
<FooterBackground />
</Layout>
);
}
Expand Down
10 changes: 0 additions & 10 deletions docs/src/theme/Footer/Layout/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import React from 'react';
import clsx from 'clsx';
import styles from './styles.module.css';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import { useColorMode } from '@docusaurus/theme-common';

import Moon from '@site/src/components/Moon/MoonIcon';
import DarkMoon from '@site/src/components/Moon/MoonIconDark';
import usePageType from '@site/src/hooks/usePageType';

export default function FooterLayout({ style, links, logo, copyright }) {
const { isLanding } = usePageType();
const currentSvgComponent =
useColorMode().colorMode === 'dark' ? <DarkMoon /> : <Moon />;

return (
<footer
className={clsx('footer', isLanding && styles.footerLanding, {
'footer--dark': style === 'dark',
})}>
{isLanding && (
<>{ExecutionEnvironment.canUseViewport && currentSvgComponent}</>
)}
<div className="container container-fluid">
{links}
{(logo || copyright) && (
Expand Down
17 changes: 0 additions & 17 deletions docs/src/theme/Navbar/Layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import {
} from '@docusaurus/theme-common/internal';
import { translate } from '@docusaurus/Translate';
import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
import Planets from '@site/src/components/Hero/Planets';
import Stars from '@site/src/components/Hero/Stars';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import styles from './styles.module.css';
import usePageType from '@site/src/hooks/usePageType';

Expand All @@ -23,19 +20,6 @@ function NavbarBackdrop(props) {
);
}

const LandingBackground = () => {
return (
<div className={styles.heroBackground}>
{ExecutionEnvironment.canUseViewport && (
<>
<Planets />
<Stars />
</>
)}
</div>
);
};

export default function NavbarLayout({ children }) {
const {
navbar: { hideOnScroll, style },
Expand All @@ -46,7 +30,6 @@ export default function NavbarLayout({ children }) {

return (
<div>
{isLanding && <LandingBackground />}
<nav
ref={navbarRef}
aria-label={translate({
Expand Down
43 changes: 0 additions & 43 deletions docs/src/theme/Navbar/Layout/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,3 @@
padding-top: 2rem;
padding: 0 1.25rem 0 1.5rem;
}

.heroBackground {
position: absolute;
top: 0;

background: linear-gradient(
180deg,
var(--swm-blue-light-40) 0%,
var(--swm-blue-light-20) 23%,
#ffffff 46%
);
width: 100%;
height: 130vh;
min-height: 70vw;
overflow: hidden;
z-index: -20;
}

[data-theme='dark'] .heroBackground {
background: none;
background-color: var(--swm-navy-dark-140);
}

@media (max-width: 996px) {
[class*='logoWrapperLanding'] {
width: 50px;
height: 50px;
display: flex;
justify-content: center;
}
}

@media (max-width: 768px) {
.heroBackground {
height: 70vh;
}
}

@media (max-width: 420px) {
.navbarLanding {
padding: 0 1.5rem;
}
}
Loading