1.1.0 • Published 3 years ago

react-clock-select v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

Introduction

A simple react component to select time or display time in 12 hour or 24 hours format

Click here for demo

Installation:

   npm install react-clock-select

Features:

  • Analog & Digital: Two types of time components available AnalogTime & DigitalTime .
  • Picker: Input field for time selection which pops open the Analog/Digital picker.
  • Time Display: For showing only Analog/Digital time display.
  • Time Format: Returns time in 12hours or 24hours format.
  • Live Clock: Real Time Clock with optional initial value.
  • Fully Customizable: Seperate props for changing color & size of time component. For advanced customization, CSS classes can be overridden.

Example (AnalogTime):

    import React from 'react';
    import { AnalogTime } from "react-clock-select";
    
    function TimePicker(props){
      return(
        <AnalogTime
           type={"picker"}
           // "picker" or "display", default is picker
           value={new Date()}
           // Date() object or 
           // a valid time string for Date() constructor
           placeholder={"Select Time.."}
           // when 'value' is empty string
           hoursFormat={12}
           // 12 or 24 
           size={1}
           // greater than 0, Default is 1.
           selectorPosition={"top"}
           // "top", "bottom" or "modal" (Picker only). 
           // Default is bottom.
           liveUpdater={true}
           // true or false (Display only).
           // Default is false.
           baseColor={"rgb(255,255,255)"}
           // Color value for clock base
           hourHandColor={"white"}
           // Color value for clock base
           minuteHandColor={"#FFFFFF"}
           // Color value for clock base
           secondHandColor={"#4d944e"}
           // Color value for clock base
           onConfirm={(e,value)=>{
           // "e" is the event object
           // "value" is a JSON
           // {
           //   time_string: "12:00:00 AM",
           //   hours: "12",
           //   minutes: "00",
           //   seconds: "00",
           //   am_pm: "AM",
           // }    
           }}
        />
      )
  }

Example (DigitalTime):

    import React from 'react';
    import { DigitalTime } from "react-clock-select";
    
    function TimePicker(props){
      return(
        <DigitalTime
           type={"picker"}
           // "picker" or "display", default is picker
           value={new Date()}
           // Date() object or 
           // a valid time string for Date() constructor
           placeholder={"Select Time.."}
           // when 'value' is empty string
           hoursFormat={12}
           // 12 or 24 
           size={1}
           // greater than 0, Default is 1.
           selectorPosition={"top"}
           // "top", "bottom" or "modal" (Picker only).
           // Default is bottom.
           liveUpdater={true}
           // true or false (Display only).
           // Default is false.
           color={"rgba(24, 24, 24, 0.671)"}
           // Color value for clock digits
           onConfirm={(e,value)=>{
            // "e" is the event object
            // "value" is a JSON
            // {
            //   time_string: "12:00:00 AM",
            //   hours: "12",
            //   minutes: "00",
            //   seconds: "00",
            //   am_pm: "AM",
            // }  
           }}
        />
      )
  }

Props (AnalogTime):

PropTypeDescription
typeString"picker" for time picker display or "display" for non editable display
valueString/Date()Sets default time value
placeholderStringSet placeholder, visible when 'value' is empty string
hoursFormatNumberHour format can be either 12 or 24
sizeNumberSize of the clock, should be greater than 0, Default is 1
selectorPositionStringPosition of the picker, "top", "bottom" or "modal" (Picker only). Default is bottom.
liveUpdaterBooleanLive Clock, if "value" prop is provided live time will be initiated from the "value".
baseColorStringColor value for clock base
hourHandColorStringColor value for hour hand
minuteHandColorStringColor value for minute hand
secondHandColorStringColor value for second hand
onConfirmCallbackCallback function for date confirm on OK button. value is a JSON { time_string: "12:00:00 AM", hours: "12", minutes: "00", seconds: "00", am_pm: "AM" }

Props (DigitalTime):

PropTypeDescription
typeString"picker" for time picker display or "display" for non editable display
valueString/Date()Sets default time value
placeholderStringSet placeholder, visible when 'value' is empty string
hoursFormatNumberHour format can be either 12 or 24
sizeNumberSize of the digital font, should be greater than 0, Default is 1
selectorPositionStringPosition of the picker, "top", "bottom" or "modal" (Picker only). Default is bottom.
liveUpdaterBooleanLive Clock, if "value" prop is provided live time will be initiated from the "value".
colorStringColor value for clock digits
onConfirmCallbackCallback function for date confirm on OK button . value is a JSON { time_string: "12:00:00 AM", hours: "12", minutes: "00", seconds: "00", am_pm: "AM" }

CSS Classes (AnalogTime):

Default CSS classes for easy css customization.

ClassNameDescription
rcs-analog-picker-customFor analog picker container.
rcs-analog-clock-base-customFor the base svg of analog clock.
rcs-analog-hour-hand-customFor the hour-hand svg of analog clock.
rcs-analog-minute-hand-customFor the minute-hand svg of analog clock.
rcs-analog-seconds-hand-customFor the seconds-hand svg of analog clock.
rcs-analog-time-picker-form-container-customFor analog picker container for inputs and button.
rcs-analog-time-input-field-parent-customFor analog picker input fields container.
rcs-analog-time-input-field-customFor analog picker input field.
rcs-analog-picker-input-customFor the main analog picker input field.
rcs-analog-am-pm-toggle-customFor analog picker am-pm toggle.
rcs-analog-time-picker-btn-customFor analog picker confirm button.

CSS Classes (DigitalTime):

Default CSS classes for easy css customization.

ClassNameDescription
rcs-digital-parent-customFor main container.
rcs-digital-picker-customFor digital picker and display container.
rcs-digital-picker-input-customFor picker input fields.
rcs-digital-time-picker-btn-customFor picker confirm button.

Support:

For support contact: adnanali17official@gmail.com, daniyal_09.2005@hotmail.com

1.1.0

3 years ago

1.1.0-alpha2

3 years ago

1.1.0-alpha1

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago