Skip to content

Commit

Permalink
configure nav base based on build options
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianscatularo committed Nov 21, 2023
1 parent 48ea968 commit d1bcc5b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
31 changes: 18 additions & 13 deletions apps/connect/src/components/atoms/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const AppBar = styled(MuiAppBar)(({ theme }) => ({
boxShadow: "none",
}));

const Link = styled(MuiLink)(({ theme }) => ({
type LinkProps = {
active?: boolean;
}

const Link = styled(MuiLink)<LinkProps>(({ theme, active }) => ({
...theme.typography.body2,
fontWeight: 600,
fontFamily: "Suisse BP Intl, sans-serif",
Expand All @@ -31,6 +35,7 @@ const Link = styled(MuiLink)(({ theme }) => ({
[theme.breakpoints.down("xs")]: {
marginLeft: theme.spacing(1),
},
textDecoration: active ? "underline" : "none",
":hover": {
textDecoration: "underline"
},
Expand Down Expand Up @@ -73,18 +78,18 @@ export default function NavBar() {
<Spacer />
<Hidden implementation="css" xsDown>
<div style={{ display: "flex", alignItems: "center" }}>
<Link
href=""
color="inherit"
>
Home
</Link>
<Link
href="usdc-bridge"
color="inherit"
>
USDC
</Link>
{
navBar.map(({ label, active, href }, idx) =>
<Link
key={`${label}_${idx}`}
href={href}
color="inherit"
active={active}
>
{label}
</Link>
)
}
<Box>
<Link
href="https://wormholescan.io"
Expand Down
8 changes: 8 additions & 0 deletions apps/connect/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
/// <reference types="vite/client" />

import type { WormholeConnectConfig } from "@wormhole-foundation/wormhole-connect";

type NavLink = {
label: string;
active?: boolean;
href: string;
}

declare global {
declare const wormholeConnectConfig: WormholeConnectConfig;
declare const navBar: NavLink[];
}
4 changes: 4 additions & 0 deletions apps/connect/vite.token-bridge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const PUBLIC_URL = viteConfig.base;
export default defineConfig({
...viteConfig,
define: {
navBar: [
{ label: "Home", active: true, href: `${PUBLIC_URL}/` },
{ label: "USDC", href: `${PUBLIC_URL}/usdc-bridge` }
],
wormholeConnectConfig: {
...viteConfig?.define?.wormholeConnectConfig,
moreNetworks: {
Expand Down
8 changes: 7 additions & 1 deletion apps/connect/vite.usdc-bridge.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { defineConfig } from 'vite'
import viteConfig from './vite.config'

const PUBLIC_URL = viteConfig.base;

// https://vitejs.dev/config/
export default defineConfig({
...viteConfig,
base: `${viteConfig.base}/usdc-bridge/`,
base: `${PUBLIC_URL}/usdc-bridge/`,
define: {
navBar: [
{ label: "Home", href: `${PUBLIC_URL}/` },
{ label: "USDC", active: true, href: `${PUBLIC_URL}/usdc-bridge` }
],
wormholeConnectConfig: {
...viteConfig?.define?.wormholeConnectConfig,
routes: ["cctpManual", "cctpRelay"],
Expand Down

0 comments on commit d1bcc5b

Please sign in to comment.