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

@jyoketsu/timeline-react

v0.2.6

Published

Timeline Component for React / React时间轴组件

Downloads

1

Readme

Timeline-React(React 时间轴)


████████╗██╗███╗   ███╗███████╗██╗     ██╗███╗   ██╗███████╗
╚══██╔══╝██║████╗ ████║██╔════╝██║     ██║████╗  ██║██╔════╝
   ██║   ██║██╔████╔██║█████╗  ██║     ██║██╔██╗ ██║█████╗
   ██║   ██║██║╚██╔╝██║██╔══╝  ██║     ██║██║╚██╗██║██╔══╝
   ██║   ██║██║ ╚═╝ ██║███████╗███████╗██║██║ ╚████║███████╗
   ╚═╝   ╚═╝╚═╝     ╚═╝╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝

live demo

Installation

yarn add @jyoketsu/timeline-react

or

npm i @jyoketsu/timeline-react

Screenshot

fMg2wD.png

Use case

fB2aq0.png

Usage

import TimeLevel from '@jyoketsu/timeline-react/dist/interface/TimeLevel';

<div className={classes.timeViewer}>
  <Timeline handleDateChanged={handleDateChanged}>
    {/* children component */}
    <TimeNodes nodeGroups={nodeGroups} columnCount={columnCount} />
  </Timeline>
</div>;

Hold down the right button and drag

Props

| Props | Description | Type | isRequire | Default | | ---------------------- | ------------------------------------------------------------------------------------- | ------------------------- | --------- | ---------------------- | | timeLevels | 时间等级列表 | TimeLevel[] | 否 | 见下 | | initTimeLevel | 初始化时间等级 | TimeLevel | 否 | timeLevels[0] | | initTime | 初始化时间 | number (Millis Timestamp) | 否 | new Date().getTime() | | backgroundColor | 背景色 | string | 否 | #2C3C4E | | shiftX | 横向偏移,用于调整 hover 时竖线的位置 | number | 否 | 0 | | nodeList | 时间轴中的子节点列表 | NodeItem[] | 是 | - | | nodeHeight | 子节点元素高度 | number | 是 | - | | handleDateChanged | 数据变化事件 | DateChangedFunc | 否 | - | | handleClickAdd | 点击添加按钮 | ClickAddFunc | 否 | - | | wheelable | 是否可以滚动缩放 | boolean | 否 | true | | changeLevelRequestData | 切换 timeLevel 时是否重新获取数据,如果是,清空当前数据并在新的数据获得前不要重新渲染 | boolean | 否 | false | | ref | ref | | 否 | - |

TimeLevel

interface TimeLevel {
  name: string;
  dateUnit: 'year' | 'month' | 'day' | 'hour';
  amount: number;
  // 能被keyDate个dateUnit整除,则为keyDate
  keyDate: number;
}

NodeItem

export default interface NodeItem {
  _key: string;
  time: number;
  itemRender: Function;
}

DateChangedFunc

interface DateChangedFunc {
  (
    startDate: number,
    endDate: number,
    amount: number,
    currentTimeLevel: TimeLevel
  ): void;
}

ClickAddFunc

interface ClickAddFunc {
  (time: number, clientX: number, clientY: number): void;
}

defaultTimeLevels

const defaultTimeLevels: TimeLevel[] = [
  { name: 'hour', dateUnit: 'hour', amount: 1, keyDate: 12 },
  { name: 'day', dateUnit: 'day', amount: 1, keyDate: 5 },
  { name: 'week', dateUnit: 'day', amount: 7, keyDate: 5 },
  { name: 'month', dateUnit: 'month', amount: 1, keyDate: 5 },
  { name: 'year', dateUnit: 'year', amount: 1, keyDate: 5 },
  {
    name: 'ten-year',
    dateUnit: 'year',
    amount: 10,
    keyDate: 5,
  },
];

Functions

| Function name | Description | Props | | --------------------- | ---------------------- | --------------- | | handleChangeLevel | 更改 timeLevel(缩放) | zoomIn: boolean | | handleClickMoveButton | 左右移动 | next: boolean |

Function usage

const timelineRef = useRef < any > null;

timelineRef.current.handleClickMoveButton(true);

<Timeline
  ref={timelineRef}
  nodeList={items}
  nodeHeight={28}
  backgroundColor="unset"
  shiftX={-56}
  handleDateChanged={handleDateChanged}
  handleClickAdd={handleOpenOptions}
  changeLevelRequestData={true}
></Timeline>;