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

native-timeline

v1.0.1

Published

React Native timeline component, based on typescript

Downloads

3

Readme

About The Project

React Native timeline component, based on typescript. It helps to manage your events in different time modes("Months", "Weeks", "Days"). It can be well customized to suit your needs using props. Read the documentation below.

Installation

# using yarn
yarn add native-timeline

# using npm
npm install native-timeline

Usage

At the very minimum:

import React from "react";
import Timeline from "native-timeline";

// ... some component and it's logic

const data = [
  {
    props: {
      id: 1,
      startDate: "2020-12-10",
      endDate: "2020-12-18",
      title: "Test1",
    },
    subItems: [
      {
        id: 2,
        startDate: "2020-12-10",
        endDate: "2020-12-14",
        title: "SubTest1",
      },
      {
        id: 3,
        startDate: "2020-12-15",
        endDate: "2020-12-18",
        title: "SubTest2",
      },
    ],
  },
  {
    props: {
      id: 4,
      startDate: "2020-12-19",
      endDate: "2020-12-25",
      title: "Test2",
    },
  },
];

const period = { startDate: "2020-12-01", endDate: "2020-12-31" };

return <Timeline data={data} period={period} />

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Danyil Zatserkovnyi - [email protected]

Project Link: https://github.com/Crysis020304050/native-timeline

Api

Props

Specify an array of event items and optional it's sub items

Specify time period to be rendered

  • horizontal?: boolean

Specify timeline position(default is vertical)

Vertical:

Vertical

Horizontal:

Horizontal

  • showSubItemsOnMainItemPress?: boolean (true by default)

Specify if sub events will be shown when user press main event item

Sub events opening

  • useTapOnDatesToChangeTimeMode?: boolean (true by default)

Specify if time mode will be changed when user press dates container

Tap on dates

  • defaultTimeMode?: string (default is "Days")

Timeline has 3 time modes("Months", "Weeks", "Days"), you can chose one by default

Use TIME_MODES constant for this

import { TIME_MODES } from "native-timeline";

defaultTimeMode={TIME_MODES.W}

Specify function that will be called when user press main event item, event ID will be passed to this function

Specify function that will be called when user press sub event item, event ID will be passed to this function

  • useStickyItemsText?: boolean (true by default)

Specify if event text will be moved inside event to be visible when user scroll timeline

Sticky text

Specify styles provided to timeline dates

Specify timeline dates format for every time mode(default is "MMM" for "Months" time mode, "MM-DD" for "Weeks" time mode and "DD ddd" for "Days" time mode)

Use TIME_MODES constant for this

import { TIME_MODES } from "native-timeline";

datesFormat={{ [TIME_MODES.M]: "YYYY MMM" }, { [TIME_MODES.D]: "DD MMM" }}

In this example dates format for "Weeks" time mode will be default

Default months format:

Default months format

Custom months format:

Custom months format

Specify styles for regular day, weekend or today on timeline

For example, you can color all weekends with red(default this color is #FFFFFF for regular day, #DEDEDE for weekend and #BBD0DE for today)

Default today color:

Default today color

Custom today color:

Custom today color

Specify day unit size for every time mode

You can control timeline scale in every time mode(default is 10px for "Months" time mode, 20px for "Weeks" time mode and 50px for "Days" time mode)

Use TIME_MODES constant for this

import { TIME_MODES } from "native-timeline";

modesToDayContainerSize={{ [TIME_MODES.W]: 30 }, { [TIME_MODES.D]: 80 }}

In this example day unit size for "Months" time mode will be default

Default day unit size:

Default day unit size

Custom day unit size:

Custom day unit size

  • gapBetweenEvents?: number(50 by default)

Specify left or top distance(depending on timeline position) between events

If event item width or height(depending on timeline position) will be increased you will most likely need to increase this distance

Default gap:

Default gap

Custom gap:

Custom gap

  • useSelectForScrollingToItems?: boolean(true by default)

Specify if main event items will be shown in modal selector, also add possibility to scroll to chosen event by picking it in the selector

Select scroller

If you use modal selector you can specify it's styles or some settings

Types and interfaces

  • DateArgs
type DateArgs = Date | moment.Moment | string | number;
  • ID
type type ID = string | number;
  • Styles
type Styles = { container?: ViewStyle; text?: TextStyle };
  • ItemProps
interface ItemProps {
  startDate: DateArgs;
  endDate: DateArgs;
  title: string;
  styles?: Styles;
  id: ID;
}
  • Data
type Data = Array<{ props: ItemProps; subItems?: Array<ItemProps> }>;
  • Period
type Period = { startDate: DateArgs; endDate: DateArgs };
  • OnItemPress
type OnItemPress = (id: ID) => void;
  • DatesFormat
type DatesFormat = Record<string, string>;
  • DateLinesStyles
type DateLinesStyles = { day?: ViewStyle; weekend?: ViewStyle; today?: ViewStyle };
  • ModesToDayContainerSize
type ModesToDayContainerSize = Record<string, number>;
  • SelectProps
type SelectProps = { [key: string]: any };

react-native-modal-selector module is used in this project, so you can find SelectProps here

Your can pass any props except data and onChange