Commit Graph

10 Commits

Author SHA1 Message Date
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
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
4bb12c573f Fix invisible text selection on brand text
When an element had a text using the brand color and was a child of an
element with a brand background, the selection was invisible.
2021-03-24 15:48:24 +01:00
Manu
b6cfe92d76 fixed banner styles issues 2019-01-21 12:02:27 -05:00
Manu
bd4e12112d Add image to legislation processes and banner colors 2019-01-21 12:02:27 -05:00
decabeza
aa76251d1d Adds image to legislation proposals views 2018-10-01 16:49:22 +02:00
decabeza
363f2a59ac improves styles for community 2017-09-21 17:39:55 +02:00
Alessandro Cuoghi
f67f4c85c7 If there is no theme, add text and link. 2017-09-05 12:55:12 +02:00
decabeza
76b7f66fb3 fixes scss lint warnings 2017-06-16 12:09:01 +02:00
Alberto Garcia Cabeza
d47ce39b37 adds styles and images 2017-03-29 18:00:49 +02:00