Components
Timeline

Timeline

1. UI

app/timeline/page.js
import { Timeline } from "@palanikannan1437/rc4community-timeline";
 
export default async function TimelinePage() {
  return <Timeline type="horizontal" data={data} />;
}

Props

Propdescriptiontype
data*The data you want to showcase in the timeline, it could easily be fetched and transformedTimelineObjectType[]
typeDecides the alignment of the Timeline Component"vertical" | "horizontal"

2. Core

fetchTimelineData

Fetches and formats your data to support correct rendering in the UI

Propdescriptiontype
endpointThe url you want to fetch your data fromstring
transferTypeA custom function you can implement that transforms your data from the endpoint to TimelineObjectType[](data:any) => TimelineObjectType[]

Types

TimelineObjectType

Type of each Timeline object

Propdescriptiontype
idThe url you want to fetch your data fromany
titleThe title displayed for the timeline blockstring
metaThe meta infostring
subtitleThe subtitle displayed for the timeline blockstring
descriptionThe main content of the timeline blockstring

Example

How to use the Timeline Component

app/timeline/page.js
import {
  fetchTimelineData,
  TimelineObjectType,
  Timeline
} from "@palanikannan1437/rc4community-timeline";
 
function transferType(data: any): TimelineObjectType[] {
  const timeline = data.products;
  return timeline.map((timelineData: any) => {
    return {
      id: String(timelineData.id),
      title: String(timelineData.title),
      meta: String(timelineData.rating),
      subtitle: String(timelineData.category),
      description: String(timelineData.description),
    };
  });
}
 
export default async function TimelinePage() {
  const data = await fetchTimelineData({
    endpoint: "https://dummyjson.com/products?limit=5",
    transferType: transferType,
  });
 
  return <Timeline type="horizontal" data={data} />;
}