okp4 / dataverse-portal

🔭 Dataverse Portal for the OKP4 network.
BSD 3-Clause "New" or "Revised" License
8 stars 1 forks source link

[Dataverse] Additional filters - Datepicker filter #208

Closed ChaimaaZaoui closed 1 year ago

ChaimaaZaoui commented 1 year ago

Feature: [Dataverse] Additional filters - Datepicker filter

As an end-user of the portal on the .../dataversepage, I want to filter the dataverse by temporal coverage So that only items in a specific time period are shown

Acceptance criteria

Scenario 1 : Filter type : Datepicker

Given that I am an end-user navigating the portal And I am using a desktop device, When I am on the .../dataverse page, And I want to filter by date, Then the following fields are displayed:

By default, no date is selected, and the datepicker displays the format DD/MM/YY.

Additionally, I expect the datepicker to have the following advanced functionalities:

Advanced Functionalities: If a date is already selected:

Furthermore, when I click on the datepicker, the calendar should be focused on today's date, both for the start and finish date.

The date range for the datepicker is as follows:

Select and Option dropdown won't be customized due to browser limitations. (@0xLodz )

Scenario 2 : Internationalisation

ENG

From... To...

Mo Tu We Th Fr Sa Su

FR

De... A...

Lu Ma Me Je Ve Sa Di

DE

Von... Bis...

Mo Di Mi Do Fr Sa So

Resources

Mockups

Mock-ups are available on Figma Dev FIle, Page "Version 2 - FOR LATER"

image

Environment

Additional informations

None.

┆Issue is synchronized with this Wrike task by Unito

ChaimaaZaoui commented 1 year ago

DOR

ChaimaaZaoui commented 1 year ago

@fredericvilcot @lolottetheclash please work on the technical definition to present it to the team in the upcoming Planning poker (04/05)

lolottetheclash commented 1 year ago

Since this component is intended to integrate our design system, it will be built from scratch.

ChaimaaZaoui commented 1 year ago

Hey team! Please add your planning poker estimate with Zenhub @0xLodz @lolottetheclash @AnjaMis @ErikssonJoakim

ChaimaaZaoui commented 1 year ago

No library will be used for the UI, however for date management, a library could be used to be confirmed with @fredericvilcot

loiclaudet commented 1 year ago

Proposal to use React DayPicker Library

Hi team! I wanted to propose a solution that I think could save us a significant amount of development time and resources. While I understand and respect the decision to limit the use of UI library for our project, I believe it would be beneficial to make an exception for the date picker component. During my research I have found a library called React DayPicker, that could be a perfect fit for our needs.

Here are a few reasons why I think React DayPicker would be a great solution:

Saves time and resources

Building a date picker from scratch is a complex task. It involves handling user input, managing state, and ensuring cross-browser compatibility, etc. React DayPicker has already solved these problems. By using it, we could significantly reduce the amount of time and effort required to build the date picker.

Flexibility and customizability

React DayPicker is flexible and customizable. It allows to create a date picker that fits our needs and our design. We can choose which features to include and how the date picker should look and feel, which was initially one of our main concern.

Maintained and well documented

React DayPicker is actively maintained and has comprehensive documentation. This means that we can expect regular updates and improvements, and it would be easy for us to learn how to use it and integrate it into the project.

Broad adoption and positive reviews

The library is widely used and has received positive feedback from the developer community. It is used in the Date Range Picker for shadcn/ui components

Facilitates date management

It has features for managing date ranges, which is what we need. It can handle the complexity of date management with date-fns, which is, as luxon, a lightweight alternative to moment.

I believe React DayPicker could be a great solution for the date picker. I understand that using a library is a significant decision, and I would be more than happy to discuss this proposal further.

fredericvilcot commented 1 year ago

@0xLodz

Thanks for your analysis.

To build this component, we need a modal version that can interact with two inputs fields. (see mockup - From / To)

As far as I see this library provides either a single modal component either a range selection without modal component, that seems to not fit our needs.

Furthermore, I will add 2 points:

So, tell me what do you think about implementing it from scratch in terms of deadlines and complexity, thx

loiclaudet commented 1 year ago

@fredericvilcot

Thank you for your thoughtful feedback. I understand your concerns and I agree that it's crucial that any solution we adopt fits our specific needs and aligns with our future design system.

However, I believe that using a library can still be valuable, even considering the points you have raised.

While the React Day Picker may not provide a modal solution for the range selection, it does not restrict us from creating one. We can create a modal component that wraps around the date picker. The date picker itself is responsible for selecting and managing dates, while the modal component is responsible for the user interaction. Please look at the Date Range Picker in this exemple.

The provided code snippets doesn't look messy to me. However I agree that the library code quality must respect our standards. If not, I understand that we need to build it from scratch. Since React DayPicker is customizable, we can style it to match our future design system.

In terms of implementing the date picker from scratch, it's certainly possible, but I believe it will be a complex and time-consuming task. It could take several weeks to build and test a robust, feature-complete date picker. On the other hand, using React DayPicker (or a similar solution), we could have a working date picker in a much shorter time, which would allow us to focus on other parts of the project.

We can create a POC using this library with a custom modal component, if that would help to illustrate my points. Please let me know what you think.

loiclaudet commented 1 year ago

Technical Specification

Overview

The goal of this issue is to create a Calendar component for our design system. The component will be based on the React DayPicker library and will be displayed using the Popover component from Radix UI. The Calendar component will have several variations as illustrated in the provided design:

Calendar Component Design

Technical Details

Libraries: React DayPicker and Radix UI

React DayPicker is a date picker library for React.js. It is well-documented, actively maintained, and facilitates date management, especially for managing date ranges. More details can be found in this comment.

Radix UI provides a Popover component that we will use to display the datepicker. The Popover component is a lightweight, customizable, and accessible component that is perfect for our needs.

Implementation

The Calendar component will be integrated into our design system. It will allow users to select a date or a date range depending on the variation used.

The variations of the Calendar component include:

In the context of dataverse filters, the calendar displayed is the Date Range Double View variation, shown and hidden as a popover after clicking on the From / To input buttons.

The component might be dynamically imported using React lazy and suspense API, since it doesn't represent critical content on page load.

Ontology query update

loiclaudet commented 1 year ago

@ChaimaaZaoui could you please confirm the behavior of these buttons? image "When a user clicks on any of them, the Calendar in it's Date Range Double View variation is displayed above them, as a popover". Is this scenario correct? Thanks

MdechampG commented 1 year ago

@0xLodz , as seen with @SpicySalm0n it's exactly that.

lolottetheclash commented 1 year ago

@0xLodz thanks for this tech spec, it seems good for me 👍

loiclaudet commented 1 year ago

@MdechampG do we need to handle calendar display on mobile? If yes, do we have associated mockups? Thanks

SpicySalm0n commented 1 year ago

@0xLodz I think that a specific display is needed for the mobile version but no mockup has been made but I am thinking, for example, of splitting the date selection into two parts in order to display only one calendar at a time (start and end)

loiclaudet commented 1 year ago

@SpicySalm0n it sounds good, thanks for the details! Is it possible to make a proposal for the calendar mobile display? Thank you

SpicySalm0n commented 1 year ago

@0xLodz Yes here is the display:

I put it on the DEV file since it has been validated

image

ChaimaaZaoui commented 1 year ago

For the date picker, date range design will be handled later; A button to "remove date" will also be needed on desktop; the date range will be Past Years: 100 years ; Future Years: 20 years; Days in the calenders must also be translated

ChaimaaZaoui commented 1 year ago

@0xLodz & @lolottetheclash the US is fully updated

lolottetheclash commented 1 year ago

@ChaimaaZaoui are you sure about this: "By default, no date is selected, and the datepicker displays the format DD/MM/YY." ? We've designed the display to be dynamic according to the user's chosen language, ok for you?

loiclaudet commented 1 year ago

@ChaimaaZaoui here are the displayed placeholders for existing languages:

ChaimaaZaoui commented 1 year ago

@lolottetheclash & @0xLodz that's fine for me in terms of language adaptation.

ChaimaaZaoui commented 1 year ago

Tested, All scenarios are OK