Commit Graph

1644 Commits

Author SHA1 Message Date
Javi Martín
45c1f93562 Add a link to skip to the main content
While people using screen readers already have keyboard shortcuts to
jump to the <main> tag, there are people who navigate the page with the
keyboard using just the tab key, and for them, this link provides a way
to save time and start reading the main content instead of having to
manually go through all the navigation links every time a new page is
loaded.

Note that we had to add an additional `width: 0` rule because
Foundation's `element-invisible` would apply `1px` and the test checking
for `visible: :hidden` would faile.
2024-03-23 00:35:47 +01:00
Javi Martín
a101608ebe Fix invalid HTML in comment votes
We forgot to change the `span` tag when we replaced links with buttons
in commit ba0d21b46.
2024-03-05 00:41:53 +01:00
Pierre Mesure
e5a6a5bf1d Adding clustering 2024-01-29 17:56:54 +01:00
Senén Rodero Rodríguez
0186484fac Use leaflet npm version instead of the gem 2024-01-29 17:56:54 +01:00
Senén Rodero Rodríguez
6a64f38d17 Use admin table settings component to render featured settings
Now, with the same template we can render all kind of settings.
2024-01-25 18:29:38 +01:00
Javi Martín
ce4939703e Merge pull request #5278 from consuldemocracy/vote_contrast
Make like/unlike buttons more accessible
2023-10-24 17:24:22 +02:00
Javi Martín
bc1f303551 Merge pull request #5281 from consuldemocracy/pdf_links
Open PDF files in the same tab/window
2023-10-24 16:28:31 +02:00
Javi Martín
834da50901 Merge pull request #5279 from jensconsul/admin_panel_branch
Add information about the project to admin index
2023-10-24 15:23:33 +02:00
Javi Martín
7c6134fdee Unify the way we display document information
We were displaying documents in five places, and in five different ways.
Sometimes with the metadata in parenthesis after the title, sometimes
with the metadata below the title, sometimes without metadata, sometimes
with an icon in front of the document, and sometimes with a separate
link to download the file.

So we're now displaying the same thing everywhere. Not sure whether this
is the best solution, but at least it's consistent.

We aren't unifying the way we display a list of documents, though, since
different sections look pretty different and I'm not sure whether the
same style would look well everywhere.

Note that we're renaming the `document` HTML class in the documents
table to `document-row` so the styles for the `document` class don't
apply here.
2023-10-23 18:15:54 +02:00
Javi Martín
a2e4b056ee Move documents partials to components
This way it'll be easier to change them.

Note that there were two `.document-link` elements which aren't part of
a `.documents` element. We're renaming the HTML class of the link in
investments because it didn't contain links to download documents and
are slightly duplicating the CSS in the poll answer documents in order
to keep the `word-wrap` property.
2023-10-23 18:10:24 +02:00
Javi Martín
e0c5be10aa Extract mixins to style separators
This way they can be reused in other places.
2023-10-23 15:49:01 +02:00
Javi Martín
a8bd5eb192 Rename document/image fields HTML classes
Using the `document` or `documents` classes meant styles defined for the
public list of documents conflict with these ones.

So now we're using HTML classes that match the name of the Ruby
component classes, as we usually do.
2023-10-23 15:49:01 +02:00
Javi Martín
00f063b291 Remove unused documents-related CSS
We don't have any elements matching the `.documents .icon-document`
selector.
2023-10-23 15:49:01 +02:00
Javi Martín
38e81f2858 Style "like" buttons to hint they can be unpressed
We added the feature to undo a vote and made it obvious for people using
screen readers using the `aria-pressed` attribute. However, for sighted
people, the only way to know a button can be unpressed is to try to
press it again and see what happens.

The most obvious way to indicate it would be to add a text indicating
that you can undo your vote. However, that'd require changing the design
quite a bit.

So, after trying a few techniques, we're using a classic approach
browsers have used by default for years: using an inset border for
pressed buttons and an outset border for unpressed ones. It might now be
enough, though; we haven't done usability tests to confirm this point.

Since icons to like/unlike comments don't have a border, I'm not sure
what to do in this case; the icons are small and that makes it hard to
style them in a distinct way. So for now we're not changing these icons.
2023-10-18 18:08:59 +02:00
Javi Martín
3482e6e058 Change styles of pressed buttons on hover
Since we were styling pressed buttons the same way as buttons on hover,
a person hovering on the button and then clicking it wouldn't notice
that the buttons had been pressed unless they noticed that the number
and percentages of votes had changes. They wouldn't notice the changes
when unpressing the buttons either, since, after clicking the button,
the cursor would still be over it, and so the hover styles would apply.

Furthermore, it was hard for mouse users to realize that a button could
be unpressed, since the style of pressed buttons didn't change on hover.

So we're now changing the icons on hover without changing the
background. This way all four states (unpressed, unpressed on hover,
pressed, pressed on hover) are styled in a different way.
2023-10-18 18:08:59 +02:00
Javi Martín
11a33c12e3 Increase contrast in like/unlike buttons
The colors we were using (gray for unpressed buttons and green or red
for pressed buttons) didn't contrast well against a white background, so
we're now using darker colors.

However, with darker colors, using solid icons for the unpressed buttons
makes it harder to differentiate when a button is pressed and when it
isn't, particularly for color-blind people.

So we're now using regular icons for the unpressed buttons and solid
icons for the pressed ones.
2023-10-18 18:08:59 +02:00
Javi Martín
1387356c86 Refactor like/unlike buttons SCSS
We were using the same selectors three times. Since we're going to
change that part of the code, we're simplifying it so we don't have to
do the same changes three times.
2023-10-18 18:08:59 +02:00
Javi Martín
0f45dbb896 Simplify border-related rules for like/unlike icons
We were keeping the same style and width when they were pressed, so we
can simply overwrite the color.
2023-10-18 18:08:59 +02:00
Javi Martín
3b6fb85c51 Use node packages to install jQuery and jQuery UI
Other packages depend on jQuery, so that's why these are the first one
we move from the Gemfile to the package.json file.

This way we can also test whether dependabot correctly opens pull
requests to update Node packages.

I've tried several configuration options for the asset pipeline in order
to be able to include images referenced in jQuery UI CSS files. So far,
adding the `node_modules/jquery-ui/themes/base` folder to the assets
paths is the only way I've found to make it work. Hopefully we can find
a better solution in the future so we don't have to study the internals
of every Node package in order to integrate it with the assets pipeline.
2023-10-17 13:12:20 +02:00
jensconsul
b5c13d63d1 Add information about the project to admin index
This way it'll be easier for people to know how to contact the Consul
Democracy Foundation.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2023-10-16 15:23:19 +02:00
Javi Martín
4435673ace Move admin index to a component
This way we make it easier to modify.

Note that, since the title of the page is "Administration" and it's in
the "Admin" section, we're adding an option to the `header` method in
order to avoid having a confusing title like "Administration - Admin".

Also note that, by removing the `title` HTML class, we avoid inheriting
styles from the `dashboard.scss` stylesheet, and now the heading is
displayed in the position it was meant to.

Finally, the concept of using a `main-class` for the current page comes
from a branch (currently in development) which will replace the <div>
tag with the `admin-content` class with a `main` tag.
2023-10-16 15:06:15 +02:00
Javi Martín
ae4b07de41 Make alt text readable when the logo doesn't load
We were displaying the alt text using the same color as the background
color, which made it impossible to read it when the logo didn't load
(for whatever reason).

Using the same color as the text, like done in the admin section, solves
the issue.
2023-10-10 15:03:35 +02:00
Javi Martín
959176b66d Use a darker "delete" color
The color we were using didn't have enough contrast against a white
background, which made it harder to read texts like "Remove map marker"
or "Erase my account".

Since the new color is almost identical to the color we were using on
hover and for the border, we're changing the color on hover as well,
while IMHO it's no longer necessary to use a different color for the
border.
2023-10-10 15:03:35 +02:00
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
d3eeffded1 Fix focus outline on links containing images
In some cases, like SDG icons and the proposals map, the image was
bigger than the link containing it, resulting in a funny-looking outline
on focus.

For reasons I don't understand, using `&:active,&:focus:active` didn't
compile to the CSS I was expecting, so I'm repeating the same code for
these two separate cases.
2023-10-10 15:03:21 +02:00
Javi Martín
b15512f025 Fix focus outline on budget executions index
The outline was invisible when we had the link containing block
elements, and I didn't manage to fix it, so the easiest solution is to
use an inline link and style the card with CSS.
2023-10-10 15:03:21 +02:00
Javi Martín
f285dfcbac Simplify HTML in proposal/debates recommendations
This way it's going to be easier to style the link on focus, since
styles like `box-shadow` weren't working properly when we had an inline
link with block elements inside, and adding the `display: inline-block`
element to the link didn't play well with the layout we were using for
the recommendations.

We're also fixing the focus outline on recommendations, which didn't
look properly because of the border added with:

```
.recommended-index {
  // (...)
  @include full-width-border(top, 1px solid #fafafa);
}
```

The border was on top of the outline, breaking it. Increasing the
`z-index` of the element containing the outline solves the issue.

In a similar way, we're making sure the button to hide recommendations
stays visible so it's easier to click it.
2023-10-10 15:03:21 +02:00
Javi Martín
d874697310 Remove redundant CSS properties set to none
These are default values that aren't needed.
2023-10-10 15:03:21 +02:00
Sebastia
db759bdd08 Merge pull request #5118 from consuldemocracy/undo-votes
Allow undoing "like/unlike" votes
2023-10-10 06:44:43 +02:00
taitus
5009bf6c37 Add aria-pressed to in comments votes component
In order to the users using screen readers know whether the button is pressed
or not.
2023-10-06 18:13:45 +02:00
taitus
10cfa0e59f Refactor scss for in favor against component
In order to reduce the code used to add styles to the buttons,
we removed the classes that had been added and handled it with
the new aria-pressed attribute
2023-10-06 18:13:45 +02:00
taitus
75c9b66375 Refactor footer legal links for cleaner code
Removed inline '&nbsp;|' used as a separator between footer legal links.
2023-09-14 09:51:51 +02:00
Javi Martín
21a268ab96 Remove alert for Internet Explorer 8 and below
Internet Explorer 8 was released in 2009 and people using it already
know that most web pages look broken on it, so we don't need to warn
them.

Removing it makes our application layout file much easier to read and
modify.
2023-09-07 19:44:54 +02:00
Javi Martín
3d9a23bd1b Use the new name in code comments 2023-07-12 16:05:33 +02:00
Javi Martín
2766d8f152 Merge pull request #5144 from consul/fix_invert_selection
Fix text selection in budget header
2023-07-03 17:29:08 +02:00
Karim Semmoud
3faaa8521d Render markdown tables in legislation draft
* Add Tables option to Redcarpet in Legislation draft

* Allow table tags in Admin Legislation Sanitizer

* Add Test to render markdown tables in Legislation drafts

* Add Test for Admin Legislation Sanitizer

We include test for image, table and h1 to h6 tags and additional tests to strengthen the allowed and disallowed parameters

* Add Table from markdown test in System and Factories

* Add test to render  tables for admin user

* Remove comment line about Redcarpet options

* Edit custom css for legislation draft table to make it responsive
2023-06-29 20:48:01 +02:00
Javi Martín
68927409b6 Fix text selection in budget heading
The `inverted-selection` rules defined in the `%brand-background`
selector weren't being applied because we were using this selector in
`::before` and `::after` pseudoelements. Not sure about the reason, but
it looks like the saturation of `::after::selection` pseudoelements
resulted in invalid selectors and so the inverted selection rules were
ignored for every selection using `%brand-background`, like
`%budget-header`.

Using `@include brand-background` instead of `@extend %brand-background`
in pseudoelements solves the issue. The inverted selection might not
work in these pseudoelements, but we don't need it there since these
pseudoelements don't have content.
2023-06-29 15:54:29 +02:00
Javi Martín
8b14522bf5 Use a button instead of a link to remove a marker
Using a button for interactive elements is better, as explained in
commit 5311daadf.

Since buttons with "type=button" do nothing by default, we no longer
need to call `preventDefault()` when clicking it.
2023-05-04 15:32:33 +02:00
Javi Martín
59ed975f81 Set remove marker link margin-bottom in CSS
We were setting the margin-top property in CSS but the margin-bottom
property by adding a div with a `.margin-bottom` HTML class.
2023-05-04 15:32:33 +02:00
Javi Martín
a145fdb8a8 Make map location HTML class names consistent
We were using `map_location` in one place and
`location-map-remove-marker` in another one. We usually use dashes in
HTML class names, we don't say "location map" anywhere else.
2023-05-04 15:32:33 +02:00
Javi Martín
9cc3c553ff Extract component to render a map
This way it'll be easier to refactor it.
2023-05-04 15:27:15 +02:00
Javi Martín
d0be5c4850 Extract component to render my ballot
This is the only part of the sidebar that needs to be re-rendered after
an AJAX request adding or removing investments to a ballot, so having a
separate view just for it will make it easier to simplify the code.
2023-04-21 17:39:55 +02:00
taitus
d96a91710f Fix broken h3 tag
Since we're now allowing <h2> and <h3> tags in the description, we
remove the broken <h3> tag from quiz-question class. Since its content
is also in the <title> element, and in order to be consistent with other
show actions in the public area, we change this tag to <h1>.

We add <h2> tag in the "Share" heading and we replace the broken <h4>
tag above adding new styles.
2023-02-22 19:19:27 +01:00
Javi Martín
f8df90010e Unify spacing styles in public and admin top bars
The top bar padding was different on small screens when we were in the
admin section, so we're now applying the same padding everywhere.

Note we're still applying extra padding on medium/large screens because
in the public section we display our logo image, which has some blank
space. In the admin section we're emulating this blank space with
padding; we might change it in the future if we change our logo.

Also note we're using `0.8rem` instead of `$line-height / 2`. The reason
is tricky: there's a spec testing the reorder feature with drag and drop
in the poll questions answers administration, and that test fails when
the drop space is right at the bottom of the screen, which is what
happens when we use the `$line-height / 2` padding. A proper solution
would be to remove the inaccessible drag and drop feature and use a
different method to reorder the answers.
2023-02-16 17:51:09 +01:00
Javi Martín
27d9859674 Remove unnecessary styles in top bar
Not sure why these properties were added, but they no longer seem to be
necessary.
2023-02-16 17:24:34 +01:00
Javi Martín
3b125d9cfc Simplify styles for the remote translations button
We can use the `link` mixin. Note this mixin uses anchor-color instead
of brand-color; by default, they're both the same, so we probably meant
anchor-color here.
2023-02-16 17:24:34 +01:00
Javi Martín
fb2b88b10a Simplify styles for the remote translations message
Instead of adding all the styles of a callout and then overwriting half
of them, we can simply add the half we need.
2023-02-16 17:24:34 +01:00
Javi Martín
9bca73bc8b Fix background width in remote translations message
The `overflow: hidden` applied to the `.callout` selector made the full
width background invisible, meaning this section hasn't looked properly
on very large screens since  commit 701378d02.
2023-02-16 17:24:34 +01:00
Javi Martín
1778a7563b Use CSS to define alignment in translations message
That way it's possible to override the style without changing the HTML,
which is the hardest code to customize and maintain.
2023-02-16 17:24:34 +01:00
Javi Martín
efc69e8663 Extract component for remote translations button
So we're consistent with the rest of the code in the header, which
renders components and not partials.
2023-02-16 17:24:34 +01:00