Commit Graph

18014 Commits

Author SHA1 Message Date
Javi Martín
80dbdeec98 Simplify borders in dashboard resource cards
In both cases we were using a 2px solid border with the color of the
current text, so we can write the rule once and without defining the
colors.
2021-06-29 20:03:36 +02:00
Javi Martín
0c2e752932 Simplify overriding menu dropdown icon color
By default Foundation uses a `#1779ba transparent transparent`
transparent border. We were overriding the whole border, when we only
needed to override the top border. Furthermore, we were overriding it
twice: once in the public area and once in the admin area. However, if
we use `currentcolor`, we only have to override it once, and in both
cases the border will have the same color as the text surrounding it
(white in the public area and black in the admin area).
2021-06-29 20:03:36 +02:00
Javi Martín
28ae1a369a Merge pull request #4514 from consul/link_colors
Simplify using text color for links
2021-06-29 20:03:13 +02:00
Javi Martín
ef21498cf5 Merge pull request #4513 from consul/obsolete_colors
Remove unused CSS to set colors
2021-06-29 19:57:22 +02:00
Javi Martín
e6c1cf7743 Simplify colors in admin header
Not that we've simplified the top bar colors, we can just use a
transparent header to get the same background as the body.
2021-06-29 19:45:09 +02:00
Javi Martín
8e8a4d784c Simplify using text color for links
Using `inherit` is IMHO more expressive since it means "use the color of
the parent element".

This is particularly useful for CONSUL installations using custom
styles. Consider the following code:

```
h2 {
  color: $white;

  a {
    color: $white;
  }
}
```

If we'd like to customize the way headings look, we'd have to override
two colors:

```
h2 {
  color: $red;

  a {
    color: $red;
  }
}
```

Consider the scenario where we use `inherit`:

```
h2 {
  color: $white;

  a {
    color: inherit;
  }
}
```

Now we only need to override one color to change the styles:

```
h2 {
  color: $red;
}
```
2021-06-29 19:45:09 +02:00
Javi Martín
bc7005aeef Simplify dropdown menu colors
Using `inherit` we don't have to overwrite the styles in the admin menu.
2021-06-29 19:45:09 +02:00
Javi Martín
9a94a5f87f Simplify top bar colors
The text color is inherited from the `<header>` element since commit
e2d540d20, while the background color can also be inherited as well.
2021-06-29 19:45:09 +02:00
Javi Martín
41893f3435 Differenciate links in summaries
Using the same color as text made it impossible to visually recognize
the link. Users might click the link accidentally while trying to select
the text of that link.

Furthermore, sighted keyboard users would be surprised when tabbing
through the interface and realizing some apparently normal text is
really a link.
2021-06-29 19:45:09 +02:00
Javi Martín
7d8a64cb1f Remove unused poll table styles
These styles aren't used since commit 6f324c693.
2021-06-29 19:41:58 +02:00
Javi Martín
ede4515230 Remove unused stats styles
These classes aren't used since commit e5a2440e9 and the styles were
accidentally added when bringing code from Madrid's fork in commit
ba67bb2f9.
2021-06-29 19:41:58 +02:00
Javi Martín
33a40acf74 Remove obsolete dark heading styles
The `.dark-heading` selector isn't used in proposals since commit
ac58f3049, and it isn't used anywhere since commit 1b3cdc181.
2021-06-29 19:41:58 +02:00
Javi Martín
067aa4169a Remove obsolete styles for stats menu
All menus in the sidebar are "vertical". These styles aren't used since
commit b91b766e96.
2021-06-29 19:41:58 +02:00
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