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 tBTC SDK Page #105

Merged
merged 18 commits into from
Dec 22, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.eslintcache

# Generated
build/
/build/
michalsmiarowski marked this conversation as resolved.
Show resolved Hide resolved
dist/

# Yarn
Expand Down
18 changes: 18 additions & 0 deletions src/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ import {
import { FC } from "react"
import { BodyLg, BodySm, LabelSm } from "../Typography"

export interface CardButton {
label: string
url: string
variant: string
}

export interface CardCategory {
label: string
}

type CardComponent<P> = FC<P> & {
PreTitle: FC<TextProps>
Title: FC<TextProps>
SubTitle: FC<TextProps>
Divider: FC<DividerProps>
Expand All @@ -21,6 +32,12 @@ const Card: CardComponent<BoxProps> = (props) => {
return <Box __css={styles} {...props} />
}

const PreTitle: FC = ({ children, ...textProps }) => (
<LabelSm as="span" bgClip="text" textTransform="uppercase" {...textProps}>
{children}
</LabelSm>
)

const Title: FC = ({ children, ...textProps }) => (
<BodyLg {...textProps}>{children}</BodyLg>
)
Expand All @@ -39,6 +56,7 @@ const Divider = ({ ...dividerProps }) => {
return <ChakraDivider bg="gray.700" {...dividerProps} />
}

Card.PreTitle = PreTitle
Card.Title = Title
Card.SubTitle = SubTitle
Card.Body = Body
Expand Down
9 changes: 4 additions & 5 deletions src/components/HighlightWord.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import React, { FC } from "react"
import { RoleTemplateProps } from "../templates/home-page/SectionTemplate"
import { BoxProps, Text } from "@chakra-ui/react"

export interface HighlightWordProps extends BoxProps {
title: string
highlightedWord: string
highlightedWord?: string
}

export const HighlightWord: FC<HighlightWordProps> = ({
title,
highlightedWord,
...highlightedWordProps
}) => {
const titleSplittedByHighlightedWord = title.split(highlightedWord!)
const splittedTitle = title.split(highlightedWord || "")
return (
<>
{titleSplittedByHighlightedWord.map((item, index) => (
{splittedTitle.map((item, index) => (
<React.Fragment key={`text-${index}`}>
{item}
{index !== titleSplittedByHighlightedWord.length - 1 && (
{index !== splittedTitle.length - 1 && highlightedWord && (
<Text as="span" bgClip="text" key={index} {...highlightedWordProps}>
{highlightedWord}
</Text>
Expand Down
1 change: 0 additions & 1 deletion src/components/IntegrationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export const IntegrationsCardGroup: FC<{ cards: IntegrationCardProps[] }> = ({
spacing={cardSpacing}
overflowX="hidden"
py={20}
mb={-28}
position="relative"
>
{cardSet.map((card: IntegrationCardProps, i) => (
Expand Down
16 changes: 14 additions & 2 deletions src/components/Navbar/DesktopNav/DesktopNavLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ import { HStack } from "@chakra-ui/react"
import DropdownLabelLink from "./DropdownMenu"
import NavLink from "./NavLink"
import { LinkInfo } from "../types"
import NavCTAButtons from "../NavCTAButtons"
import { CardButton } from "../../Card"

const DesktopNavLinks: FC<{ navLinks: LinkInfo[] }> = ({ navLinks }) => {
interface DesktopNavLinksProps {
navLinks: LinkInfo[]
menuButtons: CardButton[]
}

const DesktopNavLinks: FC<DesktopNavLinksProps> = ({
navLinks,
menuButtons,
}) => {
return (
<HStack
w="100%"
Expand All @@ -13,7 +23,8 @@ const DesktopNavLinks: FC<{ navLinks: LinkInfo[] }> = ({ navLinks }) => {
borderColor="gray.700"
px={8}
spacing={4}
display={{ base: "none", lg: "inherit" }}
display={{ base: "none", md: "inherit" }}
justifyContent={{ base: "end", lg: "start" }}
as="nav"
>
{navLinks.map(({ subitems, label, url }) => {
Expand All @@ -29,6 +40,7 @@ const DesktopNavLinks: FC<{ navLinks: LinkInfo[] }> = ({ navLinks }) => {
</NavLink>
)
})}
<NavCTAButtons menuButtons={menuButtons} px={5} />
</HStack>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/components/Navbar/DesktopNav/DropdownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const DropdownMenu: FC<{ dropdown: LinkInfo[]; text: string }> = ({
px={2}
color="gray.300"
_hover={hoverStyles}
display={{ base: "none", lg: "inherit" }}
{...openStyles}
>
<HStack>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navbar/DesktopNav/NavLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const NavLink: FC<{ href: string }> = ({ href, children }) => {
px={2}
to={href}
color="gray.300"
display="flex"
display={{ base: "none", lg: "flex" }}
_hover={{
textDecoration: "none",
color: "white",
Expand Down
23 changes: 21 additions & 2 deletions src/components/Navbar/MobileNav/MobileDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,24 @@ import { LinkInfo, SocialLink } from "../types"
import SocialMediaLinks from "../SocialMediaLinks"
import { FaChevronLeft } from "react-icons/all"
import { BodySm, H5 } from "../../Typography"
import { CardButton } from "../../Card"
import NavCTAButtons from "../NavCTAButtons"

const MobileDrawer: FC<{
interface MobileDrawerProps {
onClose: () => void
isOpen: boolean
navLinks: LinkInfo[]
socialLinks: SocialLink[]
}> = ({ onClose, isOpen, navLinks, socialLinks }) => {
menuButtons: CardButton[]
}

const MobileDrawer: FC<MobileDrawerProps> = ({
onClose,
isOpen,
navLinks,
socialLinks,
menuButtons,
}) => {
const isMobileDevice = useChakraBreakpoint("lg")

const [navLinksToRender, setNavLinksToRender] = useState(navLinks)
Expand Down Expand Up @@ -64,6 +75,14 @@ const MobileDrawer: FC<{
justifyContent="space-between"
pb={20}
>
<NavCTAButtons
menuButtons={menuButtons}
display={{ base: "flex", md: "none" }}
w="100%"
fontSize="18px"
height={14}
mb={6}
/>
<Stack divider={<StackDivider borderColor="gray.700" />}>
{navLinksToRender.map(({ url, label, subitems }) => (
<MobileNavLink
Expand Down
30 changes: 30 additions & 0 deletions src/components/Navbar/NavCTAButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { FC } from "react"
import { CardButton } from "../Card"
import { ButtonProps, Stack } from "@chakra-ui/react"
import ExternalButtonLink from "../Buttons/ExternalButtonLink"
import { ExternalLinkHref } from "./types"

interface NavCTAButtonsProps extends ButtonProps {
menuButtons: CardButton[]
}

const NavCTAButtons: FC<NavCTAButtonsProps> = ({ menuButtons, ...props }) => {
return (
<Stack direction={{ base: "column", sm: "row" }} spacing={8}>
{menuButtons.map((_: CardButton) => {
return (
<ExternalButtonLink
variant="special"
href={_.url as ExternalLinkHref}
key={_.label}
{...props}
>
{_.label}
</ExternalButtonLink>
)
})}
</Stack>
)
}

export default NavCTAButtons
105 changes: 57 additions & 48 deletions src/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,59 @@ import { LinkInfo } from "./types"
import WhatsNextBanner from "./WhatsNextBanner"
import MobileDrawer from "./MobileNav/MobileDrawer"
import DesktopNavLinks from "./DesktopNav/DesktopNavLinks"
import { CardButton } from "../Card"
import NavCTAButtons from "./NavCTAButtons"

export const Navbar: FC = () => {
const {
isOpen: isDrawerOpen,
onOpen: onDrawOpen,
onClose: onDrawerClose,
} = useDisclosure()

const { isOpen: showBanner, onClose: closeBanner } = useDisclosure({
defaultIsOpen: true,
})
const data = useStaticQuery(query)
const socialLinks =
data.allMarkdownRemark.edges[0].node.frontmatter.social_links
const navLinks = data.allMarkdownRemark.edges[0].node.frontmatter
.nav_items as LinkInfo[]
const menuButtons = data.allMarkdownRemark.edges[0].node.frontmatter
.menu_buttons as CardButton[]

return (
<>
{showBanner && <WhatsNextBanner onClose={closeBanner} />}
<HStack
bg="gray.900"
h="90px"
borderBottom="1px solid"
borderColor="gray.700"
as="header"
>
<Container
maxW="1140px"
h="100%"
display="flex"
justifyContent="space-between"
>
Comment on lines +42 to +47
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking:

I think that the NavBar would require some refactoring/touch-ups, because in some resolutions it looks off. For example this is how it looks for 1173px width:

image

I think that setting the maxW to 1140px with justifyContent="space-between" is a mistake. Content should probably just be justified to "center" and the width should be maxed out. But I'm not sure as of now.

I think this would require some more touch upd in the long run so I would say to address this issue in a separate PR. The bug is also happening on production (1126 px width):
image

but adding the dashboard link in the navigation made it a little bit worse (see previous screen).

To not block this PR, I will mark it as non-blocking. Addressing that issue in this PR might extend the time to merge this one, as more code equals to more potential bugs that can be found 😅 So I would say we separate that into another PR. Let's just not forget about that issue..

You can test it out yourself and see it you can reproduce the issue.

Copy link
Contributor Author

@evandrosaturnino evandrosaturnino Dec 22, 2023

Choose a reason for hiding this comment

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

Good catch! I've opened an issue to keep track of that, I will address it in a separate PR as advised.
Issue: #107

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! I'll keep this conversation open just in case

<ThresholdBrand />
<MobileDrawer
isOpen={isDrawerOpen}
onClose={onDrawerClose}
navLinks={navLinks}
socialLinks={socialLinks}
menuButtons={menuButtons}
/>
<DesktopNavLinks navLinks={navLinks} menuButtons={menuButtons} />
<SocialMediaLinks links={socialLinks} pl={8} />
<HamburgerButton openDrawer={onDrawOpen} />
</Container>
</HStack>
</>
)
}

const query = graphql`
query Navbar {
Expand All @@ -27,6 +80,10 @@ const query = graphql`
isExternal
}
}
menu_buttons {
label
url
}
social_links {
label
url
Expand Down Expand Up @@ -63,51 +120,3 @@ const query = graphql`
}
}
`

export const Navbar: FC = () => {
const {
isOpen: isDrawerOpen,
onOpen: onDrawOpen,
onClose: onDrawerClose,
} = useDisclosure()

const { isOpen: showBanner, onClose: closeBanner } = useDisclosure({
defaultIsOpen: true,
})
const data = useStaticQuery(query)
const socialLinks =
data.allMarkdownRemark.edges[0].node.frontmatter.social_links
const navLinks = data.allMarkdownRemark.edges[0].node.frontmatter
.nav_items as LinkInfo[]

return (
<>
{showBanner && <WhatsNextBanner onClose={closeBanner} />}
<HStack
bg="gray.900"
h="90px"
borderBottom="1px solid"
borderColor="gray.700"
as="header"
>
<Container
maxW="1140px"
h="100%"
display="flex"
justifyContent="space-between"
>
<ThresholdBrand />
<MobileDrawer
isOpen={isDrawerOpen}
onClose={onDrawerClose}
navLinks={navLinks}
socialLinks={socialLinks}
/>
<DesktopNavLinks navLinks={navLinks} />
<SocialMediaLinks links={socialLinks} pl={8} />
<HamburgerButton openDrawer={onDrawOpen} />
</Container>
</HStack>
</>
)
}
23 changes: 12 additions & 11 deletions src/content/components/nav-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ nav_items:
url: /earn/btc
- label: Token Holder
url: /earn/token-holder
- label: Build
isExternal: false
subitems:
- label: tBTC SDK
url: /build/tbtc-sdk
- label: Docs
url: https://docs.threshold.network/
isExternal: true
- label: Governance
url: /governance
- label: Ecosystem
url: /ecosystem
- label: News
- label: About
subitems:
- label: Press
url: /press
- label: Blog
url: https://blog.threshold.network/
isExternal: true
- label: About
subitems:
- label: Docs
url: https://docs.threshold.network/
isExternal: true
- label: Contributors
url: /about#contributors
- label: FAQ
Expand All @@ -38,6 +41,9 @@ nav_items:
- label: Brand Assets
url: https://bit.ly/threshold-brand-assets
isExternal: true
menu_buttons:
- label: tBTC dApp
url: https://dashboard.threshold.network/tBTC
social_links:
- label: Twitter
url: https://twitter.com/TheTNetwork
Expand All @@ -54,11 +60,6 @@ social_links:
icon:
image: /images/discord.svg
alt: Threshold Discord
- label: Discourse
url: https://forum.threshold.network
icon:
image: /images/discourse-resources.svg
alt: Threshold Forum
- label: GitHub
url: https://github.com/threshold-network
icon:
Expand Down
5 changes: 5 additions & 0 deletions src/content/pages/build/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
template: build-page
path: /build
title: Build
---
Loading