Get started
Examples

Waypoint card

Waypoint card

WaypointCard shows everything a place records: a headline, its services, its contacts and its timing.

src/HutCard.tsx
import type { Waypoint } from "@mountaya/elements/profile";
import { WaypointCard } from "@mountaya/elements-react/elements";
import "@mountaya/elements-react/styles.css";

// A waypoint from an itinerary you read, such as an item of `itineraryWaypoints(itinerary)`.
export const HutCard = ({ waypoint }: { readonly waypoint: Waypoint }) => (
  <WaypointCard waypoint={waypoint} />
);

In your own markup

useWaypointCard resolves the same facts and renders nothing, so your design system draws them.

src/HutFacts.tsx
import type { Waypoint } from "@mountaya/elements/profile";
import { useWaypointCard } from "@mountaya/elements-react/elements";
import { Fragment } from "react";

export const HutFacts = ({ waypoint }: { readonly waypoint: Waypoint }) => {
  const card = useWaypointCard({ waypoint });

  return (
    <dl>
      <dt>Summary</dt>
      <dd>{card.headline}</dd>
      <dt>Services</dt>
      <dd>{card.amenities.map((amenity) => amenity.name).join(" ยท ")}</dd>
      {card.timing.map((row) => (
        <Fragment key={row.label}>
          <dt>{row.label}</dt>
          <dd>{row.value}</dd>
        </Fragment>
      ))}
    </dl>
  );
};

Next steps

Last updated