Skip to content
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

[front] feat: add buttons to compare criteria #1968

Merged
merged 73 commits into from
Nov 14, 2024

Conversation

GresilleSiffle
Copy link
Collaborator

@GresilleSiffle GresilleSiffle commented May 7, 2024

related issues #1940


Description

This PR adds a new comparison method for mobile devices: buttons.

capture

Features

  • the main criterion is mandatory and can't be skipped
  • the arrows allow to navigate between the criteria
  • to clear a score given to a criterion, click on the active comparison button
  • the criteria are displayed according to the user's preferences

How the front end chooses to display buttons or sliders?

If the displayed comparison has been previously made with buttons, the buttons are displayed. If it has been rated by sliders, sliders are displayed.

If the displayed comparison is new, the button are displayed for devices not matching the media query (pointer:fine), and the sliders are displayed for all other devices (See the pointer media feature).

No conversion from buttons to sliders and from sliders to buttons is allowed for now.

Future improvements

  • disable by default the weekly collective goal on mobile devices to save space, and to make the UI more simple, add a setting to control this behaviour
  • suggested in Discord add a setting to control display of the buttons auto and select (they are currently displayed above the entity cards, but they could be displayed below to ease the navigation on mobile devices)

to-do

front end - tutorial

  • test the tutorial
  • update the texts to match the buttons on mobile devices

front end - buttons

  • make the buttons look like buttons
  • make them "selected" when a criterion has been given a score
  • disable them during API requests
  • add the possibility to swipe up and down
  • add hints about swipe up and down
  • prevent skipping the main criterion of the poll
  • display a "continue or change video" after all mandatory criteria have been rated?
    • not for now

front end - comparison input

  • display buttons when the score_max of the main criterion is 2
  • else display sliders if the score_max of the main criterion is 10
  • else display buttons on smartphones
  • else display sliders
  • handle incoherent score_max between != criteria

front end - comparison scores review

  • add the possibility to view all criteria at once
    • add a proto of the table view
  • display the review only when buttons are displayed
    • factorise duplicated code

front end - comparison

  • add the possibility to clear the score of an already submitted optional criterion
  • rework the margin and padding of the grid items to save space

front end - coherence

  • when displaying a "mobile" comparison on desktop
    • display the buttons, and add a message "this comparison has been made on mobile"
    • allow the users to update their comparison
  • when displaying a "desktop" comparison on mobile
    • display the sliders, and add a message "this comparison has been made on desktop"
    • make the sliders read-only

Preview

capture

A "mobile" comparison displayed on desktop:

screencapture-localhost-3000-comparison-2024-06-10-11_29_03

Checklist

  • I added the related issue(s) id in the related issues section (if any)
    • if not, delete the related issues section
  • I described my changes and my decisions in the PR description
  • I read the development guidelines of the CONTRIBUTING.md
  • The tests pass and have been updated if relevant
  • The code quality check pass

@GresilleSiffle GresilleSiffle changed the title [front] feat: (WIP) add buttons to compare criteria WIP / [front] feat: add buttons to compare criteria May 7, 2024
@GresilleSiffle GresilleSiffle added the Frontend Front-end code of Tournesol label May 7, 2024
@GresilleSiffle GresilleSiffle self-assigned this May 8, 2024
@GresilleSiffle GresilleSiffle added this to the Mobile Friendliness milestone May 15, 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On iOS, the "overscroll" rule has no effect. It's necessary to add

html {
  overscroll-behavior-y: none;
}

(if it has not undesirable effect on Android)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by 2b6e534

import CriterionButtons, { BUTTON_SCORE_MAX } from './CriterionButtons';
import { useOrderedCriteria } from 'src/hooks/useOrderedCriteria';

const SWIPE_TIMEOUT = 240;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the animation is a bit slow and frustrating when looking for a specific criterion. Why not using the same value as in the EntitySelector?

Suggested change
const SWIPE_TIMEOUT = 240;
const SWIPE_TIMEOUT = 180;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by e3bed73

@GresilleSiffle
Copy link
Collaborator Author

With a9655a1 I added an icon in the list of comparisons to indicate whenever a comparison has been made on a mobile device.

capture

@GresilleSiffle GresilleSiffle marked this pull request as ready for review October 31, 2024 17:31
amatissart and others added 3 commits November 14, 2024 10:54
…h all criteria (#2024)

* make 'next' buttons glow after has user has looped through all criteria

* reduce padding of ContentHeader to gain some more vertical space

* refactor: factorize behaviour of setHasLoopedThroughCriteria

* fix: prevent accidental click on the criteria link

* style: slightly faster glowing animation

* ui: more understandable submit message on mobile

---------

Co-authored-by: Gresille&Siffle <39056254+GresilleSiffle@users.noreply.github.com>
@GresilleSiffle GresilleSiffle merged commit 53a70e0 into main Nov 14, 2024
6 checks passed
@GresilleSiffle GresilleSiffle deleted the 1940-replace_sliders_by_buttons branch November 14, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Front-end code of Tournesol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants