Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

fix footer prop type error

0divc68a489cc452
diff --git a/apps/web/src/components/Footer.tsx b/apps/web/src/components/Footer.tsx
index ffcc2d179..4d34e2cec 100644
--- a/apps/web/src/components/Footer.tsx
+++ b/apps/web/src/components/Footer.tsx
@@ -5,15 +5,15 @@ import { usePathname } from 'next/navigation'
import { Button } from '@/components/Button'
import { routes } from '@/components/Navigation/routes'
-import { TwitterIcon } from '@/components/icons/TwitterIcon'
-import { GitHubIcon } from '@/components/icons/GitHubIcon'
import { DiscordIcon } from '@/components/icons/DiscordIcon'
+import { GitHubIcon } from '@/components/icons/GitHubIcon'
+import { TwitterIcon } from '@/components/icons/TwitterIcon'
function PageLink({
- label,
- page,
- previous = false,
- }: {
+ label,
+ page,
+ previous = false,
+}: {
label: string
page: { href: string; title: string }
previous?: boolean
@@ -43,10 +43,27 @@ function PageLink({
function PageNavigation() {
let initialPathname = usePathname()
// Running on the server, there's bug with usePathname() and basePath https://github.com/vercel/next.js/issues/52700
- if (typeof window === 'undefined' && initialPathname === '/') initialPathname = '/docs'
+ if (typeof window === 'undefined' && initialPathname === '/')
+ initialPathname = '/docs'
- const allPages = routes.flatMap(group => group.links)
- const currentPageIndex = allPages.findIndex(page => page.href === initialPathname)
+ const allPages = routes.flatMap((group) => {
+ if ('links' in group) {
+ return group.links.flatMap((link) => {
+ if ('links' in link) {
+ return {
+ title: link.title,
+ href: link.href,
+ icon: link.icon,
+ }
+ }
+ return link
+ })
+ }
+ return [group]
+ })
+ const currentPageIndex = allPages.findIndex(
+ (page) => page.href === initialPathname
+ )
if (currentPageIndex === -1) return null
@@ -59,19 +76,12 @@ function PageNavigation() {
<div className="flex">
{previousPage && (
<div className="flex flex-col items-start gap-3">
- <PageLink
- label="Previous"
- page={previousPage}
- previous
- />
+ <PageLink label="Previous" page={previousPage} previous />
</div>
)}
{nextPage && (
<div className="ml-auto flex flex-col items-end gap-3">
- <PageLink
- label="Next"
- page={nextPage}
- />
+ <PageLink label="Next" page={nextPage} />
</div>
)}
</div>
@@ -79,21 +89,18 @@ function PageNavigation() {
}
function SocialLink({
- href,
- icon: Icon,
- children,
- }: {
+ href,
+ icon: Icon,
+ children,
+}: {
href: string
icon: React.ComponentType<{ className?: string }>
children: React.ReactNode
}) {
return (
- <Link
- href={href}
- className="group"
- >
+ <Link href={href} className="group">
<span className="sr-only">{children}</span>
- <Icon className="h-5 w-5 fill-zinc-700 transition group-hover:fill-zinc-900 dark:group-hover:fill-zinc-500"/>
+ <Icon className="h-5 w-5 fill-zinc-700 transition group-hover:fill-zinc-900 dark:group-hover:fill-zinc-500" />
</Link>
)
}
@@ -103,29 +110,21 @@ function SmallPrint() {
<div className="flex flex-col w-full items-center px-10 justify-between gap-5 pt-8 dark:border-white/5 sm:flex-row">
<div className="flex flex-col items-center justify-start lg:items-start">
<p className="text-xs text-zinc-600 dark:text-zinc-400">
- &copy; FoundryLabs, Inc. {new Date().getFullYear()}. All rights reserved.
+ &copy; FoundryLabs, Inc. {new Date().getFullYear()}. All rights
+ reserved.
</p>
<p className="text-xs text-zinc-600 dark:text-zinc-400">
548 Market Street #83122, San Francisco, CA 94104
</p>
</div>
<div className="flex gap-4">
- <SocialLink
- href="https://twitter.com/e2b_dev"
- icon={TwitterIcon}
- >
+ <SocialLink href="https://twitter.com/e2b_dev" icon={TwitterIcon}>
Follow us on Twitter
</SocialLink>
- <SocialLink
- href="https://github.com/e2b-dev"
- icon={GitHubIcon}
- >
+ <SocialLink href="https://github.com/e2b-dev" icon={GitHubIcon}>
Follow us on GitHub
</SocialLink>
- <SocialLink
- href="https://discord.gg/U7KEcGErtQ"
- icon={DiscordIcon}
- >
+ <SocialLink href="https://discord.gg/U7KEcGErtQ" icon={DiscordIcon}>
Join our Discord server
</SocialLink>
</div>
@@ -136,8 +135,8 @@ function SmallPrint() {
export function Footer() {
return (
<footer className="mx-auto w-full max-w-2xl space-y-10 pb-16 lg:max-w-5xl">
- <PageNavigation/>
- <SmallPrint/>
+ <PageNavigation />
+ <SmallPrint />
</footer>
)
}
@@ -146,8 +145,8 @@ export function FooterMain() {
return (
<footer className="flex w-full space-y-10 pb-16">
<div className="flex flex-col w-full items-center justify-center border-t border-zinc-900/5 dark:border-white/5">
- <SmallPrint/>
+ <SmallPrint />
</div>
</footer>
)
-}
\ No newline at end of file
+}
diff --git a/apps/web/src/components/Navigation/index.tsx b/apps/web/src/components/Navigation/index.tsx
index 25e020a4c..daab33929 100644
--- a/apps/web/src/components/Navigation/index.tsx
+++ b/apps/web/src/components/Navigation/index.tsx
@@ -1,16 +1,16 @@
'use client'
-import clsx from 'clsx'
-import { AnimatePresence, motion, useIsPresent } from 'framer-motion'
+import { useRef } from 'react'
import Link from 'next/link'
import { usePathname } from 'next/navigation'
-import { useRef } from 'react'
+import clsx from 'clsx'
+import { AnimatePresence, motion, useIsPresent } from 'framer-motion'
-import { Auth } from '@/components/Auth'
import { useIsInsideMobileNavigation } from '@/components/MobileNavigation'
import { useSectionStore } from '@/components/SectionProvider'
import { Tag } from '@/components/Tag'
import { remToPx } from '@/lib/remToPx'
+import { Auth } from '@/components/Auth'
import { routes } from './routes'
interface NavGroup {
@@ -76,14 +76,17 @@ function NavLink({
? 'text-zinc-900 dark:text-white'
: 'text-zinc-600 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white',
isFontMono ? 'font-mono text-xs' : '',
- className
+ className,
)}
>
<div className="flex items-center justify-start gap-1">
{icon}
{tag ? (
<div className="flex items-center gap-2">
- <Tag variant="small" color="emerald">
+ <Tag
+ variant="small"
+ color="emerald"
+ >
{tag}
</Tag>
<span className={clsx('truncate', active ? 'text-white' : '')}>
@@ -91,9 +94,7 @@ function NavLink({
</span>
</div>
) : (
- <span className={clsx('truncate', active ? 'text-white' : '')}>
- {children}
- </span>
+ <span className={clsx('truncate', active ? 'text-white' : '')}>{children}</span>
)}
</div>
</Link>
@@ -102,27 +103,19 @@ function NavLink({
function VisibleSectionHighlight({ group, pathname }) {
const [sections, visibleSections] = useInitialValue(
- [
- useSectionStore((s) => s.sections),
- useSectionStore((s) => s.visibleSections),
- ],
- useIsInsideMobileNavigation()
+ [useSectionStore(s => s.sections), useSectionStore(s => s.visibleSections)],
+ useIsInsideMobileNavigation(),
)
const isPresent = useIsPresent()
const firstVisibleSectionIndex = Math.max(
0,
- [{ id: '_top' }, ...sections].findIndex(
- (section) => section.id === visibleSections[0]
- )
+ [{ id: '_top' }, ...sections].findIndex(section => section.id === visibleSections[0]),
)
const itemHeight = remToPx(2)
- const height = isPresent
- ? Math.max(1, visibleSections.length) * itemHeight
- : itemHeight
+ const height = isPresent ? Math.max(1, visibleSections.length) * itemHeight : itemHeight
const activePageIndex = activeGroupIndex(group, pathname)
- const top =
- activePageIndex * itemHeight + firstVisibleSectionIndex * itemHeight
+ const top = activePageIndex * itemHeight + firstVisibleSectionIndex * itemHeight
return (
<motion.div
@@ -136,13 +129,7 @@ function VisibleSectionHighlight({ group, pathname }) {
)
}
-function ActivePageMarker({
- group,
- pathname,
-}: {
- group: NavGroup
- pathname: string
-}) {
+function ActivePageMarker({ group, pathname }: { group: NavGroup; pathname: string }) {
const itemHeight = remToPx(2)
const offset = remToPx(0.25)
const activePageIndex = activeGroupIndex(group, pathname)
@@ -168,8 +155,8 @@ function NavigationGroup({ group, className }) {
const initialPathname = usePathname()
const [pathname, sections] = useInitialValue(
- [initialPathname, useSectionStore((s) => s.sections)],
- isInsideMobileNavigation
+ [initialPathname, useSectionStore(s => s.sections)],
+ isInsideMobileNavigation,
)
if (!pathname) {
@@ -189,7 +176,10 @@ function NavigationGroup({ group, className }) {
<div className="relative mt-3 pl-2">
<AnimatePresence initial={!isInsideMobileNavigation}>
{isActiveGroup && (
- <VisibleSectionHighlight group={group} pathname={pathname} />
+ <VisibleSectionHighlight
+ group={group}
+ pathname={pathname}
+ />
)}
</AnimatePresence>
<motion.div
@@ -198,37 +188,41 @@ function NavigationGroup({ group, className }) {
/>
<AnimatePresence initial={false}>
{isActiveGroup && (
- <ActivePageMarker group={group} pathname={pathname} />
+ <ActivePageMarker
+ group={group}
+ pathname={pathname}
+ />
)}
</AnimatePresence>
- <ul role="list" className="border-l border-transparent">
- {group.links.map((link) => (
+ <ul
+ role="list"
+ className="border-l border-transparent"
+ >
+ {group.links.map(link => (
<motion.li
- key={link.href || `link-${link.title}`}
+ key={link.href}
layout="position"
className="relative"
>
- {link.href ? (
- <NavLink
- className="font-medium"
- href={link.href}
- active={
- `/docs${link.href}` === pathname ||
- // Special case for index (/)
- (link.href === '/' && pathname === '/docs')
- }
- isFontMono={link.isFontMono}
- icon={link.icon}
- tag={link.tag}
- >
- {link.title}
- </NavLink>
- ) : (
- <span className="block py-1 pl-4 pr-3 text-sm text-zinc-600 dark:text-zinc-400">
- {link.title}
- </span>
- )}
- <AnimatePresence mode="popLayout" initial={false}>
+ {/* @ts-ignore */}
+ <NavLink
+ className="font-medium"
+ href={link.href}
+ active={
+ `/docs${link.href}` === pathname ||
+ // Special case for index (/)
+ (link.href == '/' && pathname == '/docs')
+ }
+ isFontMono={link.isFontMono}
+ icon={link.icon}
+ tag={link.tag}
+ >
+ {link.title}
+ </NavLink>
+ <AnimatePresence
+ mode="popLayout"
+ initial={false}
+ >
{`/docs${link.href}` === pathname && sections.length > 0 && (
<motion.ul
role="list"
@@ -242,7 +236,7 @@ function NavigationGroup({ group, className }) {
transition: { duration: 0.15 },
}}
>
- {sections.map((section) => (
+ {sections.map(section => (
<li key={section.id}>
{/* @ts-ignore */}
<NavLink
@@ -266,6 +260,7 @@ function NavigationGroup({ group, className }) {
)
}
+
export function Navigation(props) {
return (
<nav {...props}>
@@ -296,7 +291,7 @@ export function Navigation(props) {
}
function activeGroupIndex(group: NavGroup, pathname: string) {
- return group.links.findIndex((link) => {
+ return group.links.findIndex(link => {
return link.href === pathname
})
}