Skip to content

Commit

Permalink
Add teaser and list behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Feb 28, 2024
1 parent 3677b01 commit 6e46294
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 114 deletions.
6 changes: 1 addition & 5 deletions app/search/algolia-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,8 @@ const SearchBox = (props?: UseSearchBoxProps) => {
const [inputValue, setInputValue] = useState<string>(query);
const inputRef = useRef<HTMLInputElement>(null);
const inputId = useId();

const isSearchStalled = status === 'stalled';

useEffect(() => {
if (query) router.replace(`?q=${query}`, {scroll: false})
}, [router, query])
router.replace(query ? `?q=${query}` : '?', {scroll: false})

return (
<form
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"@formkit/auto-animate": "^0.8.1",
"@heroicons/react": "^2.1.1",
"@js-temporal/polyfill": "^0.4.4",
"@mui/base": "^5.0.0-beta.33",
"@mui/base": "^5.0.0-beta.37",
"@next/third-parties": "^14.1.0",
"@tailwindcss/container-queries": "^0.1.1",
"@types/node": "^20.11.20",
"@types/node": "^20.11.22",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
"@uidotdev/usehooks": "^2.4.1",
Expand All @@ -42,9 +42,9 @@
"qs": "^6.11.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-focus-lock": "^2.11.1",
"react-instantsearch": "^7.6.0",
"react-instantsearch-nextjs": "^0.1.13",
"react-focus-lock": "^2.11.2",
"react-instantsearch": "^7.7.0",
"react-instantsearch-nextjs": "^0.1.14",
"react-tiny-oembed": "^1.1.0",
"sharp": "^0.33.2",
"tailwind-merge": "^2.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import Button from "@components/elements/button";
import {H2} from "@components/elements/headers";
import {HtmlHTMLAttributes} from "react";
import {ParagraphStanfordEntity} from "@lib/gql/__generated__/drupal.d";
import {twMerge} from "tailwind-merge";
import {getParagraphBehaviors} from "@components/paragraphs/get-paragraph-behaviors";

type Props = HtmlHTMLAttributes<HTMLDivElement> & {
paragraph: ParagraphStanfordEntity
}

const EntityParagraph = async ({paragraph, ...props}: Props) => {

const behaviors = getParagraphBehaviors(paragraph);
const entities = paragraph.suEntityItem || [];
const gridCols = [
'lg:grid-cols-3',
Expand All @@ -22,7 +24,9 @@ const EntityParagraph = async ({paragraph, ...props}: Props) => {
return (
<div className="centered lg:max-w-[980px] flex flex-col gap-10 mb-20" {...props}>
{paragraph.suEntityHeadline &&
<H2 className="text-center">{paragraph.suEntityHeadline}</H2>
<H2 className={twMerge("text-center", behaviors.stanford_teaser?.hide_heading && "sr-only")}>
{paragraph.suEntityHeadline}
</H2>
}

{paragraph.suEntityDescription?.processed &&
Expand Down
5 changes: 4 additions & 1 deletion src/components/paragraphs/stanford-lists/list-paragraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import {getParagraphBehaviors} from "@components/paragraphs/get-paragraph-behaviors";
import {graphqlClient} from "@lib/gql/fetcher";
import {buildHeaders} from "@lib/drupal/utils";
import {twMerge} from "tailwind-merge";

type Props = HtmlHTMLAttributes<HTMLDivElement> & {
paragraph: ParagraphStanfordList
Expand All @@ -29,7 +30,9 @@ const ListParagraph = async ({paragraph, ...props}: Props) => {
return (
<div className="centered lg:max-w-[980px] flex flex-col gap-10 mb-20" {...props}>
{paragraph.suListHeadline &&
<H2 className="text-center">{paragraph.suListHeadline}</H2>
<H2 className={twMerge("text-center", behaviors.list_paragraph?.hide_heading && "sr-only")}>
{paragraph.suListHeadline}
</H2>
}
{paragraph.suListDescription?.processed &&
<Wysiwyg html={paragraph.suListDescription.processed}/>
Expand Down
6 changes: 6 additions & 0 deletions src/lib/drupal/drupal-jsonapi.d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type LayoutParagraphBehaviors = {
export type ListParagraphBehaviors = {
hide_empty?: boolean
empty_message?: string
hide_heading?: boolean
}

export type CardParagraphBehaviors = {
Expand All @@ -22,9 +23,14 @@ export type BannerParagraphBehaviors = {
hide_heading?: string
}

export type TeaserParagraphBehaviors = {
hide_heading?: boolean
}

export type ParagraphBehaviors = {
layout_paragraphs?: LayoutParagraphBehaviors
list_paragraph?: ListParagraphBehaviors
su_card_styles?: CardParagraphBehaviors
hero_pattern?: BannerParagraphBehaviors
stanford_teaser?: TeaserParagraphBehaviors
}
52 changes: 28 additions & 24 deletions src/lib/gql/__generated__/drupal.d.ts

Large diffs are not rendered by default.

Loading

0 comments on commit 6e46294

Please sign in to comment.