Commit Graph

51 Commits

Author SHA1 Message Date
Javi Martín
64edfe5c98 Increase links and buttons contrast on focus
The Web Content Accessibility Guidelines version 2.1 added a success
criterion called Non-text Contrast [1], which mentions that the focus
indicator must contrast with the background, and version 2.2 introduced
a specific one regarding focus appearance [2]. According to that
criterion, the focus indicator:

* is at least as large as the area of a 2 CSS pixel thick perimeter of
  the unfocused component or sub-component
* has a contrast ratio of at least 3:1 between the same pixels in the
  focused and unfocused states.

Our current solution for highlighting elements on focus has a couple of
issues:

* It doesn't offer enough contrast against the default white background
  (1.6:1)
* It offers even less contrast against other backgrounds, like the
  homepage banner or the featured proposals/debates

Making the color of the outline darker would increase the contrast
against these backgrounds, but it would reduce the contrast against
other backgrounds like our default brand color.

For this reason, most modern browsers use a special double outline with
two different colors [3], and we're choosing to combine an outline and a
box shadow to emulate it, using the brand color as the second color.

However, this double-colored outline doesn't work so well when focusing
on dark buttons surrounded by a light background, so instead we're using
a triple outline, which works well on any color combination [4]. Since I
feel that making the third outline 2px wide makes the overall outline
too wide, I'm making the inner outline just 1px wide since that's enough
to prevent edge cases.

Note that Foundation adds a transition for the `box-shadow` property on
`select` controls, which gets in the way of the focus we use on the
language selector. So we're removing the transition.

Also note that the box-shadow style didn't work properly with the
box-shadow we added on the `:hover` status on cards, so we're changing
the code in order to cover this case.

Finally, note that the box-shadow isn't displayed properly on multiline
links (in Chrome, not even with `box-decoration-break: clone`), like the
ones in debates/proposals/polls/investments/processes titles, so we're
changing the style of these links to `inline-block`.

[1] https://www.w3.org/TR/WCAG21/#non-text-contrast
[2] https://www.w3.org/TR/WCAG22/#focus-appearance
[3] https://www.sarasoueidan.com/blog/focus-indicators/#examining-(current)-browser-focus-indicators-against-wcag-requirements
[4] https://www.erikkroes.nl/blog/the-universal-focus-state/
2023-10-10 15:03:21 +02:00
Javi Martín
5845dd46d9 Extract variable for SDG text color
We were using `#fff` in some places and `$white` in others. We're
choosing `#fff` because it has a better contrast against the lighter SDG
colors and because it's the one officially used by the United Nations.
2022-10-27 15:35:27 +02:00
Javi Martín
a75e470c7d Fix SDG section header and banner background
They weren't taking the full width because in the SDG index the `main`
element has a padding.
2021-10-28 21:23:07 +02:00
Javi Martín
e20e468c0f Use sans-serif fonts as fallbacks for SDG titles
This way titles look a little less broken during the time the font is
downloaded.
2021-09-30 15:06:50 +02:00
Javi Martín
35a45837ff Add default focus outline to buttons
We were using a focus outline on links, but weren't doing the same for
buttons. Since sometimes browsers use a default outline which is barely
visible, this was very disorienting when browsing using the keyboard; we
were navigating through links that clearly indicated where the keyboard
focus was, and when reaching a button suddenly we had this almost
imperceptible feedback. Even if I'm used to it, my first reaction is
always "where did the focus go?" until I realize it's now on a button.

This is even more confusing because we've got buttons looking like links
and links looking like buttons.

Note that in the rules for the `:focus` styles we're including buttons
and the `[type="button"]` attribute. This seems redundant since those
styles are already covered by the `button` selector. However, Foundation
adds styles to buttons with the `[type]` attribute. Since the attribute
selector has precedence over the tag selector, we need to use the
attribute selector as well in order to override Foundation's styles.
2021-09-15 13:38:36 +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
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
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
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
6ea9383743 Allow toggling elements with the keyboard
Using `<a>` tags with no `href` means these elements cannot be activated
by keyboard users, so we're replacing them with buttons.

In the future we probably want to add more consistency so all toggle
buttons use the same code. We might also add styles depending on the
`aria-expanded` property.
2021-03-31 13:38:38 +02:00
Javi Martín
d1675750b8 Fix a chrome bug in versions lower than 86
https://bugs.chromium.org/p/chromium/issues/detail?id=375693
2021-03-08 10:51:22 +01:00
taitus
d26607183e Add sdg help page
In this page we will render a list of clickable Goals icons that will show their
targets and related local targets

Co-authored-by: Senen <senenrodero@gmail.com>
2021-03-02 14:45:18 +01:00
Javi Martín
d741ccdb36 Extract related list selector styles to mixin 2021-03-02 14:45:17 +01:00
taitus
522684cd2f Adapt targets component to render on sdg help page
This component was rendered on different pages so there were no conflicts
with static id's.
Now in the SDG help page we are going to render them all at once, so we
convert the static identifiers to dynamic.
2021-02-26 16:36:40 +01:00
taitus
4a880fc1c5 Render header on sdg index page
We no longer show the static header when we have created a
custom header.
2021-02-26 16:20:57 +01:00
Javi Martín
ab2b3a2671 Improve help messages in SDG selector
Hopefully now it's a bit more obvious that SDGs can be selected by
clicking on them and that the field to select goals and the field to
select targets/goals are related (since they're now part of the same
fieldset).
2021-02-15 15:48:25 +01:00
Javi Martín
6ecb6757a6 Use real check boxes to select goals
We were using list items with the checkbox role. This is probably
confusing since list items have a listitem role, and so we were
basically using a list with no listitem.

We could add a `<span role="checkbox">` tag inside the list item, but
using real checkboxes is probably easier. We're also adding a test to
verify the checkboxes native behavior is compatible with our code.

Note we're using the "enter" key to toggle the "checked" status of the
SDG. This is probably not intuitive for screen reader users who might
try to submit the form using the "enter" key after selecting a goal.

However, the alternative would be even less intuitive for sighted
keyboard users, since for them these icons look like links or buttons
and they would accidentally submit the form when trying to select a
goal.

Since we haven't come up with a better interface yet, for now we're
following the principle of least damage; we consider submitting the form
against a user's will is less annoying than forcing users to move to a
different field before being able to submit the form.

Also note we can't write `check` in the tests because Capybara will try
to click the checkbox, which is hidden by the image in the label.
2021-02-15 15:48:25 +01:00
Javi Martín
999d1a2cfd Rename goals FilterLinks component to TagCloud
This is more consistent with the "tag_cloud" partial name.
2021-02-02 22:22:39 +01:00
Senén Rodero Rodríguez
bb1315def1 Prepare SDG tag list component to render list with or without links
Now the tag list can render tags with or without links, so we need
to adapt the styles slightly.

We want to use the same text color for tags without links.

The hover style is only needed when using tags with links.
2021-01-31 13:33:26 +01:00
taitus
adc66cb28e Improve icons size on goals index
We're also using a percentage to separate the icons, since using the
viewport width causes strange result on screens where the element
max-width (which is based in rem) is much smaller than the size of the
window.
2021-01-29 18:14:50 +01:00
taitus
d61d648dda Render all icons on one line in forms
Show all icons of the RelatedListSelector component on one line in the
forms.
2021-01-29 18:14:50 +01:00
Javi Martín
0b84c0da01 Improve margin rules in SDG icons
We were using the classic approach of adding a margin-right property to
all elements except the last one. This works great when all icons are
displayed in one row.

However, when they're displayed in several rows, there could be a
scenario where the last row has more elements:

element1 <margin> element2 <margin>
element3 <margin> element4 <margin> element5

In the example above, `element3` does not fit in the first row because
it's got a margin to its right. However, `element5` fits in the second
row because the last element has now right margin.

One option to fix this issue it using CSS `gap` property. However, at
the time of writing, it's only supported by 70% of the browsers.

So we're emulating the gap by giving a negative margin to the list
equivalent to the margin of the first element.

This idea is based on:

https://coryrylan.com/blog/css-gap-space-with-flexbox

The exception is the index page. Here the list of icons is centered with
`margin: auto`, and so we cannot use negative margins. We're using the
classic approach instead, which is fine because we define there are 6
icons per row.
2021-01-29 18:14:50 +01:00
taitus
2215209ae4 Standardize icon size
These icons share page with the social media icons (eg: ssb-twitter)
in both the index and the show pages
We believe we gain consistency if all the icons that appear are the
same size.

Pull request 4101 will use this width in social media icons as well.
2021-01-29 18:14:50 +01:00
taitus
f45bbb316c Add Targets component to Show component 2021-01-29 14:15:58 +01:00
taitus
7a02ce9c08 Add sdg section header on SDG IndexComponent
Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-01-28 20:02:46 +01:00
Javi Martín
3018de2847 Merge pull request #4324 from consul/sdg_target_filter
Add SDG target tags and filter
2021-01-27 16:48:12 +01:00
Javi Martín
1fefc910d6 Add list of targets to SDG tag list
Co-authored-by: Senén Rodero Rodríguez <senenrodero@gmail.com>
2021-01-27 16:21:40 +01:00
Javi Martín
7b3fcf6cb5 Split goal tag list component
This way we'll be able to add targets as well. Besides, having two
classes in the CSS selector will allows to overwrite styles such as
`.debate-show ul li`.

On the other hand, we need to add a stylesheet for the filters as well.
2021-01-27 16:21:40 +01:00
Javi Martín
2614de79c1 Extract placeholder selector to style a tag
So we can use it in more places.
2021-01-27 16:21:40 +01:00
Javi Martín
d1ab8ac29b Split li tags in link list helper
This way we generate the same HTML as we generate everywhere where we
manually generate lists of links. Having a blank space betwwen tags
results in a space being introduced when the elements are displayed
inline (or with `inline-block`).

So in places where we don't want that space between the elements we have
to use a flex layout.
2021-01-27 15:56:58 +01:00
Javi Martín
744b9d1ffd Extract placeholder selector for SDG list styles 2021-01-27 15:56:58 +01:00
taitus
6c7a8d31b1 Add read more and real less on long description
In the spec we added in system/sdg/goals_spec.rb we couldn't use
either click_link or find_link, because the link to show/hide the
long description doesn't have the href attribute.
2021-01-27 15:56:08 +01:00
taitus
c052e907eb Prepare related list component to add on front pages
To make it easier to add the component to the front pages forms and
avoid introducing redundant classes we add the necessary padding
(@include grid-column-gutter) to make it behave  like the  rest of the form
fields.

Note that for the sdg management section we set this value to 0.
2021-01-22 12:42:51 +01:00
taitus
d56396acb7 Improve usability and design
Render the tags under the input. This way the input is not moved down
when a tag is added.
Render icons under the label. As you can add tags by clicking on the icons,
in this way the input is more related to the icons.
2021-01-20 19:18:58 +01:00
taitus
602b22edfd Allow tags to be removed with the keyboard
We improved accessibility by overwriting the setIcon method in the library.
Now we render a button and add the aria-label attribute.
2021-01-20 19:18:57 +01:00
taitus
fce844261a Add help section
In the help section we show the titles of the Goals and Targets that we have added
2021-01-20 19:18:55 +01:00
taitus
23f72d939a Add list of goals icons to component
- When we click on an icon we add a new tag with the Goal related to the input or
we remove the tag when that label already exists.

- Manage goals icons status when add or remove related targets:
Whenever there is a tag related to Goal, either the Goal itself or a Target, the icon
will be "checked".
When there is no related Goal or Target it will no longer be marked as checked.
2021-01-20 19:18:03 +01:00
taitus
e4e4e28ce6 Add custom background and color text for tags 2021-01-20 19:18:02 +01:00
Javi Martín
c3e60ff514 Add cards to SDG homepage 2021-01-14 17:47:21 +01:00
Javi Martín
4072735187 Add icons to SDG index 2021-01-14 17:45:14 +01:00
Javi Martín
ceed3c18d3 Display SDG icons alongside tags
We're using the translation fallbacks for the icons, just like we do for
texts.

Note we use the `render?` method provided by view_component to make sure
the component will not be rendered when certain features are disabled.

Also note the `find_asset` method works differently in development and
production, and so we use different approaches here.
2021-01-09 14:53:54 +01:00
Javi Martín
9db0cfd009 Reduce title size on small screens
It didn't fit the screen properly on goals having long words.
2020-12-27 21:43:17 +01:00
Javi Martín
2509512d73 Split title in two lines
The same it's done in the UN official SDG pages.

We could try to split the string on a space which is more or less in the
middle. However, this wouldn't work on languages which don't have spaces
between works, like Chinese.

So in the end I've added a new translation key, where the title is
supposed to be split in several lines the same way it's done by the UN.
2020-12-27 21:43:17 +01:00
Javi Martín
bec166548c Add code to goal title
The same way it's done in UN official SDG pages.
2020-12-27 21:43:17 +01:00
Javi Martín
46c6aa7f5f Use the Oswald Medium font for goal titles
The same way it's done in the official SDG icons. We're also using
uppercase with slightly smaller letter spacing for the same reason.

Even though we didn't do so in the past, we're moving the font to its
own folder inside the vendor folder and including the license file as
well in order to make it clear that these files do not follow the same
license CONSUL uses.
2020-12-27 21:43:17 +01:00
Javi Martín
1f82c62711 Add SDG icon-only images to SDG header 2020-12-27 21:43:17 +01:00
Javi Martín
cc9ab70fbb Add processes to goal view
Note the link to see all processes does not filter by goal because the
legislation section does not have any search filters.
2020-12-27 21:42:42 +01:00
Javi Martín
2fcfa7ebd7 Render participation feeds per SDG 2020-12-27 21:42:42 +01:00
Javi Martín
3e7038d06c Use different backgound colors for different goals
The same way it's done by the United Nations.
2020-12-27 16:44:48 +01:00