Commit Graph

364 Commits

Author SHA1 Message Date
dependabot[bot]
64bcedc8b2 Bump sassc-embedded from 1.70.1 to 1.80.1
Note: Since we update to 1.80.1 deprecation warnings are appear when execute the assets:precompile command.
In order to silence this deprecation, we add silence_deprecation option in sass.rb initializer.

The code has also been updated to remove the deprecation warnings that appeared related to the function
darken(), lighten() and "Using / for division" instead of the function calc().

Bumps [sassc-embedded](https://github.com/sass-contrib/sassc-embedded-shim-ruby) from 1.70.1 to 1.80.1.
- [Commits](https://github.com/sass-contrib/sassc-embedded-shim-ruby/compare/v1.70.1...v1.80.1)

---
updated-dependencies:
- dependency-name: sassc-embedded
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-06 13:01:58 +01:00
Javi Martín
2ccf725815 Add properties-alphabetical-order Stylelint rule
We hadn't added this rule before because there was no such rule in
scss-lint. Instead, we were following it without a linter, and so we
unintentionally broke it sometimes.

But now we're using Stylelint, so we can add the rule and let the linter
check we're still following it.
2024-07-22 17:34:08 +02:00
Javi Martín
5fa6db2226 Rename HTML attributes referencing poll options
Since now poll question answers have been renamed to poll question
options, using HTML IDs, classes and data attributes named `answer` was
confusing.
2024-06-13 19:13:05 +02:00
Javi Martín
438fe7bd25 Fix inner borders in polls administration tables
The rows in these tables were using the styles from the `.poll`
selector, and the `position: relative` property defined there caused the
inner borders to disappear in some browsers (like Firefox).

So we're adding the `public` class to the selector; this way, it doesn't
affect elements in the admin section.

Even though it's only necessary to add the `.public` prefix to the
`.poll` selector in one place in order to fix this issue, we're doing it
everywhere for consistency.
2024-06-07 16:19:04 +02:00
Javi Martín
765ab758dc Extract component to render a poll in the poll index
This is consistent with the way we've got partials to render debates,
proposals and legislation processes on their index pages.

Note that, while adding the tests for the status icon, we're keeping one
system test because it also tests the process of voting. We're adding a
new, similar component test, where the voter is created in the database,
so all possible statuses are tested in the component.
2024-06-07 15:52:02 +02:00
Javi Martín
2b03e3ebc4 Remove unused CSS to display poll status icons
This code isn't used since commit 5fdbc7b8a.
2024-06-07 15:52:02 +02:00
Javi Martín
1a797f2808 Use multiplications instead of divisions in Sass variables
In the previous commit, we used the `calc` function when assiging CSS
properties in order to avoid warnings like:

```
Deprecation Warning: Using / for division outside of calc() is
deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($global-width, 2) or calc($global-width / 2)
```

In cases like dividing by two, there's a third alternative: multiplying
by 0.5. We're applying this principle to all variable assignments where
we were using divisions, since using the `calc` function here would
sometimes result in errors due to these variables being used in
arithmetical operations. We aren't using `math.div` because it makes the
code harder to read.
2024-04-04 15:16:24 +02:00
Javi Martín
6df813fdb6 Use calc() where divisions are involved
The division operator `/` from Sass is deprecated because `/` is used in
CSS for uses other than dividing numbers. That's why we were getting
many warnings like:

```
Deprecation Warning: Using / for division outside of calc() is
deprecated and will be removed in Dart Sass 2.0.0.

Recommendation: math.div($line-height, 2) or calc($line-height / 2)

More info and automated migrator: https://sass-lang.com/d/slash-div

margin-top: $line-height / 2;
```

Since using math.div makes the code harder to read and `calc` is
universally supported by all browsers (although the implementation in
Internet Explorer doesn't work in certain cases), we're using `calc`
when assigning the value to a CSS property.

However, we're also using divisions when assigning Sass variables, and
in those cases using `calc` is trickier because sometimes these
variables are used in other operations. We'll handle these cases in the
next commit.
2024-04-04 15:16:24 +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
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
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
decabeza
01bf16fa46 Fix image size on proposals list 2023-02-03 17:42:00 +01:00
Javi Martín
36a1b2cdc2 Allow different secondary colors per tenant 2022-11-20 00:29:12 +01:00
Javi Martín
fcc63cb436 Allow different brand colors per tenant
Until now, overwriting the styles for a certain tenant was a very
tedious task. For example, if we wanted to use a different brand color
for a tenant, we had to manually overwrite the styles for every element
using that color.

It isn't possible to use different SCSS variables per tenant unless we
generate a different stylesheet per tenant. However, doing so would make
the CSS compilation take way too long on installations with more than a
couple of tenants, and it wouldn't allow to get the colors dynamically
from the database, which we intend to support in the future.

So we're using CSS variables instead. These variables are supported by
97% of the browsers (as of October 2022), and for the other 3% of the
browsers we're using the default colors (SCSS variables) instead.

CSS variables have some limitations: for instance, it isn't possible to
use functions like `lighten`, `darken` or `scale-color` with CSS
variables, so the application might behave in a strange way when we use
these functions.

It also isn't possible to automatically get whether black or white text
makes a better contrast with a certain background color. To overcome
this limitation, we're providing variables ending with `-contrast`. For
instance, since the default `$brand` color is a dark one, when assigning
a light color to `--brand`, we probably want to assign
`--brand-contrast: #{$black}` as well, so the text is still readable.
2022-11-20 00:29:12 +01:00
Javi Martín
a2c032573f Rename brand-text mixin to brand-color
This is consistent with the `body-colors` mixin and with other mixins
we're about to add, like `anchor-color`.
2022-11-20 00:29:12 +01:00
Javi Martín
9ac8ddb6bf Unify dark and brand-secondary SCSS variables
We were using each one half the time, while they both had the same value
by default. It was impossible to know when me meant "use a dark color
here" or "use the secondary brand color" here.

So now we're only using one variable, so it's easy it'll be easy to add
CSS custom properties to overwrite this variable. We're choosing
`brand-secondary` because its name makes it less problematic to use a
light color.
2022-10-28 14:07:33 +02:00
Javi Martín
b96d745e0e Use $body-font-color instead of $text
This is consistent with the usage of `$body-background`. This way
Foundation elements using `$body-font-color`, like the `<body>` tag,
will be changed when changing this variable, which wouldn't happen when
using `$text`.
2022-10-28 14:07:33 +02:00
Javi Martín
6cb4f4acde Extract mixin to get a background with text contrast
This way we simplify the code a bit.

Note we're only using this function when variables for background colors
are already defined, since that means customizing the variable using the
background color will automatically change the color of the text.
Customization isn't easier when using raw colors.
2022-10-28 13:58:04 +02:00
Javi Martín
1b1b5b5755 Use color-pick-contrast to get text colors
We were defining (for instance) white text against the `$brand`
background. That meant that, if somebody customized the `$brand` color
so it used a light color, they had to customize the text color as well
in order to guarantee proper contrast between text and background
colors.

So we're using `color-pick-contrast` instead, which means we don't have
to manually calculate whether white or black will be the color which
makes the text more readable.
2022-10-28 13:58:04 +02:00
Javi Martín
3aa73110c5 Use foundation variables to set caption color
This way we can simplify the code a bit since Foundation automatically
chooses the text color of the caption so there's enough contrast with
the background color defined in `$orbit-caption-background`.
2022-10-27 15:35:27 +02:00
Javi Martín
33eea0b21a Extract mixin to use body background and text color
This way we reduce the usages of the `$body-background` and `$text`
variables, making it easier to replace them with CSS variables in the
future.
2022-10-27 15:14:48 +02:00
Javi Martín
335f0d8bde Inherit text color instead of defining it again
This way it's easier to customize colors, particularly when links use
the same colors as the text surrounding them.

Note that the `markdown-editor-header` isn't displayed since commit
76b7f66fb, which was probably an unintended side-effect. So we're
modifying the colors here as well instead of removing the element; we
might display it again in the future.

Also note the change in `.supported` only affects the proposals section;
budget investments use a different color for the `.supported` sucess
message. Not sure whether this was originally intended or done by
accident.
2022-10-27 15:07:53 +02:00
Javi Martín
09471c1432 Remove redundant background definitions
These elements didn't need a background because their parent elements
already defined the same background.
2022-10-27 01:10:46 +02:00
Javi Martín
590f557aaa Remove redundant link colors definitions
These elements already used these colors because their parent elements
already used these colors for links.
2022-10-27 01:10:36 +02:00
Javi Martín
e050e5cc70 Remove redundant text color definitions
These elements were already using these colors because they inherited
them from their parent elements or Foundation already defined them.

Note that the only contents of `.comment-info` are: `.user-name` and
`.is-author`, `.is-association`, `.level-1`, ... and the link to the
comment. All of these elements were overwriting the `$text-medium`
color, so there's no need to set it. That means we can use the default
text color for `.user-name` without specifically setting it.
2022-10-27 01:10:31 +02:00
Javi Martín
a16247b258 Respect hover color in leaflet and author links
We were overwriting the color of the links, but not the color of the
links on hover.

Note we're removing the `!important` rule from the author link; after
testing it, it looks like it wasn't necessary.
2022-10-24 20:38:16 +02:00
Senén Rodero
760abffde9 Merge pull request #4993 from consul/refactor_public_polls
Refactor and simplify public polls views
2022-10-18 13:24:44 +02:00
Javi Martín
05cb72a398 Remove duplicate mixin in budget-investment-show
This mixin was being called twice for the `.budget-investment-show`
selector; once in the CSS including this code for all the "Show
participation" pages, and once in the CSS for budget investments.
2022-10-13 16:12:34 +02:00
Javi Martín
ef87abd8b7 Remove duplicate selector in partipation CSS
Thi line `.budget-investment-show,` was included twice, probably due to
issues while solving conflicts in git.
2022-10-13 16:07:01 +02:00
Senén Rodero Rodríguez
527d5691f7 Make poll feature work in browsers with javascript disabled
By using the Rails `button_to` helper (which generates a form), and adapting the
response to `html` and `js` formats, the feature works with or without javascript
enabled.
2022-09-22 17:39:57 +02:00
decabeza
52e65ba031 Add comments count on budget investments 2022-08-02 13:40:48 +02:00
Javi Martín
bfe6c1862d Fix link and text selection in budget header
While reviewing commit 7702b551e, I forgot to test whether selecting
text in the budget header or clicking its link worked properly.

The negative index (-5) meant it was impossible to select its text or
click on its link.

The good news is the pseudoelement with a negative index (-1) is
considered a child of the .budget-header element, so having a negative
index will cause the pseudoelement to be render behind the content of
the .budget-header element but in front of the background of the
.budget-header element.

This is exactly what we want.

Originally, we didn't have a z-index in the .budget-header element,
meaning the pseudoelement was rendered behind the background of the
.budget-header element, meaning both backgrounds were visible. This was
OK when the background was a plain color, but it wasn't when the
background was an image.

To stress the fact that the budget header is only affected when we use
an image, I'm also moving the code inside the `.with-background-image`
selector, although it would be interesting to check whether it's a good
idea to add `z-index: 0` to the `full-width-background` mixin.
2022-05-03 21:00:08 +02:00
Iraline
7702b551ec Fixing background image from Participatory Budgets page 2022-04-27 09:13:44 -03:00
Javi Martín
5c0aa42351 Remove duplication in search results summary
We were using very similar code for proposals, debates and investments,
so we might as well share the code between them.

Note we're using the `proposals.index.search_results` key even for
debates and investments. This will still work because the translations
shared the same text, but IMHO we should rename the key to something
like `shared.search_results_summary`. We aren't doing so because we'd
lose all the existing translations.
2022-04-12 14:23:14 +02:00
Javi Martín
abec716308 Show "not allowed" message on click
Defining a behavior on hover means making it different for people using
a keyboard or a touchscreen (most of the population, nowadays).

In this case, we had an accessibility issue where the message wouldn't
disappear once it appeared. That meant that, after tabbing through all
the links and buttons in, for instance, the debates index, the page
would be filled with "participation not allowed" messages, and in order
to see the information about how many people have voted, reloading the
page was required.

For touchscreen users the behavior was similar to what we get on hover,
although we've found some inconsistencies when trying to support several
elements on the same page.

We think in proposals it makes sense to hide the "support" button when
users click on it, and the same applies to the buttonsto support and
vote investment projects. However, we aren't hiding the buttons to
agree/disagree with a debate in order to keep the information about the
current number of people agreeing and disagreeing visible.

Note we're removing some support spec methods because after these
changes the duplication isn't as obvious as it was in the past.
2022-02-23 16:43:37 +01:00
Javi Martín
168575d606 Remove "not allowed" when supporting comments
Hovering over the votes showed a "participation not allowed" message
which was annoying when scrolling with the browser or simply moving the
mouse around the page. Furthermore, it hid the information about the
number of votes, links to show/collapse replies, ...

We're planning to change the behavior of all the "participation not
allowed" messages in order to show them on click instead of showing them
on hover (just like it's done on touchscreens). In the case of comments,
supports, however, there's very limited space in the part showing the
number of supports for comments, so adding this message without breaking
the layout is challenging.

So, for now, we're simply redirecting unauthenticated users to the login
page. If find an easy way to implement a better user interface in the
future to display the "participation not allowed" message, we might
change this behaviour.
2022-02-21 18:48:09 +01:00
Javi Martín
ecd34ca6ce Make participation not allowed text size consistent
Not sure whether small or normal is better, but at least it's the same.
2022-02-21 18:48:09 +01:00
Javi Martín
9154614577 Always show not allowed message in legislation debates
This message is only shown in the `show` action, so it's shown at most
once in the whole page, so it doesn't take up too much space and it
isn't as overwhelming as if we were showing it on the index page, once
per debate.

We're only showing it when there are closed options, though, since
there's already a message to sign in to comment when the question
accepts open answers.
2022-02-21 18:48:09 +01:00
Javi Martín
86ad2df46d Unify code in debates/legislation vote links
We were using the same code to render links to agree and disagree, so we
can extract a new component for this code.

We're also adding component tests to make it easier to test whether
we're breaking anything while refactoring, although the code is probably
already covered by system tests.

Since the votes mixin was only used in one place, we're removing it and
moving most of its code to a new CSS file for the shared component.
2022-02-21 18:47:13 +01:00
Javi Martín
4b42a68b6a Use the vote action to vote featured proposals
The action and the views were almost identical, with the supports
progress and the HTML classes of the success message element being the
only exceptions; we can use CSS for the styles instead.
2022-02-21 18:47:13 +01:00
Javi Martín
a8ff04d9b7 Fix investments list layout on small screens
The flex layout didn't work well on small screens, since there was
barely any space for the elements.
2021-11-09 12:27:11 +01:00
decabeza
1a73b20d9b Fix supported investments layout 2021-11-08 01:15:13 +01:00
Javi Martín
a08886fcf4 Remove obsolete investment-projects-list selector
It isn't used since we deleted spending proposals in commit d0b8fef6b.
2021-11-08 01:14:58 +01: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
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
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
decabeza
578f3437da Update styles and layout for new proposals form 2021-07-13 15:27:20 +02:00