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

s-date-range-picker

v0.3.0

Published

A date range picker built with Svelte

Downloads

137

Readme

s-date-range-picker (alpha)

CircleCI npm version

Branch coverage Function coverage Line coverage Statement coverage

A date range picker built with Svelte

Getting Started

In a Svelte App

  • npm: npm i s-date-range-picker
  • yarn: yarn add s-date-range-picker
<script>
  import SDateRangePicker from "s-date-range-picker";

  // Manage start and end props from main app component
  let startDate = new Date();
  let endDate = new Date();

  // Update state on apply event
  function onApply({ detail }) {
    startDate = detail.startDate;
    endDate = detail.endDate;
  }
</script>

<SDateRangePicker {startDate} {endDate} on:apply={onApply} />

Development

  • Requires NodeJS
  • Clone the repo: git clone https://github.com/onx2/svelte-date-range-picker.git
  • Enter directory: cd svelte-date-range-picker
  • Install dpendencies: yarn
  • Run dev web server: yarn serve
  • Run tests: yarn test
  • Run format: yarn format
  • Run linter: yarn lint
  • Run build: yarn build

API

Props / Options

applyBtnText: string = "Apply";

cancelBtnText: string = "Camcel";

dateFormat: string = "MMM dd, yyyy";

disabledDates: Date[] = [];

endDate: Date = endOfWeek(new Date());

firstDayOfWeek: string = "sunday";

locale?: Locale = undefined; // date-fns defaults to the system locale.

maxDate: Date = addYears(new Date(), 10);

minDate: Date = subYears(new Date(), 10);

monthDropdown: boolean = false;

monthFormat: string = "MMMM";

nextIcon: string | HTMLElement = "&#9656;"; - ▸

prevIcon: string | HTMLElement = "&#9666;"; // (html | string) - ◂

resetViewBtn: boolean = false;

resetViewBtnText: string | HTMLElement = "&#8602;" // ↚

rtl: boolean = false;

singlePicker: boolean = false;

startDate: Date = startOfWeek(new Date());

timePicker: boolean = false;

timePickerControls: boolean = false;

timePickerIncrement: number = 1;

timePickerSeconds: boolean = false;

today: Date = new Date(); // Used as a reference in predefinedRanges and for underlining in calendar

todayBtn: boolean = false;

todayBtnText: string = "Today";

twoPages: boolean = true;

weekGuides: boolean = false; // Distance in calendar weeks from today

weekNumbers: boolean = false; // Local week numbers

yearDropdown: boolean = false;

Events

// Fired when a selection is made (start or end date has been chosen)
selection(): { startDate: Date, endDate: Date};

// Fired when the "Cancel" button is clicked
cancel(): { startDate: Date, endDate: Date};

// Fired when the "Apply" button is clicked
apply(): { startDate: Date, endDate: Date};

Goals

  • 100% test coverage
  • Event data
  • Better accessibility
  • Total localization
  • AM / PM times
  • Maximum span of days option
  • Predefined ranges option
  • Add storybook for demo site to display different props / options
  • Convert to Typescript
  • Theming capabilities with a default theme

Thanks geakstr for the Svelte component template!

This project is using date-fns under the hood for date calculations / manipulation.