Commit Graph

57 Commits

Author SHA1 Message Date
Javi Martín
2b962f2789 Use a <main> tag on every page
Many pages had this tag, but many other didn't, which made navigation
inconsistent for people using screen readers.

Note that there are slight changes in two pages:

* The homepage now includes the banner and the content of the
  `shared/header` element inside the <main> tag
* The budgets index now includes the banner inside the <main> tag

I see both potential advantages and disadvantages of this approach,
since banners aren't necessarily related to the main content of a page
but on the other hand they aren't the same across pages and people using
screen readers might accidentally skip them if they jump to the <main>
tag.

So I'm choosing the option that is easier to implement.

Note we're adding a `public-content` class to the <main> element in the
application layout. This might be redundat because the element could
already be accessed through the `.public main` selector, but this is
consistent with the `admin-content` class used in the admin section, and
without it the <main> element would sometimes have an empty class
attribute and we'd have to use `if content_for?(:main_class)` or
`tag.main` which IMHO makes the code less consistent.

The Capybara::DSL monkey-patch is only done on the `visit` method
because it's the only reliable one. Other methods like `click_link`
generate AJAX requests, so `expect(page).to have_css "main", count: 1`
might be executed before the AJAX request is finished, meaning it
wouldn't properly test anything.
2024-03-23 00:35:43 +01:00
Javi Martín
629e208e9d Add and apply ArgumentAlignment rubocop rule
We're choosing the default `with_first_argument` style because it's the
one we use the most.
2023-08-18 14:56:16 +02:00
Javi Martín
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
taitus
af00dd94db Unify the order in which we display information
In the rest of the similar sections of the application we show the date first
and then the information of the comments.
2022-08-19 15:40:51 +02:00
taitus
2865ee286f Add comments count component
Remove all the translations that are left over after having unified them
in the component.
2022-08-19 15:40:51 +02:00
taitus
a32e249919 Remove &nbsp; after icon-comments
At some other time we will try to remove all the &nbsp;

For now we start with what we added after the comments icon.
2022-08-19 14:25:30 +02:00
Javi Martín
932da00f8d Update new topic form layout
The same way we did with debates and proposals, we move recommendations
before the form.
2021-07-13 15:27:21 +02:00
Javi Martín
cb800d0f38 Remove recommendations editing a topic
The same way we don't show recommendations when editing a proposal or a
debate.
2021-07-13 15:27:21 +02:00
Javi Martín
5214d89c88 Use order links to sort comments and topics
We use order links in many places in the web. However, in the comments
section and the list of community topics, we were displaying a
`<select>` element, and changing the location when users select an
option.

This has several disadvantages.

First, and most important, it's terrible for keyboard users. `<select>`
fields allow using the arrow keys to navigate through their options, and
typing a letter will select the first option starting with that letter.
This will trigger the "change" event and so users will navigate through
a new page while they were probably just checking the available options
[1]. For these reasons, WCAG Success Criterion 3.2.2 [2] states:

> Changing the setting of any user interface component does not
> automatically cause a change of context unless the user has been
> advised of the behavior before using the component.

Second, the form didn't have a submit button. This might confuse screen
reader users, who might not know how that form is supposed to be
submitted.

Finally, dropdowns have usability issues of their own [3], particularly
on mobile phones [4]

The easiest solution is to use the same links we generally use to allow
users select an order, so using them here we make the user experience
more consistent. They offer one disadvantage, though; on small screens
and certain languages, these links might take too much space and not
look that great. This issue affects pretty much every place where we use
order or filter links, so we might revisit it in the future.

Note we're moving the links to order comments after the form to add a
new comment. In my opinion, having an element such as a form to add a
new comment between the element to select the desired order of the
comments and the comments themselves is a bit confusing.

[1] https://webaim.org/techniques/forms/controls#javascript
[2] https://www.w3.org/WAI/WCAG21/Understanding/on-input.html
[3] https://www.youtube.com/watch?v=CUkMCQR4TpY
[4] https://www.lukew.com/ff/entry.asp?1950
2021-06-28 00:08:18 +02:00
Javi Martín
c3e0a6b089 Remove duplication rendering comments
We were using the same code 5 times, with the only slight variation
being the extra heading in the debates section.
2021-06-27 23:22:00 +02:00
Javi Martín
81f274a319 Render form to comment topics before the comments
Just like we do in debates, proposals, ... We could argue whether it's
better to have the form before or after the list of comments, but at the
very least we should have some sort of consistency.
2021-06-27 22:31:06 +02:00
Javi Martín
ae41becd3a Use CSS to hide reply forms
We were using inline styles and passing local variables around, while
the rule we were following is very simple: it's only hidden if it's a
form to reply to a comment.
2020-05-12 23:57:57 +02:00
Javi Martín
4627372a62 Use a <ul> tag for a list of comments
We were using a <ul> tag for a single comment, where the first element
of the list was the comment itself and the second element was the list
of replies.

IMHO it makes more sense to have a list of all comments, where every
element is a comment and inside it there's a list of replies.

We're also rendering the list even if it has no children so it's easier
to add comments through JavaScript. Then we use the :empty CSS selector
to hide the list if it's empty. However, since ERB adds whitespace if we
structure our code the usual way and current browsers don't recognize
elements with whitespace as empty, we have to use the `tag` helper so no
whitespace is added.
2020-05-12 23:57:16 +02:00
Javi Martín
573f861ad1 Don't use comment_flags to cache comments
Flagging a comment automatically updates the comment, so the cache
expires anyway, making the `comment_flags` variable redundant.
2020-05-11 16:09:23 +02:00
Javi Martín
928312e218 Use sanitize in translations with links
Sometimes we're interpolating a link inside a translation, and marking
the whole translations as HTML safe.

However, some translations added by admins to the database or through
crowdin are not entirely under our control.

Although AFAIK crowdin checks for potential cross-site scripting
attacks, it's a good practice to sanitize parts of a string potentially
out of our control before marking the string as HTML safe.
2019-10-08 18:46:21 +02:00
Javi Martín
6fa67b5e53 Use active record translations for labels
This way we can simplify the way we generate form fields. In some cases,
we also use the human attribute in table headers, which IMHO makes
sense.

I haven't moved all of them: for example, sometimes a label is
different depending on whether it's shown to administrators, valuators,
or users. And I haven't touched the ones related to devise, since I
wasn't sure about possible side effects.

Note I've also removed placeholders when they had the same text as their
labels, since they weren't helpful. On the contrary, the added redundant
text to the form, potentially distracting users.
2019-10-07 01:56:23 +02:00
Javi Martín
3ea9f3cecf Simplify generating form fields with labels
Instead of generating the label and then a field without a label, we can
directly generate a field with a label.
2019-10-05 16:01:58 +02:00
Javi Martín
f8bd3d4f39 Extract links to signin and signup to methods 2019-10-05 14:07:24 +02:00
Javi Martín
f5d8badeb6 Extract partial to show "login to comment" message 2019-10-05 14:07:24 +02:00
Javi Martín
78c6f6f7e9 Use the same key for "signin" and "signup" texts
We were using the same texts in several places
2019-10-05 14:07:23 +02:00
Javi Martín
ae64458fce Use the same I18n key for "login to comment" text
We were using several different keys, all of them having the same
translations.
2019-10-05 14:07:23 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
c62da726b8 Apply SpaceAroundErbTag ERB Lint rule 2019-09-10 20:02:15 +02:00
Javi Martín
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +02:00
Javi Martín
347fc21cf0 Fix trailing whitespace 2019-09-10 19:21:03 +02:00
Julian Herrero
f6489bc604 Use double quotes in app/views 2019-03-19 12:33:07 +01:00
decabeza
abf0fe992e Removes tablist and tab roles 2018-07-04 17:14:24 +02:00
decabeza
6a812659c3 Adds missing tablist and tab roles 2018-06-06 12:01:17 +02:00
Bertocq
8bfaee7267 Fix missing parenthesis on i18n.l method call 2017-12-13 14:21:20 +01:00
decabeza
0fa59401e4 improves i18n for community 2017-09-21 17:39:32 +02:00
decabeza
c887cb7366 improves html markup on communities and topics views 2017-09-21 17:35:21 +02:00
taitus
f0667937fb Refactor and extract code to partials. 2017-09-06 14:48:41 +02:00
taitus
64774b0d2d Refactor topics controller. Add Common abilities. Add destroy action. 2017-09-06 13:30:12 +02:00
taitus
62003b3000 Add back link on community show. Add styles on login to create topic. 2017-09-05 12:55:12 +02:00
taitus
47f897840a Refactor translates and indent. 2017-09-05 12:55:12 +02:00
Alessandro Cuoghi
f67f4c85c7 If there is no theme, add text and link. 2017-09-05 12:55:12 +02:00
Alessandro Cuoghi
634d782c2c Fixed error label. 2017-09-05 12:54:32 +02:00
taitus
8f7356f7a4 Add missing spec. Improve readability on topics files 2017-09-05 12:54:32 +02:00
taitus
54cf210b07 Fix rebase with master. 2017-09-05 12:53:37 +02:00
taitus
895c942a39 Add community to investments 2017-09-05 12:52:45 +02:00
taitus
4539c5fa00 Refactor and tests. 2017-09-05 12:52:14 +02:00
Alessandro Cuoghi
555c47e012 Clean code. 2017-09-05 12:51:08 +02:00
Alessandro Cuoghi
1e60bc5cc2 Remove some css. Pass scss-lint 2017-09-05 12:51:08 +02:00
Alessandro Cuoghi
35f6ce4b86 Translate button editar. Activated translations into wide_order_selector. 2017-09-05 12:51:08 +02:00
Alessandro Cuoghi
322ecf4fd5 Changed some translations. 2017-09-05 12:51:08 +02:00
Alessandro Cuoghi
e5fb90f954 Renaming class. Topic show: Added author_info. 2017-09-05 12:51:08 +02:00
Alessandro Cuoghi
11f6515e84 Style topic show. Fix tabs-panel. 2017-09-05 12:51:08 +02:00
Alessandro Cuoghi
83683eb53f Changed community.yml buttons. 2017-09-05 12:51:08 +02:00
taitus
a1d37fa6c4 Add order on topic index. 2017-09-05 12:51:08 +02:00
Alessandro Cuoghi
b4cdca215d Added style show community. 2017-09-05 12:51:08 +02:00