Commit Graph

17301 Commits

Author SHA1 Message Date
Javi Martín
4d69882e77 Remove obsolete poll callout styles
There's no element with the `callout` class inside a `polls-show-header`
since commit 70a35fbe5.
2021-06-29 19:41:58 +02:00
Javi Martín
c67fc8a814 Remove unused CSS for verified organizations
It isn't used since commit f17d0a663.
2021-06-29 19:41:58 +02:00
Javi Martín
d45bf4d5da Remove redundant menu link colors
The color is inherited from the `.top-bar .menu > li a` selector.
2021-06-29 19:41:58 +02:00
Javi Martín
41235f9f02 Remove obsolete menu-text styles
Since commit dcec003d0 we're only using the menu-text class in the admin
layouts. So instead of defining styles for menu-text and then
overwriting them in the admin section, we can define them just in the
admin section.

Since we don't have <img> tags in the menu-text element in the admin
section, we can remove their styles. And we can also remove the styles
we were overriding twice (like `line-height`).
2021-06-29 19:41:58 +02:00
Javi Martín
f32c0e3c91 Remove obsolete style for f-dropdown
It isn't used since commit 3752f3a53.
2021-06-29 19:41:58 +02:00
Javi Martín
cd22d65a3f Remove no longer necessary style
The color of the top links is inherited from the color of the `<header>`
element, which was added in commit e2d540d20.
2021-06-29 19:41:58 +02:00
Javi Martín
c6b962e64f Remove unused style
We don't have any links inside poll question headings.
2021-06-29 19:41:58 +02:00
Javi Martín
143ba490cb Remove redundant CSS color properties
Since we were using the color already defined in the `<body>` element,
these elements can inherit that color instead of specifying it.
2021-06-29 19:41:58 +02:00
Javi Martín
716ab81ee4 Remove obsolete styles
These styles aren't necessary since commit aabf8493f. Now the "Go back"
link in the budgets section can use the same color as in the other
sections, while the other texts inherit the usual colors.
2021-06-29 19:41:58 +02:00
Javi Martín
f27d1231bb Remove unused CSS selector
In the dashboard navigation, each link is inside a list item, so the
selector `a ~ a` is never used.
2021-06-29 19:41:58 +02:00
Javi Martín
a81aac6738 Merge pull request #4506 from consul/foundation_settings
Make it easier to customize Sass variables
2021-06-29 19:41:31 +02:00
Javi Martín
38436b1102 Load vendor CSS before application CSS
So we make sure the rules we add will take precedence over vendor rules.
2021-06-29 17:08:40 +02:00
Javi Martín
52bc16bf88 Make it easier to override CONSUL Sass variables
Now that we load this file before loading the `_settings.scss` file, we
can safely use the `!default` flag.

This makes it easier to override these variables by adding a new file
and loading it before `_consul_settings.scss` is loaded. For instance,
we've got this code related to the `$brand` variable:

```
$brand:             #004a83 !default;
$brand-secondary:   darken($brand, 10%) !default;
$dark:              $brand-secondary !default;
$link:              $brand !default;
$debates:           $brand !default;
$tooltip-background-color: $brand !default;
```

If we override `$brand` in `_custom_settings.scss`, variables like
`$link` won't be affected by this change. In order to do so, we'd need
to load `_custom_settings.scss` before loading `_consul_settings.scss`.

So why aren't we loading `_custom_settings.scss` first, just like we
load `_consul_settings.scss` before loading `_settings.scss`? Mainly,
compatibility reasons. Some people might have this code in their
`_custom_settings.scss` file:

```
$dark: darken($brand, 30%);
```

If we load this file before loading `_consul_settings.scss`, we'll get
an error because `$brand` isn't defined at this point.

So we're introducing a new file where variables can be overriden before
they are defined while keeping the option to override them after they
are defined.

We're updating the comments in these files to define the new behavior,
and removing the links (which point to places which don't exist since
commit 392d633d2) in order to make it easier to read the comments.
2021-06-29 17:08:40 +02:00
Javi Martín
211e400b1c Overwrite close button color using Sass variables 2021-06-29 17:08:40 +02:00
Javi Martín
bb164f88ed Remove no longer necessary overrides
We were overriding these values because the `$body-font-family` and
`$global-radius` variables were defined after the values in the
`_settings.scss` file had been computed.

Now these values are defined before the values in the `_settings.scss`
are computed, so we don't need to override the values which depend on
them anymore.
2021-06-29 17:08:40 +02:00
Javi Martín
10479148eb Override Foundation variables everywhere
We were loading all Foundation variables and then overriding them. This
is problematic because we were overriding variables after using them.
For instance, we had this code in `_settings.scss`:

```
$black: #0a0a0a;
$white: #fefefe;
$body-background: $white;
$body-font-color: $black;
```

That meant we were setting `$body-background` to `#fefefe`, and
`$body-font-color` to `#0a0a0a`. Even if we changed the values of
`$black` and `$white` later, `$body-background` and `$body-font-color`
were not affected by this change.

So now we're overriding `$black` and `$white` before setting
`$body-background` and `$body-font-color`. In order to keep our custom
values instead of overriding them, we're using the `!default` flag in
the `_settings.scss` file.

This way of defining variables in the `_settings.scss` file with the
`!default` flag is recommended in the documentation regarding the
settings file [1].

There's also a disadvantage to this approach. Now that we're loading the
`_consul_settings.scss` file first, we can no longer use Foundation
variables inside the `_consul_settings.scss` file unless we define them
in this file as well.

[1] https://get.foundation/sites/docs/sass.html#the-settings-file
2021-06-29 17:08:40 +02:00
Javi Martín
fc0db1956d Remove unused Sass variables
We don't use accordions anywhere; these settings probably come from an
earlier Foundation version and we forgot to remove them.
2021-06-29 17:08:40 +02:00
Javi Martín
4474ec4cd1 Move CONSUL variable to CONSUL variables section
Foundation does not have a variable named `$font-family-serif`.
2021-06-29 17:08:40 +02:00
Javi Martín
59cbfd21be Remove redundant variable
It was defined twice in the same file.

Since it's also defined by Foundation, I'm keeping the one in the
"Foundation overrides" section.
2021-06-29 17:08:40 +02:00
Javi Martín
626af63a42 Merge pull request #4565 from consul/improve-home-cards
Improve home cards
2021-06-29 17:07:07 +02:00
taitus
db23d536dd Do not show link content section when links fields are not defined. 2021-06-29 16:53:37 +02:00
Javi Martín
a8fe8aceda Merge pull request #4567 from consul/advanced_search_position
Fix advanced search button position
2021-06-29 14:45:02 +02:00
Javi Martín
16401dafdb Fix advanced search button on large screens
Since we were using `position: absolute` to position the button to the
right, we were assuming there was enough screen space on the left so
other elements (mainly, order selector links) could be there.

However, that wasn't always the case. In some languages, the texts
appearing on the left of the button were much larger than in English,
meaning their text and the button text could overlap. Even in English,
users could experience the same issue depending on their font size
preferences and the size of their screens.

The easiest solution is to move the button to its own line, so its text
doesn't overlap.
2021-06-29 14:30:28 +02:00
Javi Martín
a2f6e03516 Move advanced search toggle button inside the form
Since forms are landmarks, screen reader users might navigate to the
form. But then they were going to find an empty form with no way to
toggle it.

Moving the button inside the form means screen reader users navigating
to the form will find the button to toggle it.

It also helps us simplifying the code; there's no need to use
data-attributes to communicate whether the form should be visible since
now we can easily use the button `aria-expanded` attribute.

We could further simplify the JavaScript if we used a CSS rule to
show/hide the form fields based on the toggle button `aria-expanded`
attribute. However, implementing the "slide" animation we use when
toggling the form with CSS is difficult and unreliable.
2021-06-29 14:13:54 +02:00
Javi Martín
6a44ca350d Render the advanced search form without JavaScript
We were using the form and then showing it with JavaScript when advanced
search terms were present. Now we hide it with JavaScript when no
advanced search are present. This means users without JavaScript
(including users with JavaScript enabled but bad internet connections
preventing the JavaScript to load) can now access the form.

The other main difference between the two versions is the way the form
flashes while JavaScript is loading.

Previously, the form would always be hidden when no terms had been
introduced. However, when these terms were present, after submitting the
form it would briefly be hidden and then shown again.

Now the opposite happens. When advanced search terms are present, the
form is shown at all times. However, when they aren't, the form is
briefly shown before it disappears.

Here the previous behavior is arguably better because most of the time
these terms will not be present.

So basically we're significantly improving the experience of some users
at the cost of slightly worsen the experience of other users.

We're also hiding the button to show the form when JavaScript is
disabled, since in this scenario it's useless. We're using the `hidden`
attribute so hidden buttons can be detected in CSS.
2021-06-29 14:13:53 +02:00
Javi Martín
f6979d1a79 Simplify advanced search form markup
Now the advanced search form is an actual form instead of a div
containing a form.
2021-06-29 13:58:32 +02:00
Javi Martín
2f5f674b24 Fix advanced search button on small screens
Once the button was pressed, part of the form appeared next to the
button instead of appearing below it.
2021-06-29 13:58:32 +02:00
Javi Martín
b0e82d636e Remove redundant position property
I guess it was there to make a contrast with the CSS used for the
version for medium and large screens. However, it isn't necessary and
the absence of this property already makes a contrast with the presence
of the property for medium and large screens.
2021-06-29 13:58:32 +02:00
Javi Martín
6dcdf5c843 Use a button to toggle the advanced search form
Users (particularly, screen reader users) usually identify links with
things that take you somewhere, and buttons with things that either send
forms or change things on the page.

Using a button we can also use the `aria-expanded` attribute, meaning
screen reader users will know that the button has two states ("expanded"
and "collapsed"), the current state of the button, and will get
immediate feedback when clicking the button because the new state of the
button will be announced.

Thanks to this change, we can also slightly simplify the code; we
obviously have to remove the (useless) `href` attribute, and we don't
have to prevent the default event in JavaScript since there's no default
event for buttons with `type="button"`.
2021-06-29 13:58:32 +02:00
Javi Martín
a783b1a3d0 Merge pull request #4566 from consul/order_links
Use links instead of order selectors everywhere
2021-06-29 13:57:49 +02:00
taitus
108de86da5 Add link_url validation for cards when are header cards
Add link_url presence validation only when link_text is provided only for header cards.

In this case it makes sense to allow creating a "header card" without link_url, since
we can show the header without link text and without link url and it still does its
function.
2021-06-28 15:59:04 +02:00
taitus
1d47a5c079 Add link_url validation for cards when are not header cards
Currently it is not necessary to include the link_url field.

When we display these cards without link_url, they create an empty link that
redirects to the same page. I understand that this is not a desired behavior, so I
think it is better to add a validation in this case and force administrators to add a
link_url when creating a card.
2021-06-28 15:57:39 +02:00
Javi Martín
109edd4084 Merge pull request #4532 from consul/ignore_compiled_assets
Avoid adding compiled assets to version control
2021-06-28 12:59:34 +02:00
Javi Martín
bc0f040758 Use order links in legislation proposals admin
As mentioned in the previous commits, a `<select>` field which submits
its form on change causes many accessibility and usability issues, so
we're replacing it with the order links we use everywhere else.

Since the links "Id" and "Title" by themselves don't have enough
information to let users know they're used to sort by ID or title, we
have to update them somehow. We could add a "Sort by:" prefix before the
list of links (and associate it with the `aria-labelledby` attribute);
however, we don't do this anywhere else and might look weird depending
on the screen size.

So we're simply adding "Sort by" before each link.

Now that we don't use the `wide_order_selector` partial anymore, we can
remove it alongside the styles for the `select-order` class.
2021-06-28 01:20:39 +02:00
Javi Martín
d672a4294a Remove unused internationalization key
It looks like it isn't used since we replaced the order selector with
order links in debates a few years ago, in commit 7eda0b288.
2021-06-28 00:15:08 +02:00
Javi Martín
14d8bef0d8 Use order links in print proposals management
A `<select>` tag here might make more sense than in other similar places
since there are 5 options to choose among, and using links might take
too much screen space.

However, as mentioned in the previous commits, `<select>` tags which
automatically submit a form have many accessibility and usability
issues.

An alternative would be to create a dropdown menu with a button and a
list of links (similar to what Foundation does). I'm keeping the links
for simplicity and because the interface looks a bit more consistent
with the rest of the sections. Before these changes, we had a heading,
then a `<select>` field to choose the filter, and then a button to print
the page. We never use a similar interface, and some people might think
the "Print" button is related to the same form as the `<select>` field.

Now that we don't use the `order_selector` partial anywhere anymore, we
can remove it.
2021-06-28 00:15:08 +02:00
Javi Martín
227a5868b8 Use order links in moderation section
Using order links in this case causes an unusual interface, where we
show filter links, then information about the number of results, and
then order links.

Whether or not this makes sense needs to be confirmed with usability
tests. In any case, this is still way better than using `<select>`
fields which automatically change to a new page, since they cause
problems to keyboard users, are harder to select for touchscreen users,
might confuse screen reader users who will notice a form but no way to
submit it, and are not elements we generally use to let users choose the
order of the records.

For a more detailed explanation of these issues, check the commit
message in the commit "Use order links to sort comments and topics"
(just a few commits ago).
2021-06-28 00:15:08 +02:00
Javi Martín
55cf502e8f Fix typo in proposal notifications moderation test 2021-06-28 00:15:08 +02:00
Javi Martín
d2f38fd276 Reduce duplication in moderation sections
We had five almost-identical views. Now we've removed most of the
duplication, although the tables are still similar. We might refactor
them in the future.
2021-06-28 00:15:08 +02:00
Javi Martín
5db6edfbd2 Simplify internationalization key in moderation
In keys like `hide_debates`, the suffix part is redundant when that key
is part of an absoulte key starting with `moderation.debates`.

This change will make it easier to remove duplication in moderation
views.
2021-06-28 00:15:08 +02:00
Javi Martín
93f3411a30 Use anchors in comments order and pagination links
It was a bit frustrating to click on one of the order elements or the
link to the next page and having to scroll down again until reaching the
comments.
2021-06-28 00:15:06 +02:00
Javi Martín
cdd1e04550 Extract methods in order links component 2021-06-28 00:08:19 +02:00
Javi Martín
5137913565 Move order links partial to a component
This way the changes we have in mind we'll be easier to implement.
2021-06-28 00:08:19 +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
beb24670ab Extract method in comments component 2021-06-27 23:25:16 +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
92ad957735 Merge pull request #4499 from consul/related-content-exist
Improve the management of related content
2021-06-25 17:31:06 +02:00
taitus
ee66c4182a Return error when the related content already exists
It looks like this bug was introduced in commit 7ca55c4. Before that
commit, a message saying "You added a new related content" was shown,
but (as expected) the related content wasn't added twice.

We now check this case and add a slightly clearer message.
2021-06-25 17:15:34 +02:00
Javi Martín
d2876f5565 Merge pull request #4505 from consul/social_footer
Avoid rendering empty lists in top links and footer
2021-06-24 13:29:48 +02:00