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

Add announcement banner #707

Merged
merged 3 commits into from
Sep 18, 2023
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
GATSBY_FUNCTIONS_URL=
SHOW_ANNOUNCEMENT_BANNER=true
1 change: 1 addition & 0 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
- name: Build
env:
GATSBY_FUNCTIONS_URL: ${{ needs.prepare-deploy.outputs.function_URL }}
SHOW_ANNOUNCEMENT_BANNER: true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devin-black you can set this to false and then redeploy to hide the Banner in production. To test locally just add the variable to your .env.development file

run: |
yarn build

Expand Down
1 change: 1 addition & 0 deletions config/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export const links = {
prime: 'https://forms.gle/kt1GShLcWapMGzjs7',
primeBlogPost: 'https://centrifuge.mirror.xyz/KyrMWLKMccFCNfSlvjxe7uyhba7oLrUzlBuZ7GQTn6s',
podcast: 'https://linktr.ee/centrifugeconversations',
announcements: '@devin, please add link here',
}
23 changes: 23 additions & 0 deletions src/components/Banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Box, Text } from '@centrifuge/fabric'
import * as React from 'react'
import { theme } from '../theme'

type BannerProps = {
children: React.ReactNode
}

export function Banner({ children }: BannerProps) {
return process.env.SHOW_ANNOUNCEMENT_BANNER === 'true' ? (
<Box
as="div"
py={1}
display="flex"
backgroundColor={theme.colors.accentSecondary}
justifyContent="center"
height="100%"
width="100%"
>
<Text variant="body2">{children}</Text>
</Box>
) : null
}
63 changes: 45 additions & 18 deletions src/components/header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react'
import { Container, Shelf } from '@centrifuge/fabric'
import { Box, Container, Shelf, Text } from '@centrifuge/fabric'
import { useTheme } from 'styled-components'
import type { ButtonVariant } from '../desktop-menu/SubMenu'
import { useScrollDirection } from '../../hooks/use-scroll-direction'
import { Logo } from '../Logo'
import { MobileMenu } from '../mobile-menu'
import { DesktopMenu } from '../desktop-menu'
import { Root, LogoLink } from './styles'
import { Banner } from '../Banner'
import { links } from '../../../config/links'

type HeaderProps = {
menuButtonVariant: ButtonVariant
Expand All @@ -17,23 +19,48 @@ export function Header({ menuButtonVariant }: HeaderProps) {
const scrollDirection = useScrollDirection(50)

return (
<Root
as="header"
position="fixed"
zIndex={zIndices.sticky}
top={0}
px={2}
height={sizes.headerHeight}
isHidden={scrollDirection === 'down'}
>
<Container as={Shelf} justifyContent="space-between" alignItems="center" height="100%" maxWidth="containerHeader">
<LogoLink to="/" title="Home page">
<Logo />
</LogoLink>
<>
<Banner>
Centrifuge is Everywhere. Read the{' '}
<Text
as="a"
style={{ textDecoration: 'underline' }}
href={links.announcements}
rel="noopener noreferrer"
target="_blank"
variant="body2"
>
Announcement
</Text>
</Banner>
<Root
as="header"
position="sticky"
zIndex={zIndices.sticky}
top={0}
px={0}
height={sizes.headerHeight}
isHidden={scrollDirection === 'down'}
>
<Box alignItems="center" justifyContent="center" height="100%">
<Container
px={2}
py={1}
as={Shelf}
justifyContent="space-between"
alignItems="center"
height="100%"
maxWidth="containerHeader"
>
<LogoLink to="/" title="Home page">
<Logo />
</LogoLink>

<MobileMenu />
<DesktopMenu menuButtonVariant={menuButtonVariant} />
</Container>
</Root>
<MobileMenu />
<DesktopMenu menuButtonVariant={menuButtonVariant} />
</Container>
</Box>
</Root>
</>
)
}
Loading