Commit Graph

16680 Commits

Author SHA1 Message Date
Javi Martín
db4a262a0d Merge pull request #4571 from consul/campaigns_specs
Make campaign specs more robust
2021-06-30 16:16:28 +02:00
Javi Martín
bf5afd8e7c Add missing expectation to related content test
It looks like we accidentally missed it while rebasing commit
48dc72cea9.
2021-06-30 16:13:37 +02:00
Javi Martín
2eb02d555a Merge pull request #4568 from consul/executions_filters
Use a submit button in budget executions filters
2021-06-30 16:06:18 +02:00
Javi Martín
28e720a1ec Make sure we use non-existent IDs in campaign test
Previously, depending on the database status, it could be possible that
the ID of the campaign2 record was exactly 999 and this test could fail.
2021-06-30 16:00:07 +02:00
Javi Martín
855f47f386 Create campaings before running campaigns tests
We were defining campaigns with `let`. That meant they weren't created
until these methods were used in the tests.

For the test "Do not track erroneous track_ids", that meant the line
`expect(page).not_to have_content campaign2.name.to_s` wasn't really
testing anything, since before this line is executed, the campaign2
wasn't in the database at all, and so obviously its name wouldn't be on
the stats page.

For the test "Track email templates", it meant we were creating the
campaign2 record after visiting the campaign1 page with the browser.
Creating records in the tests after starting the browser might be the
reason why this test has recenty failed in our CI [1]:

 1) Email campaigns Track email templates
     Failure/Error: ds.add params[:event].titleize, Ahoy::Event.where(
                    name: params[:event]).group_by_day(:time).count
     ActiveRecord::StatementInvalid:
       PG::ProtocolViolation: ERROR:  bind message supplies 0
       parameters, but prepared statement "" requires 1
     # ./app/controllers/admin/api/stats_controller.rb:13:in `show'

Using `let!` to create the campaings before the browser starts improves
the situation.

[1] https://github.com/consul/consul/runs/2952333023
2021-06-30 16:00:00 +02:00
Javi Martín
450d954526 Don't add default margin to font awesome icons
We were removing the margin half of the time, and sometimes removing it
made us use `!important` rules.
2021-06-30 15:01:47 +02:00
Javi Martín
5531a0b2bc Simplify action links in budgets table
The word "budget" in the "Preview budget" link is redundant.

On the other hand, the words "Manage", Edit" and "Admin" are not
really necessary in my humble opinion. Just like in the admin
navigation menu we use "Participatory budgets" instead of "Manage
Participatory budgets", the fact that we're going to manage or
admin or edit something can be deduced from the fact that we're in
the admin section.

Besides, it isn't clear to me why we use "Manage" for projects,
"Edit" for heading groups and "Admin" for ballots. The differences
between these three concepts might be too subtle for me.

The previous paragraphs haven't been corroborated with real users,
though, so I might be mistaken and we might need to revisit these
links in the future.

These actions still take quite a lot of space. Maybe in the future we
could remove the "delete" icon, at least on budgets which cannot be
deleted.
2021-06-30 14:33:37 +02:00
Javi Martín
6f04c8f057 Use conventions in page actions texts
We use the words "Manage" and "View" in other places; we don't use the
word "See" as often.
2021-06-30 14:33:37 +02:00
Javi Martín
7d590031f5 Remove redundant words in edit and destroy links
When we see a list of, let's say, banners, and each one has a link to
edit them, the word "banner" in the text "edit banner" is redundant and
adds noise; even for users with cognitive disabilities, it's obvious
that the "edit" link refers to the banner.
2021-06-30 14:33:37 +02:00
Javi Martín
25e9065913 Use icons with text in admin table actions
In commit 9794ffbbf, we replaced "buttons" with icons in order to make
the admin interface consistent with the planned budget investments
redesign.

However, using icons has some issues. For once, icons like a trash for
the "delete" action might be obvious, but other icons like "confirm
moderation" or "send pending" might be a bit confusing.

It's true that we were adding tooltips on hover. We tried two
approaches: using Foundation's tooltips and using CSS tooltips.

Foundation tooltips are not activated on focus (only on hover), while
CSS tooltips always appear below the icon, which might be a problem when
the icons are at the bottom of the screen (one of our milestone tests
was failing because of that and we can now run it with JavaScript
enabled).

Both Foundation and CSS tooltips have other issues:

* They force users to make an extra step and move the mouse over the
  link just to know what the link is about
* They aren't available on touch screens, so these users will have to
  memorize what each icon does
* They are not hoverable, and making them hoverable would cause a
  different issue because the tooltip might cover links below it, making
  it impossible to click these links without moving the mouse away
  first
* They are not dismissable, which is considered an accessibility issue
  and a requirement in the Web Content Accessibility Guidelines [1]

For all these reasons, we're using both texts and icons. As Thomas
Byttebier said "The best icon is a text label [2]". Heydon Pickering
also makes a point towards providing text alongside icons in his book
"Inclusive Components" [3].

Note that, since we're now adding text and some of the colors we use for
actions are hard to read against a white/gray background, we're making a
few colors darker.

With these changes, actions take more space in the admin table compared
to the space they took in version 1.3, but they are more usable and
accessible while they still take less space than they did in version
1.2.

[1] https://www.w3.org/WAI/WCAG21/Understanding/content-on-hover-or-focus
[2] https://thomasbyttebier.be/blog/the-best-icon-is-a-text-label
[3] https://inclusive-components.design/tooltips-toggletips/
2021-06-30 14:33:37 +02:00
Javi Martín
db55a744ec Include disabled state in base button mixin
So all disabled buttons have the same styles.
2021-06-30 14:14:43 +02:00
Javi Martín
614e6da92b Use a submit button in budget executions filters
As mentioned in commit 5214d89c8, there are several issues with
submitting a form when a `<select>` tag changes. In particular, keyboard
users might accidentally fire the event while browsing the options, and
screen reader users will find a form with no obvious way to submit it.

In this case, there's an extra problem: in commit be8a0dbe8 we added a
second `<select>` field to this form, which also submitted on change.
Sometimes users changed one of the values and wanted to change the other
value as well before submitting the form. However, it wasn't possible,
because we would submit it before they had a chance to change the second
value.

So now we don't submit the form on change and add a submit button. This
is similar to what we do in the "Advanced filters" we use in several
places.
2021-06-30 14:14:43 +02:00
Javi Martín
d4bebc810a Merge pull request #4520 from consul/border_color
Simplify using current color on borders
2021-06-30 13:54:55 +02:00
Javi Martín
ee4ef8d3a5 Use labels to select filters in executions tests
This way we check there's a label associated to these fields.
2021-06-29 20:07:55 +02:00
Javi Martín
d8d5b7f60a Extract budget executions filters to a component 2021-06-29 20:07:55 +02:00
Javi Martín
b2a05322fd Simplify using current color on borders
Using `currentcolor` is IMHO more expressive, since it shows the
intention of styling the border with the same color as the text.

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

```
.is-active {
  border: 1px solid $brand;
  color: $brand;
}
```

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

```
.is-active {
  border: 1px solid $brand-secondary;
  color: $brand-secondary;
}
```

Consider the scenario where we use `currentcolor` (which is the default
border color):

```
.is-active {
  border: 1px solid;
  color: $brand;
}
```

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

```
.is-active {
  color: $brand-secondary;
}
```
2021-06-29 20:03:36 +02:00
Javi Martín
7053b17e64 Simplify setting border on active menu elements
Since we are using the same color as the text color in both the public
and admin areas, we can omit the border color completely. Since now
admin elements get the exact same border, we can remove this border so
they'll inherit the same border as used in the public area.
2021-06-29 20:03:36 +02:00
Javi Martín
2efc307e59 Simplify changing "delete/remove" links styles
Since we're only changing the style of the border in one case and the
color in the other case, we don't have to duplicate the code for every
property.

This makes it easier for other CONSUL installations to customize these
borders.
2021-06-29 20:03:36 +02:00
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