Giter Club home page Giter Club logo

svelte-date-range-picker's Introduction

s-date-range-picker (alpha)

CircleCI A date range picker built in SvelteJS

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} />

Screenshot (defaults)

Svelte Date Range Picker 2019-11-30

Todos

  • Publish to npm
  • Add the missing Props / Options
  • Tests
  • Linter
  • Styling
  • Show & hide functionality (probably in the form of a button w/ popover)
  • Documentation / Demo Site
  • Mobile / touch friendly
  • Optimizations / reduce bundle size
  • Accessibility review / updates

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 (No tests yet)
  • Run linter: yarn lint (No linter yet)

API

Props / Options

Implemented but still being reviewed / developed

  • autoApply = false (boolean)
  • dateFormat = "MMM dd, yyyy" (string) options
  • disabledDates = [] (Date[])
  • endDate = endOfWeek(new Date()) (Date)
  • firstDayOfWeek = "sunday" (string)
  • hideOnCancel = false (boolean)
  • hideOnApply = false (boolean)
  • isoWeekNumbers = false (boolean)
  • locale = undefined (Locale) date-fns defaults to the system locale.
  • maxDate = addYears(new Date(), 10) (Date)
  • minDate = subYears(new Date(), 10) (Date)
  • monthDropdown = false (boolean)
  • monthFormat = "MMMM" (string) options
  • rtl = false (boolean)
  • singlePicker = false (boolean)
  • startDate = startOfWeek(new Date()) (Date)
  • timePicker = false (boolean)
  • timePickerIncrement = 1 (number)
  • timePickerSeconds = false (boolean)
  • today = new Date() (Date) Used as a reference in predefinedRanges and for underlining in calendar
  • prevIcon = "&#9666;" (html | string) - ◂
  • nextIcon = "&#9656;" (html | string) - ▸
  • weekGuides = false (boolean) Distance in calendar weeks from today
  • weekNumbers = false (boolean) Local week numbers
  • yearDropdown = false (boolean)
  • applyBtnText = "Apply" (string)
  • cancelBtnText = "Camcel" (string)
  • todayBtnText = "Today" (string)
  • todayBtn = false (boolean)
  • resetViewBtnText = "&#8602;" (html | string) - ↚
  • resetViewBtn = false (boolean)
  • id = "s-date-range-picker-" + Math.random() (string)

Not implemented - todo

  • timePicker24Hour = true (boolean)
  • predefinedRanges = [] (Date[])
  • maxSpan = Infinity (number)
  • events = [] (Date[])
  • disabled = false (boolean)

Events

  • show Fired after the picker has been shown
  • hide Fired after the picker has been hidden
  • selection Fired when a selection is made (start or end date has been chosen)
  • cancel Fired when the "Cancel" button is clicked
  • apply Fired when the "Apply" button is clicked

Thanks geakstr for the Svelte component template!

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

svelte-date-range-picker's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

zhuny

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.