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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tristan-timeline

v0.1.9

Published

A modern React timeline component library extracted from tristan-ui

Readme

🎨 Tristan Design System

npm version License: MIT

Tristan UI Timeline

一个基于 Tristan UI 构建的现代 React 时间线组件库。

特性

🎯 易于使用 - 简单的 API 设计,快速上手
高性能 - 支持大量数据的虚拟化渲染
🎨 高度可定制 - 灵活的配置选项和样式定制
📱 响应式 - 完美适配桌面和移动设备
🔧 TypeScript - 完整的类型支持

安装

# 首先安装 tristan-ui(必需依赖)
npm install tristan-ui

# 然后安装 tristan-timeline
npm install tristan-timeline

快速开始

import React from 'react';
import { Timeline, TimelineConfigBuilder } from 'tristan-timeline';
import 'tristan-ui/style.css';

// 示例数据
const timelineData = [
  {
    id: '1',
    name: '项目启动',
    startDate: new Date('2024-01-01'),
    endDate: new Date('2024-01-15'),
    status: 'completed',
    priority: 'high'
  },
  {
    id: '2', 
    name: '开发阶段',
    startDate: new Date('2024-01-16'),
    endDate: new Date('2024-03-01'),
    status: 'in-progress',
    priority: 'medium'
  }
];

// 配置时间线显示
const config = new TimelineConfigBuilder()
  .addTag('status', {
    'completed': { name: '已完成', color: 'success' },
    'in-progress': { name: '进行中', color: 'warning' }
  })
  .addTag('priority', {
    'high': { name: '高优先级', color: 'error' },
    'medium': { name: '中优先级', color: 'info' }
  })
  .build();

function App() {
  return (
    <Timeline
      inputData={timelineData}
      init={config}
      groupBy="status"
    />
  );
}

主要组件

Timeline

主要的时间线组件,支持以下功能:

  • 数据分组和排序
  • 缩放和滚动
  • 自定义字段显示
  • URL 参数同步
  • 点击事件处理

TimelineConfigBuilder

配置构建器,用于定义时间线项目的显示方式:

const config = new TimelineConfigBuilder()
  .addProgress('completion', {
    showText: true,
    progressColors: [
      { upto: 30, color: 'error' },
      { upto: 70, color: 'warning' }, 
      { upto: 100, color: 'success' }
    ]
  })
  .addIcon('type', {
    'task': { icon: 'task', color: 'primary' },
    'milestone': { icon: 'flag', color: 'success' }
  })
  .build();

API 文档

Timeline Props

| 属性 | 类型 | 说明 | |------|------|------| | inputData | TimelineItemType[] | SortedTimelineDataType | 时间线数据 | | init | TimelineItemDisplayConfig | 显示配置 | | groupBy | keyof BaseTimelineItemType | 分组字段 | | groupByOptions | GroupByOption[] | 分组选项 | | zoomLevels | ZoomLevelType[] | 缩放级别 | | onItemClick | (item) => void | 点击事件处理 |

基础数据类型

interface BaseTimelineItemType {
  id: string;
  name: string;
  startDate: Date;
  endDate: Date;
}

// 您可以扩展这个基础类型
interface MyTimelineItem extends BaseTimelineItemType {
  status: 'pending' | 'in-progress' | 'completed';
  assignee: string;
  priority: 'low' | 'medium' | 'high';
}

Hooks

该库还导出了一些有用的 Hooks:

  • useTimelineUrlParams - URL 参数同步
  • useZoomLevelMonitor - 缩放级别监听
  • useVirtualizedTimeline - 虚拟化支持
  • useCenterBasedZoom - 中心缩放

样式定制

由于该库基于 Tristan UI 构建,您可以通过 Tristan UI 的主题系统来定制样式。

许可证

MIT

贡献

欢迎提交 Issue 和 Pull Request!

相关链接