Commit Graph

38 Commits

Author SHA1 Message Date
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
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
Javi Martín
bbd4d3e62d Render components instead of partials in headers
We were using partials to render components in order to ease the
transition of custom code from earlier versions of Consul. However,
that was back in Consul 1.4, and now these views looked a bit messy
since they sometimes rendered components and sometimes they
rendered partials.
2023-02-16 17:24:34 +01:00
Javi Martín
2ac338f51a Remove redundant admin-top-bar element
We weren't using the `admin-top-bar` class since commit e6c1cf774, and
we can always use the `.admin .top-bar` selector if we need to. And the
`row expanded` classes basically give an element a width of 100%, which
is already the default width for block elements.
2023-02-16 17:24:34 +01:00
Javi Martín
49cb6e010b Extract component to render the responsive menu
We were using the same code for the button in both the public and admin
headers, so we're removing the duplication.

Since the menu and the button must go together, and the contents of the
menu are different for different layouts, we're passing these contents
using a block.

Note the ID of the menu was `responsive-menu` in the public section but
`responsive_menu` in the admin section. Since we usually use underscores
for IDs and dashes for classes, we're keeping the one with the
underscore.
2023-02-16 17:24:34 +01:00
Javi Martín
b489923f66 Move menu button to the left in the admin section
So now it uses the same interface and styles as the main layout. On
small screens, it's easier to play with the menu when the button is on
the left because the menu it opens is aligned to the left.

Note that now we can get rid of the title-bar class; we didn't use the
styles in the public area since commit dcec003d0, and we were overriding
all the Foundation styles in the admin area with the exception of the
padding, which we no longer need.
2023-02-16 17:24:34 +01:00
Javi Martín
c553e15a90 Remove usage of top-bar-left class
We don't need it since it's only used for flexbox styles, and we
already have a `flex-grow` rule for the `h1` element which does the
same thing.
2023-02-16 17:07:20 +01:00
Javi Martín
70161720a0 Remove usages of the top-bar-right class
This is one of Foundation's classes that only applies when its
parent element is a flex container, which isn't the case here since
commit dcec003d0.
2023-02-16 17:07:20 +01:00
Javi Martín
d0fcc9022f Move menu and navigation styles to their own files
This way we follow the convention of one stylesheet per component.
Note that we depend on Foundation's `menu` class for some of the
styles and JavaScript behavior, so we're keeping both the `menu` and
`account-menu` classes.
2023-02-16 17:07:20 +01:00
Javi Martín
967bb4d097 Use link_list to render admin login items
This way it's easier to customize this menu.
2023-01-16 14:44:05 +01:00
Javi Martín
c40c6e04e7 Move login links to components
We're trying to be consistent; in the past, we had the partials
"shared/admin_login_items", "layouts/notification_item" and
"devise/menu/login_items". Now we're moving all these partials to
components in the `Layout` namespace.
2023-01-16 14:44:05 +01:00
Javi Martín
e000bd9a61 Hide menu button to managers on small screens
This menu isn't rendered in this case, so the "menu" button to toggle it
did nothing.
2023-01-16 14:44:01 +01:00
Javi Martín
44e3a393a0 Move navigation and footer partials to components
This way it'll be easier to decide when they should be rendered.

In order to be consistent, we're using the `Layout` module for both
components; previously, the navigation partial was in the `shared`
folder while the footer partial was in the `layout` folder, which IMHO
didn't make much sense.
2023-01-16 14:22:23 +01:00
Javi Martín
64536f069c Extract component for account/admin menu links
This way we remove the duplication in the layouts which had these links.

Since we're now passing the `current_user` option to partials in all
cases, IMHO the code is easier to follow if we use the
`Layout::NotificationItemComponent` instead of its partial.
2023-01-16 14:22:23 +01:00
Javi Martín
ca28a31ee5 Extract method in admin header component 2023-01-16 14:22:23 +01:00
Javi Martín
86fd14f8f0 Move admin header partial to a component
This way it's easier to refactor it.

Note we're using `with_request_url` in the tests because the component
renders the locale switcher, which needs a URL in order to work. This
doesn't affect whether we're in the management section or not.
2023-01-16 14:22:13 +01:00
Javi Martín
5c61b72d21 Identify the current tenant in the <html> tag
This way it will be possible to write CSS and JavaScript code that will
only apply to specific tenants.

Note that CSS customization is still limited because it isn't possible
to use different SCSS variables per tenant.
2022-11-11 01:39:29 +01:00
Javi Martín
2c0ede3aaa Use the dir attribute in dashboard and mailer layouts
We forgot to do so in commit d827768c0. In order to avoid the same
mistake in the future, we're extracting a method to get these
attributes. We're also adding tests, since we didn't have any tests to
check that the `dir` attribute was properly set.
2022-11-11 01:39:29 +01:00
Senén Rodero Rodríguez
ede6a3f73f Disable Turbolinks page loading for language links
Only when the current language has a different text direction
than the localization link to generate.
2022-06-08 07:12:29 +02:00
taitus
291b478050 Fix typo for "instagram"
This typo was accidentally introduced in commit 3b00f3c141.
2022-01-28 14:30:34 +01: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
Javi Martín
477c67efd8 Simplify setting the options in language selector 2021-07-05 22:27:39 +02:00
Javi Martín
b8870dd95a Add a lang attribute to language options
I'm not sure screen readers recognize this attribute inside `<option>`
tags, but if they do, it'll probably be helpful. And if they don't, no
harm will be done.
2021-07-05 22:27:39 +02:00
Javi Martín
0750166d77 Extract methods in locale switcher 2021-07-05 22:27:39 +02:00
Javi Martín
ff0f2215ea Extract component for locale switcher
Note that in order to simplify the component tests (which for some
reason seem to be whitespace-sensitive), we have to omit whitespace
characters inside the `<option>` tags.

Also note we're simplifying the test with a missing language name; since
a component test doesn't involve a whole request, we don't need a
complex setup (I'm not sure we even need it in system tests).
2021-07-05 22:27:39 +02:00
Javi Martín
bf10cf0c18 Simplify calls to content_block helper
All calls were using `I18n.locale` as the second parameter, so we might
as well make it optional.
2021-06-24 13:15:04 +02:00
Javi Martín
dae4aae328 Avoid rendenring an empty list in top links
We've had an accessibility error reported by the Spanish "Portal
Administración electrónica" (PAe). While I can't find any accessibility
rule saying empty lists should be avoided, it looks like some screen
readers report finding lists with 0 items, which is annoying.
2021-06-24 13:15:04 +02:00
Javi Martín
6d999559b3 Move top links partial to a component
This way it's easier to test.
2021-06-24 13:15:04 +02:00
Javi Martín
da76c848fc Avoid rendering an empty list in footer
We've had an accessibility error reported by the Spanish "Portal
Administración electrónica" (PAe). While I can't find any accessibility
rule saying empty lists should be avoided, it looks like some screen
readers report finding lists with 0 items, which is annoying.

We could also do it with CSS using `ul:empty { display: none}`. However,
at the time of writing no browser supports this rule when the tag
contains whitespace.
2021-06-24 13:15:03 +02:00
Javi Martín
211ed101b9 Simplify code in social component 2021-06-24 12:43:44 +02:00
Javi Martín
3b00f3c141 Remove duplication in social icons in footer 2021-06-24 12:43:44 +02:00
Javi Martín
0aba34ad4d Extract social links to a component 2021-06-24 12:43:43 +02:00
Javi Martín
e266e0e0e2 Simplify code to display text of new notifications
We couldn't do this refactoring earlier because we weren't using the
unread notifications count. This was fixed in the previous commit.
2021-02-18 14:45:48 +01:00
Javi Martín
fb88e0b77c Fix number of new notifications
We were displaying the total number of notifications with a message "You
have N unread notifications", but were using the total number of
notifications instead of the unread ones.
2021-02-18 14:45:48 +01:00
Javi Martín
4c289f2489 Simplify notification item HTML
Other than simplifying the view, we can write tests using `click_link`,
which makes the tests more robust. Clicking the `.icon-notification`
element was causing some tests to fail when defining a window height of
750 pixels in the `admin_budgets` branch.
2021-02-16 23:21:51 +01:00
Javi Martín
5b6551f6d7 Extract method to get the notifications link text 2021-02-16 00:01:10 +01:00
Javi Martín
f11f2cd3dd Extract component to render notifications item 2021-02-16 00:00:49 +01:00