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

react-headless-agenda

v0.1.4

Published

Headless agenda for React

Downloads

11

Readme

Headless agenda for react

Completely unstyled components to build your own agenda. Give it a try! It's really simple to use, and allows fully customization (the markup is all yours!). It might look intimidating at first but I'm sure you'll like it.

This library makes it easy to display events in their respective columns (or "days"), with their corresponding position and height, based on their durations. It's not meant to be used as a "calendar" or a "month" view.

🔧 Flexible

✅ Controlled

🚀 Performant

💅🏻 Unstyled but easy to style

⏰ Uses the default Date object only

↔️ Supports drag and resize for events

📖 All examples and documentation here!

🚧🚧 This repo is under heavy development 🚧🚧

Use your markup and custom logic to achieve virtually anything!

full-example

A bit of framer-motion was used to make the navigation look smooth - See code

You can easily adapt it for mobile!

vertical_example

Installation

npm i react-headless-agenda

Usage

All examples use date-fns but you can use the library of your choice to manipulate dates.

<Agenda>

Our parent component. Just provide a start day, and some events.

import { startOfWeek, addHours }  from 'date-fns'

// only `start` and `end` are required! This event starts now and ends in five hours
const events = [
  {
    id: 'event1',
    someTitle: 'Hey there!',
    start: new Date(),
    end:  addHours(new Date(), 5),
  }
]

<Agenda
  startDate={startOfWeek(new Date())}
  events={events}
/>

This is a controlled component. The agenda will NOT have an "inner" state in sync with events or startDate. Instead, it will fire an event for you to update your state when needed. You'll find more of this in the docs.

<Days>

It lets you render whatever you need to, for each day. For example, let's render its name and number:

days header

import { format }  from 'date-fns'

<div className="flex">
  <Days>
    {({ date }) => (
      <div key={date.toString()} className="flex-1">
        {format(date, 'ccc d')}
      </div>
    )}
  </Days>
</div>

Now the fun part, render your events!

day

// this will be inside <Agenda/> and will receive the events from the context.
<Days>
  {({ date, containerRef, events }) => (
    <div
      key={date.toString()}
      ref={containerRef}
      className="relative h-full"
    >
      {events.map(({ event, top, bottom }) => (
        <div
          className="absolute w-full p-4 rounded-lg"
          style={{ top, bottom }}
        >
          {event.someTitle}
        </div>
      ))}
    </div>
  )}
</Days>

That's it! You also have <Ticks>, <Needle>, and <Crosshair>, but you'll learn them as you go.


PR's are welcome!