npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

v-timeline-component

v0.3.0

Published

Customizable timeline component for Vue

Downloads

1,048

Readme

v-timeline-component

Customizable Timeline Component for Vue

The v-timeline-component is a slot based vue.js component that displays events in a timeline format. It offers both vertical and horizontal layouts, enabling customization of event presentation, styling, and content.

Features

  • Layout Customization: Choose between vertical and horizontal layouts to suit your application's needs.
  • Event Customization: Provide your own events with title, date, and description.
  • Custom Content Support: Utilize slots to insert custom content for each event.
  • Styling Customization: Adjust the color, marker size, and line width to match your desired aesthetic.

Installation

To use the v-timeline-component, install it via npm:

npm install v-timeline-component

Basic Example (Vertical Layout)

<template>
  <vTimelineComponent
    layout="vertical"
    :events="timelineEvents"
    line-width="1px"
  >
    <template #default="{ event }: { event: TimelineEvent, index: number }">
      <p>{{ event.title }}</p>
      <p>{{ event.description }}</p>
      <p>{{ event.date }}</p>
    </template>
  </vTimelineComponent>
</template>
<script setup lang="ts">
interface TimelineEvent {
  title: string;
  date: string;
  description: string;
  child?: TimelineEvent[];
}
const timelineEvents: Ref<TimelineEvent[]> = ref([
  {
    title: "Event 1 Title",
    date: "2023-02-15",
    description: "Description for the first event. This can be any text.",
    child: [
      {
        title: "child Lorem ipsum dolor sit amet 1",
        date: "2023-02-16",
        description:
          "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sit amet nulla auctor, vestibulum magna sed, convallis ex.",
      },
      {
        title: "child Lorem ipsum dolor sit amet 2",
        date: "2023-02-17",
        description:
          "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sit amet nulla auctor, vestibulum magna sed, convallis ex.",
      },
    ],
  },
  {
    title: "Event 2 Title",
    date: "2023-03-01",
    description: "This is the second event on our timeline.",
  },
  {
    title: "Event 3 Title",
    date: "2023-04-20",
    description:
      "Aperiam animi ut. Odit ullam eaque. Iusto laboriosam non nulla nisi soluta nobis est dolor ea",
  },
]);
</script>

Example (Horizontal Layout)

<vTimelineComponent
    layout="horizontal"
    :events="timelineEvents"
    line-width="1px"
  >
    <template #default="{ event }: { event: TimelineEvent, index: number }">
      <p>{{ event.title }}</p>
      <p>{{ event.description }}</p>
      <p>{{ event.date }}</p>
      <vTimelineComponent
        v-if="event.child"
        layout="vertical"
        :events="event.child"
        line-width="2px"
      >
        <template #default="{ event }: { event: TimelineEvent, index: number }">
          <p>{{ event.title }}</p>
          <p>{{ event.description }}</p>
          <p>{{ event.date }}</p>
        </template>
      </vTimelineComponent>
    </template>
  </vTimelineComponent>

Available Props

| Property | Type | Default | Description | | :------------- | :-------------- | :----------- | :-------------------------------------------- | | color | String | #ddd | Timeline line and marker color. | | markerSize | String | 0.75rem | Size of event markers. | | lineWidth | String | 2px | Width of the timeline line. | | layout | String | vertical | Timeline layout (vertical or horizontal). | | events | Array<Object> | Required | Array of event objects. |

Slots

Default Slot

The default slot allows for custom content within each event on the timeline. It provides the event and index of the event.

<template #default="{ event, index }">
  <!-- Custom content for each event -->
</template>

Marker Slot

The #marker slot allows for custom markers for each timeline event. Use it to customize the appearance of markers with custom elements or emojis.

<template #marker>💜</template>

Or dynamically with event data:


<template #marker="{ event }"> {{ event.marker }} </template>

👉 example

Contributing

If you would like to contribute to this project, feel free to fork the repository and submit a pull request. Contributions are welcome!