Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits committed Feb 14, 2024
1 parent b897cb9 commit 93b65a7
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 43 deletions.
11 changes: 1 addition & 10 deletions src/app/(sidebar)/account/template.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { Icon } from "@stellar/design-system";
import { LayoutSidebarContent } from "@/components/LayoutSidebarContent";
import { LayoutSidebarContent } from "@/components/layout/LayoutSidebarContent";
import { Routes } from "@/constants/routes";

export default function AccountTemplate({
Expand All @@ -21,14 +20,6 @@ export default function AccountTemplate({
route: Routes.FUND_ACCOUNT,
label: "Fund Account",
},
{
route: Routes.CREATE_MUXED_ACCOUNT,
label: "Create Muxed Account",
},
{
route: Routes.PARSE_MUXED_ACCOUNT,
label: "Parse Muxed Account",
},
],
}}
>
Expand Down
10 changes: 3 additions & 7 deletions src/app/(sidebar)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { LayoutSidebar } from "@/components/LayoutSidebar";
import { LayoutWithSidebar } from "@/components/layout/LayoutWithSidebar";

export default function LayoutWithSidebar({
children,
}: {
children: React.ReactNode;
}) {
return <LayoutSidebar>{children}</LayoutSidebar>;
export default function Layout({ children }: { children: React.ReactNode }) {
return <LayoutWithSidebar>{children}</LayoutWithSidebar>;
}
3 changes: 2 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { Metadata } from "next";

import { LayoutMain } from "@/components/LayoutMain";
import { LayoutMain } from "@/components/layout/LayoutMain";

import "@stellar/design-system/build/styles.min.css";
import "@/styles/globals.scss";

// TODO: update metadata
export const metadata: Metadata = {
title: "Laboratory - Stellar",
description: "",
Expand Down
6 changes: 4 additions & 2 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import Link from "next/link";

import { Routes } from "@/constants/routes";
import { LayoutContentContainer } from "@/components/layout/LayoutContentContainer";

// TODO: update 404
export default function NotFound() {
return (
<div>
<LayoutContentContainer>
<h2>Not Found</h2>
<p>Could not find requested resource</p>
<Link href={Routes.ROOT}>Return Home</Link>
</div>
</LayoutContentContainer>
);
}
10 changes: 5 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import { LayoutContentContainer } from "@/components/layout/LayoutContentContainer";

export default function Introduction() {
return (
<div className="LabLayout__container">
<div className="LabLayout__content">
<div>Introduction</div>
</div>
</div>
<LayoutContentContainer>
<div>Introduction</div>
</LayoutContentContainer>
);
}
13 changes: 2 additions & 11 deletions src/components/MainNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NextLink from "next/link";
import { usePathname } from "next/navigation";

import { Routes } from "@/constants/routes";
import { NextLink } from "@/components/NextLink";

type NavLink = {
href: Routes | string;
Expand All @@ -23,7 +23,7 @@ const primaryNavLinks: NavLink[] = [
},
];

const secondaryNavLinks = [
const secondaryNavLinks: NavLink[] = [
{
href: "https://developers.stellar.org/docs",
label: "View Documentation",
Expand All @@ -33,14 +33,6 @@ const secondaryNavLinks = [
export const MainNav = () => {
const pathname = usePathname();

const externalLinkProps = (href: string) => {
const isExternalLink = href?.startsWith("http") || href?.startsWith("//");

return isExternalLink
? { rel: "noreferrer noopener", target: "_blank" }
: {};
};

const isActiveRoute = (link: string) => {
if (link.startsWith("http")) {
return false;
Expand All @@ -53,7 +45,6 @@ export const MainNav = () => {
<NextLink
href={link.href}
className={`NavLink ${isActiveRoute(link.href) ? "NavLink--active" : ""}`}
{...externalLinkProps(link.href)}
>
{link.label}
</NextLink>
Expand Down
17 changes: 17 additions & 0 deletions src/components/NextLink.tsx
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())} />;
};
4 changes: 2 additions & 2 deletions src/components/NavLink.tsx → src/components/SdsLink.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import NextLink from "next/link";
import { Props as LinkProps, Link } from "@stellar/design-system";

/** Use `NavLink` instead of `Link` from Stellar Design System to support client-side routing. `NavLink` uses `Link` from `next/link` internally. */
export const NavLink = (props: LinkProps) => {
/** 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}
Expand Down
9 changes: 9 additions & 0 deletions src/components/layout/LayoutContentContainer.tsx
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>
);
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import { ReactNode } from "react";
import { usePathname } from "next/navigation";
import NextLink from "next/link";
import { Routes } from "@/constants/routes";
import { Icon } from "@stellar/design-system";
import { Routes } from "@/constants/routes";
import { NextLink } from "@/components/NextLink";

export type SidebarLink = {
route: Routes | string;
Expand Down Expand Up @@ -43,9 +43,13 @@ export const LayoutSidebarContent = ({
<>
<div className="LabLayout__sidebar">
<div className="LabLayout__sidebar--top">
{/* TODO: add instruction */}
{/* TODO: render nested items */}
{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} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import { ReactNode } from "react";

export const LayoutSidebar = ({ children }: { children: ReactNode }) => {
export const LayoutWithSidebar = ({ children }: { children: ReactNode }) => {
return <div className="LabLayout__withSidebar">{children}</div>;
};
7 changes: 7 additions & 0 deletions src/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@
flex-direction: column;
gap: pxToRem(8px);
}

&__instruction {
font-size: pxToRem(12px);
line-height: pxToRem(18px);
font-weight: var(--sds-fw-medium);
margin-bottom: pxToRem(4px);
}
}
}

Expand Down

0 comments on commit 93b65a7

Please sign in to comment.