Event detail

One customer event on a raised page: the date beside the name, its facts in a quiet row, the answer to the invitation as the one filled control with a follow-up in place, the agenda as a timeline, and who is going beside it.

Open full screen

Inset · Sidebar. <AppShell direction="inset">, the default: the navigation on the grey app frame, the page a raised white card inside it, scrolling within.

npx wideset add block-event-detail

Import the default export from @/blocks/wideset/event-detail. The files below are relative to your project's source directory.

Installed with this block
  • app-shell
  • avatar
  • block-styles
  • breadcrumbs
  • button
  • card
  • divider
  • dropdown-menu
  • form-field
  • icon-button
  • list-item
  • popup
  • segmented-control
  • select
  • sidebar
  • split-button
  • text-input
  • toast
  • utils
blocks/wideset/event-detail/index.tsx
'use client';

import '@/styles/wideset-blocks.css';

import { RiSideBarLine } from '@remixicon/react';
import { AppShell } from '@/components/ui/wideset/app-shell/AppShell';
import { Breadcrumbs } from '@/components/ui/wideset/breadcrumbs/Breadcrumbs';
import { cn } from '@/lib/wideset/utils';
import { IconButton } from '@/components/ui/wideset/button/IconButton';
import { ToastProvider, useToast } from '@/components/ui/wideset/toast/Toast.context';
import { useId, useState } from 'react';

import { AddToCalendarMenu } from './add-to-calendar-menu';
import { Agenda } from './agenda';
import { AttendeeList } from './attendee-list';
import { account, agenda, type Answer, event, going, hosts, me, practical, speakers } from './data';
import { EventHeader } from './event-header';
import { FactsList } from './facts-list';
import { HostList } from './host-list';
import { InviteColleague } from './invite-colleague';
import { RsvpControl } from './rsvp-control';
import { Section } from './section';
import { SharePopup } from './share-popup';
import { SideSection } from './side-section';
import { EventSidebar } from './sidebar';
import { SpeakerList } from './speaker-list';

/** One column of the page: the header and the body share its edges. */
const COLUMN = 'px-ws-14 mx-auto w-full max-w-[80rem]';

const calendarEntry = {
  title: event.name,
  start: event.start,
  end: event.end,
  location: `${event.venue.name}, ${event.venue.address} ${event.venue.postcode}`,
  details: `${event.summary}\n\n${event.link}`,
};

/** The page: the event and the answer to it, then what happens there beside who will be there. */
function EventDetailPage() {
  const sidebarId = useId();
  const { showToast } = useToast();
  const [collapsed, setCollapsed] = useState(false);
  const [answer, setAnswer] = useState<Answer | null>(null);

  const people = answer === 'going' ? [me, ...going] : going;

  return (
    <AppShell className="ws-block-utility" direction="inset">
      <EventSidebar id={sidebarId} collapsed={collapsed} onCollapsedChange={setCollapsed} />
      <AppShell.Main>
        <div className="h-ws-18 border-ws-static-base flex shrink-0 items-center border-b">
          {/* The bar belongs to the surround: it runs edge to edge. The sidebar's toggle is pulled
              left so its glyph, not its box, sits 20px from the edge; the crumbs follow it. */}
          <div className="gap-ws-5 px-ws-11 flex w-full items-center">
            <IconButton
              icon={RiSideBarLine}
              variant="secondary"
              preset="ghost"
              size="sm"
              iconClassName="text-ws-static-subtle size-ws-9"
              aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
              aria-expanded={!collapsed}
              aria-controls={sidebarId}
              onClick={() => setCollapsed((collapsed) => !collapsed)}
              className="-ml-ws-5"
            />
            <Breadcrumbs separator="arrow">
              <Breadcrumbs.Item asChild>
                <a href="#events">Events</a>
              </Breadcrumbs.Item>
              <Breadcrumbs.Item>{event.name}</Breadcrumbs.Item>
            </Breadcrumbs>
          </div>
        </div>

        {/* The page scrolls inside the card, so the card's corners stay put. */}
        <div className="ws-scrollbar min-h-0 flex-1 overflow-y-auto">
          <div className={cn(COLUMN, 'gap-ws-14 pt-ws-14 pb-ws-16 flex flex-col')}>
            <EventHeader
              actions={
                <>
                  <AddToCalendarMenu entry={calendarEntry} />
                  <SharePopup
                    link={event.link}
                    onCopy={() => showToast({ content: 'Link copied' })}
                  />
                  <RsvpControl
                    answer={answer}
                    onAnswer={setAnswer}
                    email={account.email}
                    answerBy={event.answerBy}
                  />
                </>
              }
            />

            {/* What happens is in cards on the left; who will be there is a quiet side column,
                plain on the page. */}
            <div className="gap-ws-16 grid grid-cols-1 items-start lg:grid-cols-[minmax(0,1fr)_18rem]">
              <div className="gap-ws-12 flex min-w-0 flex-col">
                <Section title="About">
                  <div className="gap-ws-5 typography-body-md text-ws-static-base flex max-w-[44rem] flex-col">
                    {event.about.map((paragraph) => (
                      <p key={paragraph}>{paragraph}</p>
                    ))}
                  </div>
                </Section>
                <Section title="Agenda">
                  <Agenda sessions={agenda} />
                </Section>
                <Section title="Speakers">
                  <SpeakerList speakers={speakers} />
                </Section>
                <Section title="Practical information">
                  <FactsList facts={practical} />
                </Section>
              </div>

              {/* Dropped by the card header's inset, so "Who is going" stands on the cards'
                  title line. */}
              <aside aria-label="People" className="gap-ws-14 lg:pt-ws-9 flex flex-col">
                <SideSection title="Who is going">
                  <AttendeeList people={people} meId={me.id} />
                </SideSection>
                <SideSection title="Hosts">
                  <HostList hosts={hosts} />
                </SideSection>
                <SideSection title="Invite a colleague">
                  <InviteColleague
                    onInvite={(email) =>
                      showToast({ status: 'success', content: `Invitation sent to ${email}` })
                    }
                  />
                </SideSection>
              </aside>
            </div>
          </div>
        </div>
      </AppShell.Main>
    </AppShell>
  );
}

/**
 * Event detail (Inset direction): one customer event on the raised page beside the workspace
 * sidebar. No hero and no banner: the header carries the date as a leaf over the name, the facts
 * in a quiet row, and the answer to the invitation as the one filled control. Below, in bordered
 * cards, what happens (about, the agenda as a timeline, the speakers, the practical facts) beside
 * a plain side column of who will be there (who is going, the hosts, inviting a colleague).
 */
export default function EventDetail() {
  return (
    <ToastProvider position="bottom-center">
      <EventDetailPage />
    </ToastProvider>
  );
}