1.3.0 • Published 1 year ago

react-weekdays-input v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-weekdays-input 👋

A highly customizable and easy to use react input that allows users to select days of the week with a user friendly interface

Example

Installation

npm i react-weekdays-input

Demo 👀

https://axelmy-projects-showcase.firebaseapp.com/react-weekdays-input

Usage 💻

import React, { useState } from 'react'
import { WeekdaysInput } from 'react-weekdays-input'

const Example = () => {
    const [daysAsString, setDaysAsString] = useState('0010010') //Wednesday and saturday active
    const [daysAsObject, setDaysAsObject] = useState([0, 0, 1, 0, 0, 1, 0]) //Wednesday and saturday active

    return (
        <>
            {/*Using default styling and props*/}
            <WeekdaysInput
                value={daysAsString}
                onChange={(value) => setDaysAsString(value)}
            />

            {/*Using custom props*/}
            <WeekdaysInput
                value={daysAsObject}
                onChange={(value) => setDaysAsObject(value)}
                days={[
                    'monday',
                    'tuesday',
                    'wednesday',
                    'thursday',
                    'friday',
                    'saturday',
                    'sunday'
                ]}        
                showChars={2} //mo, tu, we, th, fr, sa, su
                activeDayStyle={{
                    backgroundColor: 'pink',
                    color: '#000'
                }}
                inactiveDayStyle={{
                    backgroundColor: '#cececec',
                    color: 'white'
                }}
                dayStyle={{
                    border: '2px dotted black',
                }}
                inputStyle={{
                    margin: '10px',
                }}
                forcedState={{
                    0: 'none',
                    1: 'none',
                    2: 'active',
                    3: 'inactive',
                    4: 'none',
                    5: 'none',
                    6: 'none'
                }}
                textCase={'firstToUpper'} //Mo, Tu, We, Th, Fr, Sa, Su
            />
        </>
    )
}

export default Example

API ✔

Propertiestypedefaultdescription
valuestring/array(int)"0000000"A string or an array of 7 integers representing the active days of the week. 0 being inactive, 1 being active.
showCharsintnullThe numbers of chars to show for the days names. Ex: Monday=Mo. null will display the entire word
onChangefunction(string)/function(array(int))The function that will be called when the user clicks on a day which provides the new value as a parameter.
daysarray['monday','tuesday','wednesday'...The array defining the name of the days
activeDayStylestringThe CSS styling to apply to active days
inactiveDayStylestringThe CSS styling to apply to inactive days
inputStyleobjectThe CSS styling of the whole input
dayStyleobjectThe CSS styling used for each days
forcedStateobjectForce certain days to be active or inactive. See examples above
textCasestringnullDefines the case of the text. Available: firstToUpper (Monday), toUpper (MONDAY), toLower (monday)
wrapperClassNamestringnullA class that you may optionally provide for external modifications of the wrapper style.
selectorClassNamestringnullA class that you may optionally provide for external modifications of the day selection style.
renderOrderarray(int)0, 1, 2, 3, 4, 5, 6Determines which position each day will render. Index: the renderring slot. Value: The numeric value representing a day (nth index of the days array) that should be renderred in this slot. (Useful for renderring days in a different order, rather than the order in which they appear in the days parameter)
1.3.0

1 year ago

1.2.23

2 years ago

1.2.24

2 years ago

1.2.25

2 years ago

1.2.22

2 years ago

0.2.1

2 years ago

1.2.21

2 years ago

1.2.20

2 years ago

1.2.19

2 years ago

1.2.18

2 years ago

1.2.17

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago