Skip to content

Commit

Permalink
add header buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahongsf committed Apr 28, 2024
1 parent 2e0effb commit 9d1857c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
20 changes: 20 additions & 0 deletions src/components/config-pages/header-buttons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

import Button from "@components/elements/button";
import { StanfordBasicSiteSetting } from "@lib/gql/__generated__/drupal.d";

type Props =
Omit<StanfordBasicSiteSetting, "__typename" | "id" | "metatag">


export const HeaderButtons = ({
sumSiteHeaderPrim,
sumSiteHeaderSec,
}: Props) => {
return (
<>
{sumSiteHeaderPrim && <Button href={sumSiteHeaderPrim.url} secondary>{sumSiteHeaderPrim.title}</Button>}
{sumSiteHeaderSec && <Button href={sumSiteHeaderSec.url}>{sumSiteHeaderSec.title}</Button>}
</>
)
}
export default HeaderButtons;
9 changes: 6 additions & 3 deletions src/components/global/page-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
StanfordGlobalMessage
} from "@lib/gql/__generated__/drupal.d";
import {isPreviewMode} from "@lib/drupal/utils";
import HeaderButtons from "@components/config-pages/header-buttons";

const PageHeader = async () => {
const menuItems = await getMenu(MenuAvailable.Main, isPreviewMode());
Expand All @@ -33,12 +34,14 @@ const PageHeader = async () => {
<div className="w-full border-b-2 lg:border-b-0">
<div className="centered min-h-50 pr-24 rs-py-2 lg:pr-0">
<div className="flex w-full justify-between">
<Lockup {...siteSettingsConfig} {...lockupSettingsConfig}/>
<Lockup {...siteSettingsConfig} {...lockupSettingsConfig} />
<div className="hidden lg:block">
<HeaderButtons {...siteSettingsConfig} />
</div>
</div>
</div>
</div>

<MainMenu menuItems={menuItems}/>
<MainMenu menuItems={menuItems} {...siteSettingsConfig}/>
</div>
</header>
)
Expand Down
11 changes: 8 additions & 3 deletions src/components/menu/main-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SiteSearchForm from "@components/search/site-search-form";
import useActiveTrail from "@lib/hooks/useActiveTrail";
import useOutsideClick from "@lib/hooks/useOutsideClick";
import { ArrowRightIcon, ChevronDownIcon, MagnifyingGlassIcon } from "@heroicons/react/20/solid";
import { MenuItem as MenuItemType } from "@lib/gql/__generated__/drupal.d";
import { MenuItem as MenuItemType, StanfordBasicSiteSetting } from "@lib/gql/__generated__/drupal.d";
import { clsx } from "clsx";
import { useBoolean, useEventListener } from "usehooks-ts";
import {
Expand All @@ -17,17 +17,19 @@ import {
useState,
} from "react";
import { usePathname } from "next/navigation";
import HeaderButtons from "@components/config-pages/header-buttons";

const menuLevelsToShow = 2;

type Props = {
type Props =
Omit<StanfordBasicSiteSetting, "__typename" | "id" | "metatag"> & {
/**
* Array of nested menu items.
*/
menuItems: MenuItemType[];
};

const MainMenu = ({ menuItems }: Props) => {
const MainMenu = ({ menuItems, ...siteSettingsConfig}: Props) => {
const buttonRef = useRef<HTMLButtonElement>(null);
const menuRef = useRef<HTMLDivElement>(null);
const navId = useId();
Expand Down Expand Up @@ -103,6 +105,9 @@ const MainMenu = ({ menuItems }: Props) => {
}
>
<SiteSearchForm className="px-10 lg:hidden" />
<div className="border-b border-spirited-light flex flex-col items-center mt-10 lg:hidden children:w-full children:centered">
<HeaderButtons {...siteSettingsConfig} />
</div>
<ul className="list-unstyled lg:flex lg:justify-end flex-wrap m-0 p-0">
{menuItems.map((item) => (
<MenuItem
Expand Down

0 comments on commit 9d1857c

Please sign in to comment.