-
Notifications
You must be signed in to change notification settings - Fork 100
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
V2 Layout and basic page setup #740
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b897cb9
Layout mostly done
quietbits 93b65a7
Cleanup
quietbits df5355f
Updated next.config.js
quietbits b18afe2
Delete extra folders
quietbits 4b44926
Remove trailingSlash config
quietbits f644d75
Add console.log for testing
quietbits File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use client"; | ||
|
||
export default function CreateAccount() { | ||
return <div>Create Account</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use client"; | ||
|
||
export default function FundAccount() { | ||
return <div>Fund Account</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use client"; | ||
|
||
export default function Account() { | ||
return <div>Account content</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use client"; | ||
|
||
import { LayoutSidebarContent } from "@/components/layout/LayoutSidebarContent"; | ||
import { Routes } from "@/constants/routes"; | ||
|
||
export default function AccountTemplate({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<LayoutSidebarContent | ||
sidebar={{ | ||
navItems: [ | ||
{ | ||
route: Routes.CREATE_ACCOUNT, | ||
label: "Create Account", | ||
}, | ||
{ | ||
route: Routes.FUND_ACCOUNT, | ||
label: "Fund Account", | ||
}, | ||
], | ||
}} | ||
> | ||
{children} | ||
</LayoutSidebarContent> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { LayoutWithSidebar } from "@/components/layout/LayoutWithSidebar"; | ||
|
||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return <LayoutWithSidebar>{children}</LayoutWithSidebar>; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
|
||
import { Routes } from "@/constants/routes"; | ||
import { LayoutContentContainer } from "@/components/layout/LayoutContentContainer"; | ||
|
||
// TODO: update 404 | ||
export default function NotFound() { | ||
return ( | ||
<LayoutContentContainer> | ||
<h2>Not Found</h2> | ||
<p>Could not find requested resource</p> | ||
<Link href={Routes.ROOT}>Return Home</Link> | ||
</LayoutContentContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
"use client"; | ||
|
||
import { Layout } from "@stellar/design-system"; | ||
import { LayoutContentContainer } from "@/components/layout/LayoutContentContainer"; | ||
|
||
export default function Home() { | ||
return <Layout.Inset>Page</Layout.Inset>; | ||
export default function Introduction() { | ||
return ( | ||
<LayoutContentContainer> | ||
<div>Introduction</div> | ||
</LayoutContentContainer> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { usePathname, useSearchParams } from "next/navigation"; | ||
|
||
import { Routes } from "@/constants/routes"; | ||
import { NextLink } from "@/components/NextLink"; | ||
|
||
type NavLink = { | ||
href: Routes | string; | ||
label: string; | ||
}; | ||
|
||
const primaryNavLinks: NavLink[] = [ | ||
{ | ||
href: Routes.ROOT, | ||
label: "Introduction", | ||
}, | ||
{ | ||
href: Routes.CREATE_ACCOUNT, | ||
label: "Account", | ||
}, | ||
{ | ||
href: Routes.EXPLORE_ENDPOINTS, | ||
label: "Explore Endpoints", | ||
}, | ||
]; | ||
|
||
const secondaryNavLinks: NavLink[] = [ | ||
{ | ||
href: "https://developers.stellar.org/docs", | ||
label: "View Documentation", | ||
}, | ||
]; | ||
|
||
export const MainNav = () => { | ||
const pathname = usePathname(); | ||
const searchParams = useSearchParams(); | ||
|
||
console.log(">>> pathname: ", pathname); | ||
console.log(">>> searchParams: ", searchParams.toString()); | ||
|
||
const isActiveRoute = (link: string) => { | ||
if (link.startsWith("http")) { | ||
return false; | ||
} | ||
|
||
return pathname.split("/")[1] === link.split("/")[1]; | ||
}; | ||
|
||
const NavItem = ({ link }: { link: NavLink }) => ( | ||
<NextLink | ||
href={link.href} | ||
className={`NavLink ${isActiveRoute(link.href) ? "NavLink--active" : ""}`} | ||
> | ||
{link.label} | ||
</NextLink> | ||
); | ||
|
||
return ( | ||
<nav className="LabLayout__header__nav"> | ||
{/* Primary nav links */} | ||
<div className="LabLayout__header__nav--primary"> | ||
{primaryNavLinks.map((l) => ( | ||
<NavItem key={l.href} link={l} /> | ||
))} | ||
</div> | ||
{/* Secondary nav links */} | ||
<div className="LabLayout__header__nav--secondary"> | ||
{secondaryNavLinks.map((sl) => ( | ||
<NavItem key={sl.href} link={sl} /> | ||
))} | ||
</div> | ||
</nav> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ComponentProps } from "react"; | ||
import Link from "next/link"; | ||
|
||
type LinkProps = ComponentProps<typeof Link>; | ||
|
||
/** `NextLink` is extended `next/link`. */ | ||
export const NextLink = (props: LinkProps) => { | ||
const externalLinkProps = (href: string) => { | ||
const isExternalLink = href?.startsWith("http") || href?.startsWith("//"); | ||
|
||
return isExternalLink | ||
? { rel: "noreferrer noopener", target: "_blank" } | ||
: {}; | ||
}; | ||
|
||
return <Link {...props} {...externalLinkProps(props.href.toString())} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import NextLink from "next/link"; | ||
import { Props as LinkProps, Link } from "@stellar/design-system"; | ||
|
||
/** Use `SdsLink` instead of `Link` from Stellar Design System to support client-side routing. `SdsLink` uses `next/link` internally. */ | ||
export const SdsLink = (props: LinkProps) => { | ||
return ( | ||
<Link {...props} customAnchor={<NextLink href={props.href || ""} />}> | ||
{props.children} | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const LayoutContentContainer = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => ( | ||
<div className="LabLayout__container"> | ||
<div className="LabLayout__content">{children}</div> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
|
||
import { ReactNode } from "react"; | ||
import Link from "next/link"; | ||
|
||
import { ProjectLogo, ThemeSwitch } from "@stellar/design-system"; | ||
|
||
import { MainNav } from "@/components/MainNav"; | ||
|
||
export const LayoutMain = ({ children }: { children: ReactNode }) => { | ||
return ( | ||
<> | ||
<div className="LabLayout__header"> | ||
<header className="LabLayout__header__main"> | ||
<ProjectLogo | ||
title="Laboratory" | ||
link="/" | ||
customAnchor={<Link href="/" />} | ||
/> | ||
|
||
<div className="LabLayout__header__settings"> | ||
<ThemeSwitch storageKeyId="stellarTheme:Laboratory" /> | ||
</div> | ||
</header> | ||
<MainNav /> | ||
</div> | ||
|
||
{children} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
"use client"; | ||
|
||
import { ReactNode } from "react"; | ||
import { usePathname } from "next/navigation"; | ||
import { Icon } from "@stellar/design-system"; | ||
import { Routes } from "@/constants/routes"; | ||
import { NextLink } from "@/components/NextLink"; | ||
|
||
export type SidebarLink = { | ||
route: Routes | string; | ||
label: string; | ||
icon?: ReactNode; | ||
nestedItems?: SidebarLink[]; | ||
}; | ||
|
||
export type Sidebar = { | ||
navItems: SidebarLink[]; | ||
instruction?: string; | ||
bottomItems?: SidebarLink[]; | ||
}; | ||
|
||
export const LayoutSidebarContent = ({ | ||
children, | ||
sidebar, | ||
}: { | ||
children: ReactNode; | ||
sidebar: Sidebar; | ||
}) => { | ||
const pathname = usePathname(); | ||
|
||
const Link = ({ item }: { item: SidebarLink }) => ( | ||
<NextLink | ||
href={item.route} | ||
className={`SidebarLink ${ | ||
pathname === item.route ? "SidebarLink--active" : "" | ||
}`} | ||
> | ||
{item.icon ?? null} {item.label} | ||
</NextLink> | ||
); | ||
|
||
return ( | ||
<> | ||
<div className="LabLayout__sidebar"> | ||
<div className="LabLayout__sidebar--top"> | ||
{sidebar.instruction ? ( | ||
<div className="LabLayout__sidebar__instruction"> | ||
{sidebar.instruction} | ||
</div> | ||
) : null} | ||
|
||
{/* TODO: render nested items */} | ||
{sidebar.navItems.map((item) => ( | ||
<Link key={item.route} item={item} /> | ||
))} | ||
</div> | ||
<div | ||
className={`LabLayout__sidebar--bottom ${ | ||
sidebar.bottomItems?.length | ||
? "LabLayout__sidebar--bottom--border" | ||
: "" | ||
}`} | ||
> | ||
<div className="LabLayout__sidebar__wrapper"> | ||
{sidebar.bottomItems?.map((bi) => ( | ||
<Link key={bi.route} item={bi} /> | ||
))} | ||
</div> | ||
<div className="LabLayout__sidebar__wrapper"> | ||
<NextLink href="https://stellar.org" className="SidebarLink"> | ||
<Icon.MessageTextSquare02 /> Got product feedback? | ||
</NextLink> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="LabLayout__container"> | ||
<div className="LabLayout__content">{children}</div> | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use client"; | ||
|
||
import { ReactNode } from "react"; | ||
|
||
export const LayoutWithSidebar = ({ children }: { children: ReactNode }) => { | ||
return <div className="LabLayout__withSidebar">{children}</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export enum Routes { | ||
ROOT = "/", | ||
// Account | ||
CREATE_ACCOUNT = "/account/create", | ||
FUND_ACCOUNT = "/account/fund", | ||
CREATE_MUXED_ACCOUNT = "/account/muxed-create", | ||
PARSE_MUXED_ACCOUNT = "/account/muxed-parse", | ||
// Explore Endpoints | ||
EXPLORE_ENDPOINTS = "/explore-endpoints", | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving these for now to test server setup