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

@1amageek/timetable

v1.0.1

Published

A flexible and customizable React timetable component using Luxon for datetime handling.

Downloads

127

Readme

Timetable

A flexible and customizable React timetable component using Luxon for datetime handling.

Features

  • 📅 Flexible timetable layout supporting multiple days
  • 🕒 Luxon-based datetime handling with timezone support
  • ✨ Event selection and multi-select support
  • 🎨 Customizable styling and themes
  • 📱 Responsive design
  • 💪 TypeScript support
  • 🔄 Context-based state management
  • 📚 Comprehensive documentation and Storybook

Installation

npm install @1amageek/timetable
# or
yarn add @1amageek/timetable
# or
pnpm add @1amageek/timetable

Quick Start

import { DateTime } from "luxon";
import { Timetable } from "react-luxon-timetable";

interface Event {
  id: string;
  start: DateTime;
  end: DateTime;
  title: string;
  type: string;
}

function App() {
  const events: Event[] = [
    {
      id: "1",
      start: DateTime.local(2024, 3, 1, 12, 0),
      end: DateTime.local(2024, 3, 1, 14, 0),
      title: "Team Meeting",
      type: "meeting"
    }
  ];

  return (
    <div className="h-screen">
      <Timetable
        start={DateTime.local(2024, 3, 1)}
        end={DateTime.local(2024, 3, 7)}
        items={events}
        onChange={(selectedIds) => console.log("Selected:", selectedIds)}
      >
        {(item) => (
          <div className="p-2 rounded-xl bg-blue-100 text-blue-800">
            <div className="font-medium">{item.title}</div>
            <div className="text-sm">
              {item.start.toFormat("HH:mm")} - {item.end.toFormat("HH:mm")}
            </div>
          </div>
        )}
      </Timetable>
    </div>
  );
}

Props

Timetable Props

interface TimetableProps<T extends Identifiable & DateTimeRange> {
  start: DateTime;              // Start date
  end: DateTime;               // End date
  items: T[];                  // Array of events
  options?: TimetableOptions;  // Optional configuration
  children: (item: T) => React.ReactNode;  // Render function for events
  onChange?: (selectedIds: string[]) => void;  // Selection change handler
}

interface TimetableOptions {
  cellHeight: number;     // Height of each time slot
  headerHeight: number;   // Height of the header
  paddingInsets: {       // Padding configuration
    top: number;
    left: number;
    right: number;
    bottom: number;
  };
}

Event Interface

interface DateTimeRange {
  start: DateTime;
  end: DateTime;
}

interface Identifiable {
  id: string;
}

// Your event type should extend both interfaces
interface Event extends Identifiable, DateTimeRange {
  title: string;
  // ... other properties
}

Advanced Usage

Custom Styling

<Timetable>
  {(item) => (
    <div
      className={`
        p-2 rounded-xl 
        ${item.type === "meeting" ? "bg-blue-100 text-blue-800" : ""}
        ${item.type === "lunch" ? "bg-green-100 text-green-800" : ""}
      `}
    >
      {item.title}
    </div>
  )}
</Timetable>

Development

Setup

# Clone the repository
git clone https://github.com/1amageek/timetable.git

# Install dependencies
npm install

# Start development server
npm run dev

# Run Storybook
npm run storybook

Building

# Build the library
npm run build

# Build Storybook documentation
npm run sb

License

MIT © [1amageek]