Skip to content

Commit

Permalink
Create TopBanner
Browse files Browse the repository at this point in the history
Initial text for bridge
  • Loading branch information
mvaivre committed Nov 10, 2023
1 parent de9f1f5 commit 85e266b
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 35 deletions.
13 changes: 7 additions & 6 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ const Button = ({ onClick, className, children, url, newTab, trackingName, disab
)

export default styled(Button)`
background-color: var(--color-blue-100);
color: var(--color-white);
border-radius: var(--radius-small);
padding: var(--spacing-2) var(--spacing-3);
background-color: white;
color: black;
border-radius: 4px;
padding: 3px 5px;
border: 0 solid;
text-decoration: none;
display: inline-flex;
box-shadow: 0 5px 5px rgba(0, 0, 0, 0.2);
/* The following rules are the same as in the ArrowedLink, maybe extract? */
align-items: center;
font-weight: var(--fontWeight-medium);
font-size: var(--fontSize-18);
transition: all 0.1s ease-out;
${({ disabled }) =>
Expand All @@ -59,6 +59,7 @@ export default styled(Button)`
&:hover {
cursor: pointer;
filter: brightness(120%);
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.2);
}
`
: css`
Expand All @@ -69,7 +70,7 @@ export default styled(Button)`
.arrow {
width: 11px;
margin-left: var(--spacing-1);
fill: var(--color-white);
fill: inherit;
${(props) =>
props.newTab &&
Expand Down
7 changes: 5 additions & 2 deletions src/components/NavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import { RiMenu3Fill } from 'react-icons/ri'
import useOnClickOutside from '../hooks/useOnClickOutside'

interface NavigationMenuProps {
topOffset?: number
className?: string
}

const detachScrollValue = 150

const NavigationMenu = ({ className }: NavigationMenuProps) => {
const NavigationMenu = ({ topOffset, className }: NavigationMenuProps) => {
const { scrollY } = useScroll()
const [isDetached, setIsDetached] = useState(false)

Expand All @@ -32,12 +33,14 @@ const NavigationMenu = ({ className }: NavigationMenuProps) => {
}
})

const initialTop = topOffset || 0

return (
<NavigationWrapper>
<NavigationMenuStyled
className={className}
animate={{
y: isDetached ? 30 : 0,
y: isDetached ? 30 : initialTop,
backgroundColor: isDetached ? 'rgba(30, 30, 30, 0.6)' : 'rgba(30, 30, 30, 0)'
}}
transition={{ type: 'spring', stiffness: 200, damping: 50 }}
Expand Down
1 change: 0 additions & 1 deletion src/components/PageSectionEcosystem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styled from 'styled-components'
import { graphql } from 'gatsby'

import { deviceBreakPoints } from '../styles/global-style'

Expand Down
43 changes: 43 additions & 0 deletions src/components/TopBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import styled from 'styled-components'
import Button from './Button'

export interface TopBannerContentType {
text: string
linkText: string
url: string
color: string
}

export interface TopBannerProps {
content: TopBannerContentType
className?: string
}

const TopBanner = ({ content: { text, linkText, url, color }, className }: TopBannerProps) =>
text ? (
<TopBannerContainer className={className} style={{ backgroundColor: color }}>
<BannerText>{text}</BannerText>
<Button url={url} newTab trackingName="top-banner:main-link">
{linkText}
</Button>
</TopBannerContainer>
) : null

export default TopBanner

const TopBannerContainer = styled.div`
position: absolute;
top: 0;
right: 0;
left: 0;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
color: white;
gap: 10px;
z-index: 10001;
font-size: 14px;
`

const BannerText = styled.div``
5 changes: 5 additions & 0 deletions src/content/homepage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
topBanner:
text: 'The bridge is OUT!'
linkText: 'Try it'
url: 'https://bridge.alephium.org'
color: '#1c91eb'
headerSection:
dark:
title: 'Scalable for devs.
Expand Down
63 changes: 37 additions & 26 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThemeProvider } from 'styled-components'
import styled, { ThemeProvider } from 'styled-components'
import { graphql, PageProps } from 'gatsby'

import GlobalStyle from '../styles/global-style'
Expand All @@ -18,12 +18,14 @@ import PageSectionShop, { PageSectionShopContentType } from '../components/PageS
import SectionDivider from '../components/SectionDivider'
import PageSectionWallets, { PageSectionWalletsContentType } from '../components/PageSectionWallets'
import NavigationMenu from '../components/NavigationMenu'
import TopBanner, { TopBannerContentType } from '../components/TopBanner'

interface IndexPageProps extends PageProps {
data: {
homepage: {
nodes: {
frontmatter: {
topBanner: TopBannerContentType
headerSection: PageSectionHeroContentType
introSection: PageSectionIntroContentType
technologySection: PageSectionTechnologyContentType
Expand Down Expand Up @@ -51,43 +53,52 @@ const IndexPage = (props: IndexPageProps) => {
<Seo />
<ThemeProvider theme={darkTheme}>
<GlobalStyle />
<SiteWrapper>
<TopBanner content={pageContent.topBanner} />
<NavigationMenu topOffset={pageContent.topBanner.text ? 50 : 0} />
<ContentContainer>
<PageSectionHero content={pageContent.headerSection} />
<SectionDivider />
<PageSectionIntro content={pageContent.introSection} />
<SectionDivider />
<PageSectionTechnology content={pageContent.technologySection} minimal />
<PageSectionNumbers content={pageContent.numbersSection} />
<SectionDivider />
<PageSectionWallets content={pageContent.walletsSection} />
<SectionDivider />
<PageSectionEcosystem content={pageContent.ecosystemSection} />
<SectionDivider />
<PageSectionMilestones content={pageContent.milestonesSection} />
<SectionDivider />
<PageSectionTodoList content={pageContent.todoListSection} />
<SectionDivider />
<PageSectionShop content={pageContent.shopSection} />
<PageSectionFollowUs content={pageContent.followUsSection} />
<Footer content={pageContent.footer} openPrivacyPolicyModal={openPrivacyPolicyModal} />
</ContentContainer>
</SiteWrapper>
</ThemeProvider>
<main>
<ThemeProvider theme={darkTheme}>
<NavigationMenu />
<PageSectionHero content={pageContent.headerSection} />
<SectionDivider />
<PageSectionIntro content={pageContent.introSection} />
<SectionDivider />
<PageSectionTechnology content={pageContent.technologySection} minimal />
<PageSectionNumbers content={pageContent.numbersSection} />
<SectionDivider />
<PageSectionWallets content={pageContent.walletsSection} />
<SectionDivider />
<PageSectionEcosystem content={pageContent.ecosystemSection} />
</ThemeProvider>
<ThemeProvider theme={darkTheme}>
<SectionDivider />
<PageSectionMilestones content={pageContent.milestonesSection} />
<SectionDivider />
<PageSectionTodoList content={pageContent.todoListSection} />
<SectionDivider />
<PageSectionShop content={pageContent.shopSection} />
<PageSectionFollowUs content={pageContent.followUsSection} />
<Footer content={pageContent.footer} openPrivacyPolicyModal={openPrivacyPolicyModal} />
</ThemeProvider>
</main>
</>
)
}

export default IndexPage

const SiteWrapper = styled.main``

const ContentContainer = styled.div``

export const pageQuery = graphql`
query {
homepage: allMarkdownRemark(filter: { fileAbsolutePath: { regex: "/homepage.md/" } }) {
nodes {
frontmatter {
topBanner {
text
linkText
url
color
}
headerSection {
dark {
title
Expand Down

0 comments on commit 85e266b

Please sign in to comment.