Skip to content

Commit

Permalink
Add sticky header (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrederikBolding authored Jan 2, 2024
1 parent 35d197e commit 87606a6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
18 changes: 14 additions & 4 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,28 @@ import { FaGithub } from "react-icons/fa";
import { AddIcon } from "@chakra-ui/icons";
import { Filters } from "./Filters";

export const Header = () => {
export const Header = ({ showSearch = true, showFilters = true }) => {
const { handleConnect, isConnected, address } = useContext(Web3Context);
return (
<Flex
pb="2"
as="header"
flexShrink="0"
py="3"
px="8"
flexDirection={{ base: "column", md: "row" }}
justifyContent="space-between"
backdropFilter="auto"
backdropBlur="1.25rem"
position="fixed"
top="0"
left="0"
width="100%"
zIndex="sticky"
>
<Heading>Chainlist</Heading>
<Search />
{showSearch && <Search />}
<Flex>
<Filters />
{showFilters && <Filters />}
<Tooltip label="Add Network">
<Link
href="https://github.com/ethereum-lists/chains/pulls"
Expand Down
12 changes: 12 additions & 0 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import { Flex } from "@chakra-ui/react";
import { Header } from "./Header";

export const Layout = ({ children, headerProps = {} }) => (
<Flex flexDirection="column" py="4" px="8" height="100vh" position="relative">
<Header {...headerProps} />
<Flex as="main" flexDirection="column" mt={{ base: "164px", md: "16" }}>
{children}
</Flex>
</Flex>
);
10 changes: 4 additions & 6 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Box } from "@chakra-ui/react";
import { graphql, useStaticQuery } from "gatsby";
import React, { useState } from "react";
import React from "react";
import { ChainList } from "../components/ChainList";
import { Header } from "../components/Header";
import { Seo } from "../components/SEO";
import { Web3Provider } from "../context/Web3Context";
import { SearchProvider } from "../context/SearchContext";
import { Layout } from "../components/Layout";

const IndexPage = () => {
const rawData = useStaticQuery(graphql`
Expand Down Expand Up @@ -79,10 +78,9 @@ const IndexPage = () => {
<Seo />
<Web3Provider>
<SearchProvider>
<Box py="4" px="8">
<Header />
<Layout>
<ChainList chains={chains} />
</Box>
</Layout>
</SearchProvider>
</Web3Provider>
</>
Expand Down

0 comments on commit 87606a6

Please sign in to comment.