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

react-native-calendar-strip-slide-navigation

v0.0.3

Published

This is a fork of react-native-calendar-strip updated Slide navigation for selected dates

Downloads

38

Readme

react-native-calendar-strip

Easy to use and visually stunning calendar component for React Native.

<CalendarStrip> is a React Native component designed to replace the standard date picker component. It works for both iOS and Android and in both portrait and landscape orientations!

alt text

Instalation

Just use the standard npm installation

npm install react-native-calendar-strip-slide-navigation --save

Example

You can see the examples in \example folder of this repo.

Simple "out of the box" usage

You can use this component without any styling or customization. Just import it in your project and render it:

import React, {Component} from 'react';
import {
    AppRegistry,
    View
} from 'react-native';

import CalendarStrip from 'react-native-calendar-strip-slide-navigation';

class Example extends Component {
    render() {
        return (
            <View>
                <CalendarStrip/>
            </View>
        );
    }
}

AppRegistry.registerComponent('Example', () => Example);

alt text

Styling and animations

Even though this component works withouth any customization, it is possible to customize almost everything, so you can make it as beautiful as you want:

import React, {Component} from 'react';
import {
    AppRegistry,
    View
} from 'react-native';

import CalendarStrip from 'react-native-calendar-strip-slide-navigation';

class Example extends Component {
    render() {
        return (
            <View>
                <CalendarStrip
                    calendarAnimation={{type: 'sequence', duration: 30}}
                    selection={'border'}
                    selectionAnimation={{duration: 300, borderWidth: 1}}
                    style={{paddingTop: 20, paddingBottom: 10}}
                    calendarHeaderStyle={{color: 'white'}}
                    calendarColor={'#7743CE'}
                    highlightColor={'#9265DC'}
                    dateNumberStyle={{color: 'white'}}
                    dateNameStyle={{color: 'white'}}
                    highlightDateNumberStyle={{color: 'yellow'}}
                    highlightDateNameStyle={{color: 'yellow'}}
                    borderHighlightColor={'white'}
                    iconLeft={require('./img/left-arrow.png')}
                    iconRight={require('./img/right-arrow.png')}
                    iconContainer={{flex: 0.1}}
                />
            </View>
        );
    }
}

AppRegistry.registerComponent('Example', () => Example);

alt text

Props / API

This is the list of all the props you can pass to the component so that you can customize it:

Initial data and onDateSelected handler
  • startingDate: React.PropTypes.any - Date to be used for centering the calendar/showing the week based on that date. It is internaly wrapped by moment so it accepts both Date and moment Date.
  • selectedDate: React.PropTypes.any - Date to be used as pre selected Date. It is internaly wrapped by moment so it accepts both Date and moment Date.
  • onDateSelected: React.PropTypes.func - Function to be used as a callback when a date is selected. It returns moment Date
  • onWeekChanged: React.PropTypes.func - Function to be used as a callback when a week is changed. It returns moment Date
  • useIsoWeekday: React.PropTypes.bool - start week on ISO day of week (default true). If false, starts week on startingDate parameter.
Top level style
  • style: React.PropTypes.any - Style for the top level CalendarStrip component
Icon
  • iconLeft: React.PropTypes.any - Icon to be used for the left icon. It accepts require statement with url to the image (require('./img/icon.png')), or object with remote uri {uri: 'http://example.com/image.png'}
  • iconRight: React.PropTypes.any - Icon to be used for the right icon. It accepts require statement with url to the image (require('./img/icon.png')), or object with remote uri {uri: 'http://example.com/image.png'}
  • iconStyle: React.PropTypes.any - Style that is applied to both left and right icons. It is applied before iconLeftStyle or iconLeftStyle.
  • iconLeftStyle: React.PropTypes.any - Style for left icon. It will override all of the other styles applied to icons.
  • iconRightStyle: React.PropTypes.any - Style for right icon. It will override all of the other styles applied to icons.
  • iconContainer: React.PropTypes.any - Style for the container of icons. (Example usage is to add flex property to it so in the portrait mode, it will shrink the dates strip)
Header style and formating
  • calendarHeaderStyle: React.PropTypes.any - Style for the header text of the calendar.
  • calendarHeaderFormat: React.PropTypes.string - Format for the header text of the calendar. For options, refere to moments documentation
Date name and number styling
  • dateNameStyle: React.PropTypes.any - Style for the name of the day on work days in dates strip.
  • dateNumberStyle: React.PropTypes.any - Style for the number of the day on work days in dates strip.
  • weekendDateNameStyle: React.PropTypes.any - Style for the name of the day on weekend days in dates strip.
  • weekendDateNumberStyle: React.PropTypes.any - Style for the number of the day on weekend days in dates strip.
  • styleWeekend: React.PropTypes.bool - (default true) Whether to style weekend dates separately.
  • highlightDateNameStyle: React.PropTypes.any - Style for the selected name of the day in dates strip.
  • highlightDateNumberStyle: React.PropTypes.any - Style for the selected number of the day in dates strip.
Animations

There are two animated properties that also can be customized. The first one is actually animated showing of dates when you change a week. If you do not add this prop, it will not have an animation There are 2 possible options.

  • calendarAnimation: React.PropTypes.object - Animation object for showin the dates. It can have 2 types: {type: 'sequence', duration: 30} or {type: 'parallel', duration: 300} and the duration part being the duration of animation in millisecond.

####### Sequence The animation is used to show dates in sequence, so it shows them one by one. alt text

####### Parallel The animation is used to show dates in parallel, so it shows all of them with opacity animation. alt text


The second animation is used to animate selection of the date. Again, there are 2 types of animation, and they are either animating circular border around a date or changing a circualar background of the date.

  • selection: React.PropTypes.string - String prop for type of selection highligh. Possible types are border or background. !important This property will only determen the type of selection and type of animation, but to be animated, properties bellow have to be added as well.
  • selectionAnimation: React.PropTypes.object - An object used for the animation of selection. If this object is added, only then the selection will be animated. This object defines {duration: 30} of the animation, and if you add a type border of selection, you should also add a {duration: 30, borderWidth: 1} to this object.
  • borderHighlightColor: React.PropTypes.string - Highlighting border color. alt text

If you chose the background type of animation, the selected date will animate the circular background color from calendarColor to highlightColor. That is why, when this type is chosen, you have to define both of these colors.

  • calendarColor: React.PropTypes.string - Color of the circular backgroundo of the date. !important This color will also be aplied as the whole calendar strip background color, so that highlighting the date will appear 'from background' but be aware that top level style of this component can override this property.
  • highlightColor: React.PropTypes.string - Highlighting color of dates.

alt text

Localization
  • locale: React.PropTypes.object - Locale for dates

This prop is used for adding localization to react-native-calendar-strip component. The localization rules are the same as moments and can be found in moments documentation

The locale object has two properties:

  • name - String - The name of the locale (ex. 'fr')
  • config - Object - The config object holding all of the localization strings.

Example of one locale object is:

const locale = {
            name: 'fr',
            config: {
                months : "Janvier_Février_Mars_Avril_Mai_Juin_Juillet_Août_Septembre_Octobre_Novembre_Décembre".split("_"),
                monthsShort : "Janv_Févr_Mars_Avr_Mai_Juin_Juil_Août_Sept_Oct_Nov_Déc".split("_"),
                weekdays : "Dimanche_Lundi_Mardi_Mercredi_Jeudi_Vendredi_Samedi".split("_"),
                weekdaysShort : "Dim_Lun_Mar_Mer_Jeu_Ven_Sam".split("_"),
                weekdaysMin : "Di_Lu_Ma_Me_Je_Ve_Sa".split("_"),
                longDateFormat : {
                    LT : "HH:mm",
                    LTS : "HH:mm:ss",
                    L : "DD/MM/YYYY",
                    LL : "D MMMM YYYY",
                    LLL : "D MMMM YYYY LT",
                    LLLL : "dddd D MMMM YYYY LT"
                },
                calendar : {
                    sameDay: "[Aujourd'hui à] LT",
                    nextDay: '[Demain à] LT',
                    nextWeek: 'dddd [à] LT',
                    lastDay: '[Hier à] LT',
                    lastWeek: 'dddd [dernier à] LT',
                    sameElse: 'L'
                },
                relativeTime : {
                    future : "dans %s",
                    past : "il y a %s",
                    s : "quelques secondes",
                    m : "une minute",
                    mm : "%d minutes",
                    h : "une heure",
                    hh : "%d heures",
                    d : "un jour",
                    dd : "%d jours",
                    M : "un mois",
                    MM : "%d mois",
                    y : "une année",
                    yy : "%d années"
                },
                ordinalParse : /\d{1,2}(er|ème)/,
                ordinal : function (number) {
                    return number + (number === 1 ? 'er' : 'ème');
                },
                meridiemParse: /PD|MD/,
                isPM: function (input) {
                    return input.charAt(0) === 'M';
                },
                // in case the meridiem units are not separated around 12, then implement
                // this function (look at locale/id.js for an example)
                // meridiemHour : function (hour, meridiem) {
                //     return /* 0-23 hour, given meridiem token and hour 1-12 */
                // },
                meridiem : function (hours, minutes, isLower) {
                    return hours < 12 ? 'PD' : 'MD';
                },
                week : {
                    dow : 1, // Monday is the first day of the week.
                    doy : 4  // The week that contains Jan 4th is the first week of the year.
                }
            }
        };

ToDo

  • [ ] Add unit tests
  • [ ] Add Travis CI integration
  • [ ] Implement week view, which should show weeks in a month rather than days, so that you select the whole week
  • [ ] Add a month and a year selection in a form of a popup