-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add guide "Create a Calendar Widget" #2687
Conversation
Deploy preview for algolia-instantsearch ready! Built with commit 1f6f89b https://deploy-preview-2687--algolia-instantsearch.netlify.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably the best guide I've read! Very clear and beginner-friendly. I left some comments on smaller things, nothing too blocking
docgen/src/guides/calendar-widget.md
Outdated
* `location`: the venue of the concert | ||
* `date`: the date of the event we will refine the results with | ||
|
||
Both `name` and `location` will be added to the [searchable attributes](https://www.algolia.com/doc/guides/ranking/searchable-attributes/) in the Algolia dashboard so that the user can filter events on their name *and* their location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for italic and
IMO
docgen/src/guides/calendar-widget.md
Outdated
|
||
If you're using [npm](https://www.npmjs.com/): | ||
|
||
```console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console is not recognised, and is showing it very faint, try sh
, bash
or nothing
docgen/src/guides/calendar-widget.md
Outdated
If you're using [npm](https://www.npmjs.com/): | ||
|
||
```console | ||
npm install -g create-instantsearch-app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npx create-instantsearch-app [name-of-your-new-app]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel so old 👴 what is npx
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's something npm 5 has, doing install globally and execute the binary, like yarn create
docgen/src/guides/calendar-widget.md
Outdated
yarn create instantsearch-app [name-of-your-new-app] | ||
``` | ||
|
||
The command-line tool will ask for your credentials: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing here where the dataset is, maybe list the credentials here, will be clearer, and we show them in the example anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I should expose them. Should I make the JSON dataset downloadable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the JSON dataset should be provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both the json and the credentials should be given IMO, you can put the JSON in https://github.com/algolia/datasets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced the dataset is good enough to be officially exposed though. I might work a bit more on that beforehand!
The default `item` template from the `hits` widget provided by `create-instantsearch-app` is great, but we're going to enhance it to display the relevant information of our dataset. | ||
|
||
```javascript | ||
search.addWidget( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is runnable
for some reason, but it doesn't work with the demo instant_search
index; @bobylito can we make that configurable in the guide metadata 🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh :/ It's because we do:
if (exampleContent.indexOf("search.addWidget") === 0) {
initWidgetExample(codeSample, index);
}
in the runnable code JS :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if the index would be configurable based on the page metadata, do you think that's possible @bobylito ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working on it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR sent #2690
docgen/src/guides/calendar-widget.md
Outdated
); | ||
``` | ||
|
||
We use the function syntax for the `item` template because we want to convert the numeric timestamp from our dataset to a JavaScript date on the fly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the fly.
+ Be careful here with user-generated data, you can use existing libraries to prevent XSS,
+ or use a template and `transformData` instead.
(we don't currently have a guide on XSS I think, otherwise it should be linked
docgen/src/guides/calendar-widget.md
Outdated
}, | ||
// Some good parameters based on our dataset: | ||
start_date: new Date(), | ||
end_date: new Date(`2020 00:00`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better not to mix backticks and normal quotes
docgen/src/guides/calendar-widget.md
Outdated
In our connector instantiation, we need to attach the calendar and specify its callback function to refine the search. This part will be specific to the calendar library that you use in your app. In the Baremetrics Calendar, this function is passed to the `callback` argument. | ||
|
||
```javascript | ||
const makeRangeWidget = instantsearch.connectors.connectRange( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proposal: call the widget datePicker
, since that's more consistent with the names in IS.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's also more explicit!
Nice guide! Advice on behaviourI would like your advice on the calendar behaviour. Since I am used to the AirBnB like calendar, it took me some time to understand how to use this one. Here's the difference: If you just blindly click on the two dates and you endup clicking only on the "End date (second date)" then the behaviour is very confusing because you think you're gonna select start then end dates while it's not the case. You're only changing the end date. Is there a way to have the default demo behaviour where every time the calendar is opened then the action is "select the start date, then the end date" and never "select only the end date". For the demoCould you add a link to the source code in the demo? So the user once he have seen the demo can jump into the code right away. |
I couldn't find a calendar widget without huge dependencies as good as As for the source code in the demo, I can add a link to the zip file. |
docgen/src/guides/calendar-widget.md
Outdated
|
||
Search results often need to be refined by dates. Calendars are a good visual way to improve the user experience when it comes to filtering dates. InstantSearch provides custom widgets to create reusable components within your app. | ||
|
||
By the end of this guide, you'll understand how to implement a calendar widget to refine your results based on a single date and a range of dates. You can [preview](https://community.algolia.com/instantsearch.js/v2/examples/calendar-widget/) and [download](https://community.algolia.com/instantsearch.js/v2/examples/calendar-widget.zip) the concert app that you'll be able to build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Links should be relative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, should I make all links relative or only these two?
I've seen some other guides using absolute links.
It's OK for now since we show how to plug a calendar. This one also has some cool features like last 30 days etc.. Which are great
I would add a link to zip yes but also the GitHub direct link, since you might just want to read the code without having to download and unzip |
master yes since it's the branch tracking the releases (= doc website is master branch doc) |
All changes have been made and all dependant PRs have been merged 🙂 Thank you all for your feedback! @Haroenv I've fixed the "Invalid date" issue on Safari. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for my own comments
LGTM 👍 thanks for this awesome contribution @francoischalifour :) |
# [6.0.0-beta.1](algolia/react-instantsearch@v5.7.0...v6.0.0-beta.1) (2019-10-18) ### Bug Fixes * **connectToggleRefinement:** cast currentRefinement to boolean ([algolia/react-instantsearch#2701](algolia/react-instantsearch#2701)) ([aaf8043](algolia/react-instantsearch@aaf8043)) * **deps:** update dependency antd to v3.19.3 ([algolia/react-instantsearch#2530](algolia/react-instantsearch#2530)) ([a2a9ba0](algolia/react-instantsearch@a2a9ba0)) * **deps:** update dependency antd to v3.19.4 ([algolia/react-instantsearch#2559](algolia/react-instantsearch#2559)) ([c0d13a5](algolia/react-instantsearch@c0d13a5)) * **deps:** update dependency antd to v3.19.5 ([algolia/react-instantsearch#2560](algolia/react-instantsearch#2560)) ([089ed3e](algolia/react-instantsearch@089ed3e)) * **deps:** update dependency antd to v3.19.6 ([algolia/react-instantsearch#2564](algolia/react-instantsearch#2564)) ([eb496fb](algolia/react-instantsearch@eb496fb)) * **deps:** update dependency antd to v3.19.7 ([algolia/react-instantsearch#2573](algolia/react-instantsearch#2573)) ([f76c9b9](algolia/react-instantsearch@f76c9b9)) * **deps:** update dependency antd to v3.19.8 ([algolia/react-instantsearch#2584](algolia/react-instantsearch#2584)) ([2d243cd](algolia/react-instantsearch@2d243cd)) * **deps:** update dependency antd to v3.20.0 ([algolia/react-instantsearch#2611](algolia/react-instantsearch#2611)) ([635c0ee](algolia/react-instantsearch@635c0ee)) * **deps:** update dependency antd to v3.20.1 ([algolia/react-instantsearch#2635](algolia/react-instantsearch#2635)) ([c45ad1a](algolia/react-instantsearch@c45ad1a)) * **deps:** update dependency antd to v3.20.2 ([algolia/react-instantsearch#2655](algolia/react-instantsearch#2655)) ([aff6af1](algolia/react-instantsearch@aff6af1)) * **deps:** update dependency antd to v3.20.3 ([algolia/react-instantsearch#2658](algolia/react-instantsearch#2658)) ([2fe1b08](algolia/react-instantsearch@2fe1b08)) * **deps:** update dependency antd to v3.20.5 ([algolia/react-instantsearch#2686](algolia/react-instantsearch#2686)) ([767f6bb](algolia/react-instantsearch@767f6bb)) * **deps:** update dependency antd to v3.20.6 ([algolia/react-instantsearch#2711](algolia/react-instantsearch#2711)) ([1026bb1](algolia/react-instantsearch@1026bb1)) * **deps:** update dependency antd to v3.20.7 ([algolia/react-instantsearch#2712](algolia/react-instantsearch#2712)) ([5dbe0f6](algolia/react-instantsearch@5dbe0f6)) * **deps:** update dependency antd to v3.21.1 ([algolia/react-instantsearch#2736](algolia/react-instantsearch#2736)) ([b6028e7](algolia/react-instantsearch@b6028e7)) * **deps:** update dependency antd to v3.21.2 ([algolia/react-instantsearch#2738](algolia/react-instantsearch#2738)) ([fab0a42](algolia/react-instantsearch@fab0a42)) * **deps:** update dependency antd to v3.21.4 ([algolia/react-instantsearch#2747](algolia/react-instantsearch#2747)) ([b31b543](algolia/react-instantsearch@b31b543)) * **deps:** update dependency antd to v3.22.0 ([algolia/react-instantsearch#2758](algolia/react-instantsearch#2758)) ([be351e1](algolia/react-instantsearch@be351e1)) * **deps:** update dependency antd to v3.22.2 ([algolia/react-instantsearch#2791](algolia/react-instantsearch#2791)) ([79ef129](algolia/react-instantsearch@79ef129)) * **deps:** update dependency antd to v3.23.2 ([algolia/react-instantsearch#2814](algolia/react-instantsearch#2814)) ([bd12e7a](algolia/react-instantsearch@bd12e7a)) * **deps:** update dependency lodash to v4.17.13 ([2d2d2da](algolia/react-instantsearch@2d2d2da)) * **deps:** update dependency lodash to v4.17.14 ([algolia/react-instantsearch#2647](algolia/react-instantsearch#2647)) ([3075507](algolia/react-instantsearch@3075507)) * **deps:** update dependency lodash to v4.17.15 ([algolia/react-instantsearch#2684](algolia/react-instantsearch#2684)) ([081fe68](algolia/react-instantsearch@081fe68)) * **deps:** update dependency next to v9 ([algolia/react-instantsearch#2638](algolia/react-instantsearch#2638)) ([23be0c2](algolia/react-instantsearch@23be0c2)) * **deps:** update dependency next to v9.0.1 ([algolia/react-instantsearch#2652](algolia/react-instantsearch#2652)) ([100f04a](algolia/react-instantsearch@100f04a)) * **deps:** update dependency next to v9.0.2 ([algolia/react-instantsearch#2662](algolia/react-instantsearch#2662)) ([09947fb](algolia/react-instantsearch@09947fb)) * **deps:** update dependency next to v9.0.3 ([algolia/react-instantsearch#2724](algolia/react-instantsearch#2724)) ([aaa3f4c](algolia/react-instantsearch@aaa3f4c)) * **deps:** update dependency next to v9.0.4 ([algolia/react-instantsearch#2767](algolia/react-instantsearch#2767)) ([2a73410](algolia/react-instantsearch@2a73410)) * **deps:** update dependency next to v9.0.5 ([algolia/react-instantsearch#2789](algolia/react-instantsearch#2789)) ([c3ef3a7](algolia/react-instantsearch@c3ef3a7)) * **deps:** update dependency qs to v6.8.0 ([algolia/react-instantsearch#2757](algolia/react-instantsearch#2757)) ([0eb150a](algolia/react-instantsearch@0eb150a)) * **deps:** update dependency react-compound-slider to v2.1.0 ([algolia/react-instantsearch#2610](algolia/react-instantsearch#2610)) ([00c680d](algolia/react-instantsearch@00c680d)) * **deps:** update dependency react-compound-slider to v2.2.0 ([algolia/react-instantsearch#2649](algolia/react-instantsearch#2649)) ([fb37e13](algolia/react-instantsearch@fb37e13)) * **deps:** update dependency react-native-vector-icons to v6.5.0 ([algolia/react-instantsearch#2520](algolia/react-instantsearch#2520)) ([2da40fa](algolia/react-instantsearch@2da40fa)) * **deps:** update dependency react-native-vector-icons to v6.6.0 ([algolia/react-instantsearch#2599](algolia/react-instantsearch#2599)) ([cc3a5df](algolia/react-instantsearch@cc3a5df)) * **deps:** update dependency react-router-dom to v5.0.1 ([algolia/react-instantsearch#2506](algolia/react-instantsearch#2506)) ([10c1a8e](algolia/react-instantsearch@10c1a8e)) * **highlight:** switch to index as key ([algolia/react-instantsearch#2691](algolia/react-instantsearch#2691)) ([78e6fad](algolia/react-instantsearch@78e6fad)), closes [#2688](algolia/react-instantsearch#2688) * **voiceSearch:** fix incorrect status on stop ([algolia/react-instantsearch#2535](algolia/react-instantsearch#2535)) ([129596e](algolia/react-instantsearch@129596e)) ### chore * **release:** 6.0.0-beta.1 ([algolia/react-instantsearch#2861](algolia/react-instantsearch#2861)) ([9a329da](algolia/react-instantsearch@9a329da)), closes [#2023](algolia/react-instantsearch#2023) [#2178](algolia/react-instantsearch#2178) [#2178](algolia/react-instantsearch#2178) [#2179](algolia/react-instantsearch#2179) [#2180](algolia/react-instantsearch#2180) [#2181](algolia/react-instantsearch#2181) [#2185](algolia/react-instantsearch#2185) [#2192](algolia/react-instantsearch#2192) [#2189](algolia/react-instantsearch#2189) [#2190](algolia/react-instantsearch#2190) [#2179](algolia/react-instantsearch#2179) [#2178](algolia/react-instantsearch#2178) [#2180](algolia/react-instantsearch#2180) [#2181](algolia/react-instantsearch#2181) [#2185](algolia/react-instantsearch#2185) [#2192](algolia/react-instantsearch#2192) [#2190](algolia/react-instantsearch#2190) [#2203](algolia/react-instantsearch#2203) [#2432](algolia/react-instantsearch#2432) [#2444](algolia/react-instantsearch#2444) [#2357](algolia/react-instantsearch#2357) [#2454](algolia/react-instantsearch#2454) [#2455](algolia/react-instantsearch#2455) [#2459](algolia/react-instantsearch#2459) [#2458](algolia/react-instantsearch#2458) [#2460](algolia/react-instantsearch#2460) [#2442](algolia/react-instantsearch#2442) [#2446](algolia/react-instantsearch#2446) [#2434](algolia/react-instantsearch#2434) [#2467](algolia/react-instantsearch#2467) [#2466](algolia/react-instantsearch#2466) [#2288](algolia/react-instantsearch#2288) [#2290](algolia/react-instantsearch#2290) [#2289](algolia/react-instantsearch#2289) [#2305](algolia/react-instantsearch#2305) [#2338](algolia/react-instantsearch#2338) [#2461](algolia/react-instantsearch#2461) [#2442](algolia/react-instantsearch#2442) [#2307](algolia/react-instantsearch#2307) [#2314](algolia/react-instantsearch#2314) [#2304](algolia/react-instantsearch#2304) [#2379](algolia/react-instantsearch#2379) [#2552](algolia/react-instantsearch#2552) [#2555](algolia/react-instantsearch#2555) [#2536](algolia/react-instantsearch#2536) [#2537](algolia/react-instantsearch#2537) [#2339](algolia/react-instantsearch#2339) [#2349](algolia/react-instantsearch#2349) [#2570](algolia/react-instantsearch#2570) [#2462](algolia/react-instantsearch#2462) [#2600](algolia/react-instantsearch#2600) [#2468](algolia/react-instantsearch#2468) [#2626](algolia/react-instantsearch#2626) [#2621](algolia/react-instantsearch#2621) [#2627](algolia/react-instantsearch#2627) [#2644](algolia/react-instantsearch#2644) [#2626](algolia/react-instantsearch#2626) [#2645](algolia/react-instantsearch#2645) [#2339](algolia/react-instantsearch#2339) [#2643](algolia/react-instantsearch#2643) [#2467](algolia/react-instantsearch#2467) [#2690](algolia/react-instantsearch#2690) [#2687](algolia/react-instantsearch#2687) [#2722](algolia/react-instantsearch#2722) [#2568](algolia/react-instantsearch#2568) [#2726](algolia/react-instantsearch#2726) [#2379](algolia/react-instantsearch#2379) [#2289](algolia/react-instantsearch#2289) [#2290](algolia/react-instantsearch#2290) [#2304](algolia/react-instantsearch#2304) [#2307](algolia/react-instantsearch#2307) [#2314](algolia/react-instantsearch#2314) [#2288](algolia/react-instantsearch#2288) [#2305](algolia/react-instantsearch#2305) [#2701](algolia/react-instantsearch#2701) [#2568](algolia/react-instantsearch#2568) [#2357](algolia/react-instantsearch#2357) [#2552](algolia/react-instantsearch#2552) [#2530](algolia/react-instantsearch#2530) [#2559](algolia/react-instantsearch#2559) [#2560](algolia/react-instantsearch#2560) [#2564](algolia/react-instantsearch#2564) [#2573](algolia/react-instantsearch#2573) [#2584](algolia/react-instantsearch#2584) [#2611](algolia/react-instantsearch#2611) [#2635](algolia/react-instantsearch#2635) [#2655](algolia/react-instantsearch#2655) [#2658](algolia/react-instantsearch#2658) [#2686](algolia/react-instantsearch#2686) [#2711](algolia/react-instantsearch#2711) [#2712](algolia/react-instantsearch#2712) [#2736](algolia/react-instantsearch#2736) [#2738](algolia/react-instantsearch#2738) [#2747](algolia/react-instantsearch#2747) [#2758](algolia/react-instantsearch#2758) [#2647](algolia/react-instantsearch#2647) [#2684](algolia/react-instantsearch#2684) [#2638](algolia/react-instantsearch#2638) [#2652](algolia/react-instantsearch#2652) [#2662](algolia/react-instantsearch#2662) [#2724](algolia/react-instantsearch#2724) [#2767](algolia/react-instantsearch#2767) [#2757](algolia/react-instantsearch#2757) [#2610](algolia/react-instantsearch#2610) [#2649](algolia/react-instantsearch#2649) [#2520](algolia/react-instantsearch#2520) [#2599](algolia/react-instantsearch#2599) [#2506](algolia/react-instantsearch#2506) [#2467](algolia/react-instantsearch#2467) [#2626](algolia/react-instantsearch#2626) [#2690](algolia/react-instantsearch#2690) [#2688](algolia/react-instantsearch#2688) [#2626](algolia/react-instantsearch#2626) [#2726](algolia/react-instantsearch#2726) [#2535](algolia/react-instantsearch#2535) [#2461](algolia/react-instantsearch#2461) [#2434](algolia/react-instantsearch#2434) [#2687](algolia/react-instantsearch#2687) [#2338](algolia/react-instantsearch#2338) [#2179](algolia/react-instantsearch#2179) [#2180](algolia/react-instantsearch#2180) [#2181](algolia/react-instantsearch#2181) [#2185](algolia/react-instantsearch#2185) [#2192](algolia/react-instantsearch#2192) [#2189](algolia/react-instantsearch#2189) [#2190](algolia/react-instantsearch#2190) [#2179](algolia/react-instantsearch#2179) [#2180](algolia/react-instantsearch#2180) [#2181](algolia/react-instantsearch#2181) [#2185](algolia/react-instantsearch#2185) [#2192](algolia/react-instantsearch#2192) [#2190](algolia/react-instantsearch#2190) [#2536](algolia/react-instantsearch#2536) [#2537](algolia/react-instantsearch#2537) [#2834](algolia/react-instantsearch#2834) [#2845](algolia/react-instantsearch#2845) [#2842](algolia/react-instantsearch#2842) [#2852](algolia/react-instantsearch#2852) [#2853](algolia/react-instantsearch#2853) ### BREAKING CHANGES * **release:** translation will render default value if passed undefined as value * chore(lodash): remove imports * fix(translation): allow undefined value to be passed on purpose * **release:** no longer do we allow paths like `attribute[5].something`, or other indexed forms, only `.` is allowed as special key. All existing tests still pass, and we never documented you could use `lodash.get` patterns other than `.`. * feat(get): accept array & bracked-separated string moved to utils at the same time * fix typo * feedback: test for undefined behaviour * chore(size): update expectation this will go down afterwards, but for now there's some more duplication
⚠️ Waiting for #2686 and algolia/create-instantsearch-app#8 to be merged.DONE ✅This PR is the result of the app and the guide: "Create a Calendar Widget".
I'm looking for feedback on both the app and the guide 🙌