GithubHelp home page GithubHelp logo

isabella232 / instantsearch-widget-date-range-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from algolia/instantsearch-widget-date-range-picker

0.0 0.0 0.0 339 KB

License: MIT License

JavaScript 16.94% TypeScript 60.05% CSS 16.06% HTML 6.95%

instantsearch-widget-date-range-picker's Introduction

date-range-picker

InstantSearch widget that makes a date range picker


MIT NPM version

Demo

Demo on CodeSandbox.

Install

npm install @algolia/instantsearch-widget-date-range-picker
# or
yarn add @algolia/instantsearch-widget-date-range-picker

This widget is using @duetds/date-picker under the hood, so you need to include this at the end of <head> tag.

<script
  type="module"
  src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.esm.js"
></script>
<script
  nomodule
  src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.js"
></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/themes/default.css"
/>

This widget is using @duetds/date-picker under the hood, so you need to include this at the end of <head> tag.

<script
  type="module"
  src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.esm.js"
></script>
<script
  nomodule
  src="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/duet.js"
></script>
<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/@duetds/[email protected]/dist/duet/themes/default.css"
/>

Widget

Usage

import instantsearch from 'instantsearch.js';
import algoliasearch from 'algoliasearch/lite';
import { dateRangePicker } from '@algolia/instantsearch-widget-date-range-picker';

const searchClient = algoliasearch('appId', 'apiKey');

const search = instantsearch({
  indexName: 'indexName',
  searchClient,
});

search.addWidgets([
  dateRangePicker({
    // widget parameters
  }),
]);

search.start();

Options

Option Type Required Default Description
container string or HTMLElement true - The element to insert the widget into.
option1 ... true - REPLACE WITH THE DESCRIPTION FOR THIS OPTION

container

string | Element | required

The element to insert the widget into.

This can be either a valid CSS Selector:

dateRangePicker({
  container: '#date-range-picker',
  // ...
});

or an HTMLElement:

dateRangePicker({
  container: document.querySelector('#date-range-picker'),
  // ...
});

option1

... | required

REPLACE WITH THE DESCRIPTION FOR THIS OPTION

dateRangePicker({
  option1: 'value',
  // ...
});

Connector

Usage

import { connectDateRangePicker } from '@algolia/instantsearch-widget-date-range-picker';

// 1. Create a render function
const renderDateRangePicker = (renderOptions, isFirstRender) => {
  // Rendering logic
};

// 2. Create the custom widget
const customDateRangePicker = connectDateRangePicker(renderDateRangePicker);

// 3. Instantiate
search.addWidgets([
  customDateRangePicker({
    // instance params
  }),
]);

Options

option1

...

REPLACE WITH THE DESCRIPTION FOR THIS RENDERING ITEM

const renderDateRangePicker = (renderOptions, isFirstRender) => {
  // show how to use this render option
};

const customDateRangePicker = connectDateRangePicker(renderDateRangePicker);

search.addWidgets([
  customDateRangePicker({
    // ...
  }),
]);

widgetParams

object

All original widget options forwarded to the render function.

const renderDateRangePicker = (renderOptions, isFirstRender) => {
  const { widgetParams } = renderOptions;
  widgetParams.container.innerHTML = '...';
};

const customDateRangePicker = connectDateRangePicker(renderDateRangePicker);

search.addWidgets([
  customDateRangePicker({
    container: document.querySelector('#date-range-picker'),
    // ...
  }),
]);

Contributing

To start contributing to code, you need to:

  1. Fork the project
  2. Clone the repository
  3. Install the dependencies: yarn
  4. Run the development mode: yarn start

Please read our contribution process to learn more.


This project was generated with create-instantsearch-app by Algolia.

instantsearch-widget-date-range-picker's People

Contributors

eunjae-lee avatar

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.