Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-timeline-range-slider-with-disabled

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-timeline-range-slider-with-disabled

Time Slider component for React ,

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
increased by162.5%
Maintainers
1
Weekly downloads
 
Created
Source

Original Component

https://github.com/lizashkod/react-timeline-range-slider

react-timeline-range-slider

demo gif

Installation

 npm i react-timeline-range-slider-with-disabled

Props

PropTypeDefaultDescription
timelineIntervalarray[startOfToday(), endOfToday()]Interval to display
selectedIntervalarray[new Date(), addHours(new Date(), 1)]Selected interval inside the timeline
disabledIntervalsarray[]Array of disabled intervals inside the timeline
containerClassNamestringClassName of the wrapping container
stepnumber48Number of milliseconds between steps
ticksNumbernumber1800000Number of steps on the timeline (the default value is 30 minutes)
errorboolfalseIs the selected interval is not valid
disabledboolfalseDisable Slide
onUpdateCallbackfunction
onChangeCallbackfunction

Example

Live demo

import React from 'react'  
import { endOfToday, format, set } from 'date-fns' 
import TimeRange from 'react-timeline-range-slider'  

const now = new Date()
const getTodayAtSpecificHour = (hour = 12) =>
	set(now, { hours: hour, minutes: 0, seconds: 0, milliseconds: 0 })

const selectedStart = getTodayAtSpecificHour()
const selectedEnd = getTodayAtSpecificHour(14)

const startTime = getTodayAtSpecificHour(7)
const endTime = endOfToday()

const disabledIntervals = [
  { start: getTodayAtSpecificHour(16), end: getTodayAtSpecificHour(17) },
  { start: getTodayAtSpecificHour(7), end: getTodayAtSpecificHour(12) },
  { start: getTodayAtSpecificHour(20), end: getTodayAtSpecificHour(24) }
]

class App extends React.Component {  
  state = {  
    error: false,  
    selectedInterval: [selectedStart, selectedEnd],  
  }
	
  errorHandler = ({ error }) => this.setState({ error })  

  onChangeCallback = selectedInterval => this.setState({ selectedInterval })  

  render() {  
    const { selectedInterval, error } = this.state  
      return (  
        <TimeRange
          error={error}  
          ticksNumber={36}  
          selectedInterval={selectedInterval}  
          timelineInterval={[startTime, endTime]}  
          onUpdateCallback={this.errorHandler}  
          onChangeCallback={this.onChangeCallback}
          disabledIntervals={disabledIntervals}  
        />
      )  
  }  
}  

export default App

Keywords

FAQs

Package last updated on 12 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc