Replies: 2 comments
-
Thanks for the request, at the moment we have indeed not yet made a date widget as the use case is very broad, however we have a an example here on how to integrate a third-party UI for the date picker. https://github.com/algolia/instantsearch.js/tree/master/examples/calendar-widget |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks for sharing the use case! Funny I made almost the same code :)
const ONE_DAY_IN_MS = 3600 * 24 * 1000;
const datePicker = instantsearch.connectors.connectRange(
(renderOptions, isFirstRender) => {
if (!isFirstRender) return;
const { refine } = renderOptions;
new Calendar({
element: $('#calendar'),
current_date: Date.now(),
same_day_range: true,
days_array: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
presets: [{
label: 'Hier',
start: moment().subtract(1, 'day').startOf('day'),
end: moment().subtract(1, 'day').endOf('day')
}, {
label: 'Aujourd\'hui',
start: moment().startOf('day'),
end: moment().endOf('day')
}, {
label: 'Cette Semaine',
start: moment().startOf('week'),
end: moment().endOf('week')
}, {
label: 'Ce Mois',
start: moment().startOf('month'),
end: moment().endOf('month')
}, {
label: 'Cette année',
start: moment().startOf('year'),
end: moment().endOf('year')
}],
callback: function () {
let startYear = moment(this.start_date).year();
let startMonth = moment(this.start_date).month();
let startDay = moment(this.start_date).date();
let endYear = moment(this.end_date).year();
let endMonth = moment(this.end_date).month();
let endDay = moment(this.end_date).date();
let start = new Date(Date.UTC(startYear, startMonth, startDay, 0, 0, 0, 0)).
getTime();
let end = new Date(Date.UTC(endYear, endMonth, endDay, 23, 59, 59, 999)).
getTime();
const actualEnd = start === end ? end + ONE_DAY_IN_MS - 1 : end;
refine([start, actualEnd]);
},
});
}
);
…On Mon, Nov 22, 2021 at 3:02 PM Haroen Viaene ***@***.***> wrote:
Thanks for the request, at the moment we have indeed not yet made a date
widget as the use case is very broad, however we have a an example here on
how to integrate a third-party UI for the date picker.
https://github.com/algolia/instantsearch.js/tree/master/examples/calendar-widget
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4959 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHY6OI6RH6VK67LEFQVYSDUNI5ODANCNFSM5IQ4L22A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
yofisim
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Il would be great to finally have a date widget to filter by timestamp;
Use cases:
Create my own widget is a bit of a headache;
Beta Was this translation helpful? Give feedback.
All reactions