Commit Graph

1644 Commits

Author SHA1 Message Date
Javi Martín
288ae13958 Merge pull request #4687 from consul/phases_image_button
Fix "Add image" button styles in budget phases
2021-09-14 13:19:30 +02:00
Javi Martín
e2d680947a Add separator in small screen navigation
The "Sign in" or "My account" links and the main navigation are
different elements, and they're in different places on medium and large
screens. Now we're also separating them on small screens.

Since the `.vertical` class in the menu added quite a few styles and it
was difficult to overwrite them, we're simply removing this class from
this element. This way we're also removing the huge space between the
menu button and the first element of the navigation.
2021-09-12 14:20:53 +02:00
Javi Martín
00565bba6a Increase login links touch area on small screens
On small screens, the "Sign in", "Register", "My content", "My account"
and "Sign out" links didn't have much padding nor space between them,
and it was easy to accidentally click the wrong link.

This change also positively affects the menu on medium and large
screens. When one of the options (like "SDG content") had a text
spanning over two lines (like it happens in Swedish), there was barely
any space between those two lines. So we're using `line-height: inherit`
instead and adjusting the padding accordingly.
2021-09-12 14:00:42 +02:00
Javi Martín
4fbe2d99d5 Simplify small screen styles in admin submenu
Some of these styles were redundant and so we can remove them.
2021-09-12 14:00:42 +02:00
Javi Martín
877eb44bd4 Simplify logo layout in admin header
Having the logo inside a list of one item wasn't needed and its classes
conflicted with other elements with the `.menu` class.
2021-09-12 14:00:40 +02:00
Javi Martín
59da7d0af4 Fix "Add image" button styles in budget phases
It was broken since we fixed issues with other image fields in commit
394a94cbf, because there we added a fieldset for the image fields, and
so they inherited the styles in budget phases fields (these styles were
added before it was possible to attach an image to a phase).
2021-09-12 13:47:15 +02:00
Javi Martín
4ea30da299 Fix line height in subnavigation items
When, on small screens, a navigation element had a very long text
causing it to span over multiple lines, the space between each line was
the same as the space between elements. This made it hard to see where
elements started and ended.

Using a padding to separate the contents of one element and the contents
of the next one solves the issue.
2021-09-12 01:25:10 +02:00
Javi Martín
9f1f912d84 Remove official level filter from advanced search
User testing has shown this filter isn't really useful and sometimes
makes users wonder what it's about. This is particularly true in CONSUL
installations which don't change the default values (most of them),
since users will see a filter with options like "Official position 1".
2021-09-11 17:28:38 +02:00
Javi Martín
a868a5ff35 Change Foundation text direction in RTL languages
This way, when the language is written form right-to-left, elements
using Foundation mixins/classes will float to the opposite direction as
they do in left-to-right languages. The same will apply to text
alignment.

To offer full support for RTL languages, we need to change every single
reference to `float: left`, `float: right`, `text-align: left`,
`text-align: right`, and possible adjust other properties like `left`,
`margin-left`, `padding-left` or `border-left`. In the meantime, we at
least partially support these languages.

Replacing `float` with `flex` when possible would also improve RTL
support.
2021-08-16 17:47:33 +02:00
Machine Learning
4d27bbebad Add experimental machine learning 2021-08-16 16:31:04 +02:00
Javi Martín
c8d8fae98d Move related list partial to a component
This way the code is easier to follow; the code checking whether the
list has contents is in the partial rendering the list.

We also remove some duplication setting up related content in the
controllers.

For some reason, we have to manually ignore i18n keys which were
automatically ignored when the code was in the view.
2021-08-16 16:30:13 +02:00
decabeza
4a9aae9806 Add groups index page
When render the investment list component with the link "see all
investments", now we redirect to groups index page when a budget has
multiple headings.
2021-08-09 21:45:29 +02:00
Javi Martín
3cd2529791 Fix huge header in participatory budgets
The budget header was supposed to be huge, but only in the participatory
budgets index or show actions. It was still huge, with plenty of empty
space, when there was no budget, or in the "submit my ballot" and
"select a heading" pages.
2021-08-09 20:07:51 +02:00
Javi Martín
297956b579 Extract placeholder selector for budget header
This way it'll be easier to reuse its main properties.
2021-08-09 20:07:51 +02:00
Javi Martín
c0a6bf54fc Fix invisible error message in attachments
In commit cc6f9391f we made the images and documents file inputs
invisible (instead of using `display: none`) in order to make it
possible to attach images and documents using the keyboard.

However, since the error messages associated to these inputs has the
same HTML class as the inputs, we were also hiding them (the `display:
none` didn't affect the error messages because they've also got the
`is-visible` class).

Using the `[type=file]` selector we make it more explicit that we only
want to style these inputs.

I'm not adding a test for this scenario because technically the text is
there and I'm not sure how to test for the presence of invisible
elements.
2021-07-27 23:57:41 +02:00
Javi Martín
cc6f9391fc Fix attaching files using the keyboard
We were hiding the file input and styling the label as a button instead.
Since clicking on a label has the same effect as clicking on the input,
the input worked properly for mouse and touch screen users.

However, hiding the input makes it inaccessible for keyboard users,
since labels don't get keyboard focus, but inputs do.

So we must not hide the input but make it invisible instead. But we
still need to hide the input (alongside the label) after a file has been
attached.

We could add some extra JavaScript to hide the input when we hide the
label. Since the JavaScript is already quite complex and my first few
attempts at changing it failed, I've opted to assume that the input (and
its label) must be hidden whenever there's already a file name, and
implement that rule with CSS.

Note we're using the `:focus-within` pseudoclass to style a label when
focus is on the input. This rule (at the time of writing) is only
supported by 93.5% of the browsers. Keyboard users without a screen
reader and using the other 6.5% of the browsers will still be able to
focus on the field but might not notice the field has received focus.
Since the percentage of affected users will decrease over time and until
now 100% of keyboard users were completely unable to focus on these
fields, for now we think this is a good-enough solution.
2021-07-13 17:09:05 +02:00
Javi Martín
a7e2f1ae30 Move file name before the destroy attachment link
This way screen reader users will hear the name of the file before
hearing about the link to destroy it. We were already displaying it this
way visually by having the file name on the left and the destroy link on
the right.

Thanks to this change we can also simplify the code which dynamically
changed the layout.
2021-07-13 16:58:22 +02:00
Javi Martín
8116e75aee Simplify showing/hiding attached file name
Note we have to render the `<p>` tag in one line because at the time of
writing browsers don't consider elements with whitespace inside as empty
[1].

[1] https://developer.mozilla.org/en-US/docs/Web/CSS/:empty
2021-07-13 16:58:13 +02:00
Javi Martín
0dfabc8939 Use a Font Awesome icon in recommendations
We've deprecated the "icons" font since we started using Font Awesome
two years ago and using it caused some screen readers to announce an "l"
before the content of every list item.
2021-07-13 15:27:21 +02:00
Javi Martín
e7b37ae93b Increase font-size in recommendations
Now that we display them in one column, the lines were too long for a
small font size.
2021-07-13 15:27:21 +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
decabeza
578f3437da Update styles and layout for new proposals form 2021-07-13 15:27:20 +02:00
decabeza
909fd00714 Update styles and layout for new debates form 2021-07-13 15:27:14 +02:00
Javi Martín
8398d176b5 Allow more elements in investment form header
Since we're going to reuse this pattern in other forms, we shouldn't
rely on the header having just one element. There could be a subtitle.
So we're changing the CSS to be less dependent on a very specific HTML
structure.

Regarding the subtitle, the original idea was to have both an <h1> and
an <h2> element inside the header. However, the W3C advices against it
[1]:

> h1–h6 elements must not be used to markup subheadings, subtitles,
> alternative titles and taglines unless intended to be the heading for
> a new section or subsection.

So we ended up including the subtitle inside he <h1>. We could also add
it in a separate <p> tag. However, in this case I think it's better to
include it in the <h1> (and in the <title> tag) because it helps to
uniquely identify the current page from other pages.

Due to some rounding issues in Firefox, we're manually moving the polygon
6px so there isn't a blank space between it and the icon on the right.
And due to rounding issues in Chrome, we're adding one extra pixel to
the bottom of the polygon defining the clip-path.

[1] https://www.w3.org/TR/html52/common-idioms-without-dedicated-elements.html#common-idioms-without-dedicated-elements
2021-07-13 15:27:14 +02:00
Javi Martín
c4542457ac Group styles setting padding to the main content
So we don't add the same lines to pretty much every stylesheet we
create.

Eventually we'll remove this code and add a padding to every <main>
element, or (even better) to the <body> element itself.
2021-07-13 15:27:14 +02:00
Javi Martín
937450ff4e Simplify new investment header HTML
In commit 49b406199 we added an extra `<span>` element just so we could
add an icon to the right while maintaining both the title and subtitle
on the left.

We can do the same thing without the extra `<span>` element, absolutely
positioning the element and leaving enough padding.
2021-07-13 15:27:14 +02:00
Javi Martín
6d03b3226b Simplify new investment layout
We had an additional `<div>` just to add a background color, when we can
do it by applying the background color to the whole `<main>` element and
then the body background color to the optional fields.

However, I've decided not to do so. The main purpose of changing the
background color is to highlight the required fields. The benefits of
changing the background color of the header as well are unclear. When in
doubt, we're using the solution which requires less code.
2021-07-13 15:27:14 +02:00
Javi Martín
10f7183f8c Remove no longer necessary participation icons CSS
The `icon-budget` hasn't been used in this context for a long time;
maybe since commit d0b8fef6b.

The `document-form` class was removed in commit 6c1d828a6.

Finally, the `topic-new` and `topic-form` were removed in commit
c887cb736.
2021-07-13 15:27:14 +02:00
Javi Martín
461df6167a Fix investment form padding in Internet Explorer
It looks like Internet Explorer wasn't applying the padding to the
<main> element because it considered it an inline element.
2021-07-13 15:27:14 +02:00
Javi Martín
a14cf4f700 Simplify padding rules for SDG selector
Now the padding is only applied in two places (administration forms) so
we can apply it just there instead of applying it everywhere and then
removing it in most places. We're using the `column` class here because
it's what's used in the rest of the fields of these forms and because we
haven't defined (yet) general margin/padding rules for the
administration views.
2021-07-13 15:27:14 +02:00
Javi Martín
b162ad512a Remove row and column divs in debate/proposal form
We don't need any row classes anymore because the <body> already has a
maximum width. As for columns, we only have one column in this form, so
we don't need them either. Besides, the form's parent element already
has a padding.
2021-07-13 15:27:13 +02:00
Javi Martín
7bc55f78c0 Rename debate-form HTML classes
So they follow the same convention used in proposals.

Note the styles are for elements which appear in the "new" view but not
in the "edit" view, so we only have to include them in one place.
2021-07-13 15:25:31 +02:00
Javi Martín
7a1acf5706 Rename proposal-form HTML class to proposal-new
So it's consistent with the proposal-edit class we use in the edit
action.
2021-07-13 15:25:31 +02:00
decabeza
823cc37ce8 Update styles and layout for new budget investment form 2021-07-09 14:25:24 +02:00
Javi Martín
a87e8bd34d Move new investment button styles to CSS files 2021-07-09 14:25:18 +02:00
Javi Martín
355153813d Remove row and column divs in investment form
We don't need any row classes anymore because the <body> already has a
maximum width. As for columns, we only have one column in this form, so
we don't need them either. Besides, the form's parent element already
has a padding.

Although most CONSUL installation don't enable the translation
interface, we're adding some code to take this case into account.
2021-07-09 14:25:16 +02:00
Javi Martín
b8ee32589e Simplify padding rules in SDG pages
We can give the padding to the whole page instead of giving it to
individual elements.

On the minus side, now padding in the SDG pages is not the same as the
padding in the homepage, so we need to add an extra padding to the
participation feeds in only one of these cases.
2021-07-09 03:47:56 +02:00
Javi Martín
701378d02c Add padding to the whole header
Instead of adding the padding to each individual element inside the
container, why not adding padding to the container itself? The answer is
"because we want the background of the children elements to take the
width of the whole screen". But this generates either HTML cluttered
with elements to add padding or repetitive padding definitions in the
CSS.

So now we only define the padding once, and when an element requires a
full width background or border, we use the `full-width-background`
mixin.

In this case the code is a bit more complex because the header is also
used in the dashboard and admin layouts:

* In the public layout, the body has a margin, so we include the mixin
  to take margin into account
* In the dashboard layout, the header itself has a margin, so we include
  the same mixin
* In the admin layout, the headet doesn't have a margin but gets the
  whole width, so in this case we include the mixin which dosen't take
  the margin into account

In the future, the idea is to apply this principle to the <body>
element and remove the `@include grid-column-gutter` in the CSS as well
as the `small-12 column` classes in the HTML.

Note we use the `calc()` function inside the mixin instead of using it
in the `$full-width-margin` variable. That way we avoid nested `calc()`
operations, which don't work in Internet Explorer.

Also note we're using `flex-grow: 1` to make one element appear on the
left of the screen and the other one on the right. It would be easier to
use `justify-content: space-between` (which is actually the default for
the top-bar element). However, there's a bug in Internet Explorer and
old versions of Firefox; they include the absolutely-positioned
`::before` element we use to set the full width background when
calculating where to position the elements. The bug was fixed in Firefox
52 (released in 2017).

Finally, we're removing the padding from our logo. In order to allow
logos like the new one and at the same time provide backwards
compatibility to logos in existing CONSUL installations, we're relaxing
the validation rule for the logo width.
2021-07-09 03:45:55 +02:00
Javi Martín
a4eff3aa19 Simplify subnavigation layout
Using `flex` instead of a fixed width for the navigation, the elements
take all the available space when the search form isn't present. That
wasn't the case before and produced a strange effect on medium-sized
screens.

This way we also align the search to the right.
2021-07-08 18:57:21 +02:00
Javi Martín
09479b8a61 Avoid horizontal scrolling in participation feeds
The elements were given a minimum width of `rem-calc(240)` (that is,
15rem). Considering one element is double the width of the other one,
that means that in screens between 40rem and 45rem there would be a
horizontal scrollbar.

Adding a `flex-wrap: wrap` property fixes the problem. We're also using
`flex-basis` to guarantee a minimum width and make one element be double
the size of the other one when they're on the same line. No need to add
breakpoint rules due.

Finally, we're adding an artifitial gap between flex elements so we can
remove the `@include grid-col` rules.
2021-07-08 04:21:10 +02:00
Javi Martín
d31d73c4e5 Simplify HTML in top links
In the case of the public layout, the row element was originally there
so the content of the top links had a maximum width. Since now the body
has that maximum width, we no longer need the row element.

In the other layouts I guess the row elements were added because there
were float elements inside them. We can use a flexbox layout instead and
these elements are no longer necessary. This also makes the layout more
robust when there isn't enough space on one line for both the language
selector and the external links.

Note we're using `flex-grow: 1` to make one element appear on the left
of the screen and the other one on the right. It would be easier to use
`justify-content: space-between`. However, there's a bug in Internet
Explorer and old versions of Firefox; they include the
absolutely-positioned `::before` element we use to set the full width
background when calculating where to position the elements. The bug was
fixed in Firefox 52 (released in 2017).
2021-07-07 23:04:00 +02:00
Javi Martín
8a3b9f6abf Remove no longer necessary row classes
These element had no columns inside and the row classes had only been
added to give them a maximum width. That's no longer necessary since now
the body has that maximum width.
2021-07-07 23:03:58 +02:00
Javi Martín
4a6e4ee520 Add full width background to SDG headers
We couldn't do it before because we didn't have a way to add full width
backgrounds to elements which were inside a ".row"-like element.
2021-07-07 22:32:08 +02:00
Javi Martín
f00cb631bc Remove all grid-row Sass rules
We were using these rules in order to set the maximum width of an
element to `$global-width`. However, since we now do so in the <body>
element, there's no need to apply these rules to "rows".

Note we're adding `overflow: hidden` to the budget subheader. That's
because it only contains `float` element inside, and we're now missing
the `.row::before` and `.row::after` rules which make sure float
elements are rendered properly.
2021-07-07 22:32:08 +02:00
Javi Martín
9cc4d52723 Use a global maximum width for the <body> element
We weren't using a global maximum width for the <body> element because
we wanted the background of some elements to cover the whole screen. If
the body didn't cover the whole screen, then we would have to find a way
to extend the background beyond the limits of the body.

Elements can take the whole screen width using a width of 100 viewport
width (vw) units, which weren't as widely supported when CONSUL
development started as they are today.

However, there's a gotcha will vw units; they don't take into account
the vertical scrollbars browsers add when scroll is needed. That means
that an element with a width of 100vw would cause a *horizontal*
scrollbar when the vertical scrollbar appears on the screen. So
approaches like this one wouldn't work:

```
body {
  margin-left: auto;
  margin-right: auto;
  max-width: $global-width;
}

@mixin full-background-width {

  &::before {
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
  }
}
```

We could add `overflow-x: hidden` to the body to avoid the horizontal
scrollbar. However, on certain screens sizes that could cause some
content to disappear if there isn't enough horizontal space for all the
elements.

If we tried some other solution based on using `max-width` with `margin:
auto` on the <body> element, it would result in a body having a fixed
width and a variable margin (depending on whether there's a scrollbar).
So it wouldn't be possible to set a negative margin on child elements
based on the margin of the body, because that margin would be different
depending on the existence of a scrollbar.

So, instead, we're adding a fixed margin to the body, which depends on
the viewport width and the font size of the <html> element. With this
approach, when a vertical scrollbar appears, the margin of the <body> is
still the same; what changes is its width. That means we can set a
negative margin on child elements based on the margin of the <body>. No
horizontal scrollbar will appear.

Note we're slightly duplicating the code by using two variables
(`$body-margin` and `$full-width-margin`) to do the same thing. We could
simply use `$body-margin` and then use `calc(-1 * #{$body-margin})` in
our `full-width-background` mixin. We aren't doing so because some old
versions of the Android browser and Internet Explorer can't handle this
operation. Since our whole layout is based on these properties, in this
case supporting old browsers is quite important.

For similar reasons we're using a breakpoint instead of using the
`max()` function like: `Max(0px, calc(50vw - #{$global-width / 2}))`. At
the time of writing, `max()` is only supported in about 91% of the
browsers.

With this change, we no longer need to add `row` elements to make sure
we don't exceed the maximum width; the <body> element takes care of
that.

Also note banners sometimes have a full background and sometimes they
don't, depending on which page they appear. We're adding specific rules
for them.

Finally, the code for full width borders is a bit brittle; sometimes we
want the border to cover an element, and sometimes we don't. For
example, we had to slightly change the way the border of the "tabs" in
legislation processes is rendered. Without these changes, the borders
wouldn't overlap as we intended. We also had to add a `z-index` to
navigation links so their bottom outline is visible when they're
focused. The recommendations have a border with the same color as the
background so it's painted on top of the border of the `help-header`
section.
2021-07-07 22:32:06 +02:00
Javi Martín
4c47eab608 Move search summary styles to a stylesheet 2021-07-07 15:10:29 +02:00
Javi Martín
b5fd875133 Simplify border and background in admin header
Instead of defining them for all headers and then overwriting them, we
can add it just to the body of the public layout.
2021-07-07 15:10:27 +02:00
Javi Martín
7d50fed2a3 Change sections order in CONSUL Sass settings
This way we can set `$text` to `$black`, as we intended to.
2021-07-06 15:33:10 +02:00
Javi Martín
aa46444eda Make icon to select language more prominent
It was barely visible against a dark background.
2021-07-06 13:50:12 +02:00
Javi Martín
1f10afac64 Simplify language selection with a few languages
As mentioned in commit 5214d89c8, using the `change` event of a `select`
field to automatically change location is really annoying for keyboard
users, since the event will trigger when pressing the down key to
navigate through the options or when typing a key to start searching for
an option. This might cause a lot of frustration.

Most multilanguage CONSUL sites enable between 2 and 4 languages. In
these cases, it's easier to just display the list of languages to
simplify the selection.

This way in this situation we also make it clear which languages are
available. If we use a `<select>` tag, users will have to open it in
order to check whether the site is available in their preferred
language.

This is also useful when the current language uses characters users
don't recognize; users will recognize their own language in the list of
available languages, while it might be harder to recognize the language
selector allows them to switch to a different language.

In this case, we're also hiding the label because a list of links with
language names is usually self explanatory for sighted users. We're
still providing it for screen reader users so they immediately know the
list allows them to change the language and if they don't need to do so
they can quickly skip it.
2021-07-05 22:27:39 +02:00