Sidebar tab styling on narrow screens#1806
Conversation
osma
left a comment
There was a problem hiding this comment.
The end result looks good, but I'm a bit worried about the amount of new CSS this introduces, and the !important rules that could cause problems for users.
I think there could be opportunities to use Boostrap utility classes (e.g. Spacing, Text, Overflow) in the HTML instead of CSS rules. I've suggested a few in the comments. Of course there might be some problem with these that aren't immediately obvious to me :) But please at least check if there are ways like this to simplify the CSS.
resource/css/skosmos.css
Outdated
|
|
||
| /* In smaller screen sizes, the last sidebar tab overflows to the right */ | ||
| @media only screen and (min-width: 768px) and (max-width: 1070px) { | ||
| #sidebar-tabs.wide .nav { |
There was a problem hiding this comment.
Does this actually match any HTML elements? It seems to me that the .nav class is set for the same element (#sidebar-tabs), so this doesn't match its children.
In any case, I think this could be replaced with class="flex-nowrap" which is a Bootstrap utility class.
There was a problem hiding this comment.
I fixed the rule but it has to be done in CSS as it is only applied on narrow screens
| } | ||
| } | ||
|
|
||
| @media only screen and (max-width: 900px) { |
There was a problem hiding this comment.
Could these be replaced with Bootstrap's responsive padding utility classes such as px-sm-1 px-md-2 py-2 ...?
There was a problem hiding this comment.
The bootstrap breakpoints aren't really granular enough (md is >768px and lg >992px screen width)
resource/css/skosmos.css
Outdated
| } | ||
|
|
||
|
|
||
| @media only screen and (max-width: 820px) { |
There was a problem hiding this comment.
Ditto, use responsive padding utility classes?
There was a problem hiding this comment.
I will remove this because it is not really needed
| } | ||
|
|
||
| #sidebar-tabs.wide .nav-item:last-of-type .nav-link { | ||
| justify-content: start !important; |
There was a problem hiding this comment.
Could this be replaced with Bootstrap's text-start utility class?
There was a problem hiding this comment.
The rule is dependent on the screen width which the twig template doesn't know
| } | ||
|
|
||
| #sidebar-tabs.wide .nav-link { | ||
| padding: 0.5rem 0.25rem; |
There was a problem hiding this comment.
Replace with Bootstrap padding classes?
| } | ||
|
|
||
| #sidebar-tabs.wide .nav-item:last-of-type { | ||
| overflow: hidden; |
There was a problem hiding this comment.
Replace with overflow-hidden class? Or is it too difficult to determine the last tab in Twig templates?
src/view/sidebar.inc.twig
Outdated
| <div class="sidebar-buttons"> | ||
| <h2 class="visually-hidden">{{'Sidebar listing: list and traverse vocabulary contents by a criterion' | trans}}</h2> | ||
| <ul class="nav nav-tabs-no-style nav-justified" id="sidebar-tabs" role="tablist"> | ||
| <ul class="nav nav-tabs-no-style nav-justified{% if vocab.config.sidebarViews | length == 4 and vocab.config.showDeprecatedChanges %} wide{% endif %}" id="sidebar-tabs" role="tablist"> |
There was a problem hiding this comment.
Could we change the condition to >= 4 just in case it's later possible to add more than 4 tabs?
src/view/sidebar.inc.twig
Outdated
| <ul class="nav nav-tabs-no-style nav-justified{% if vocab.config.sidebarViews | length == 4 and vocab.config.showDeprecatedChanges %} wide{% endif %}" id="sidebar-tabs" role="tablist"> | ||
| {% for view in vocab.config.sidebarViews %} | ||
| {% if view == 'alphabetical' %} {% set view_trans_text = 'Alpha-nav' %} | ||
| {% if view == 'alphabetical' %} {% set view_trans_text = (vocab.config.sidebarViews | length == 4) ? 'A-Z' : 'Alpha-nav' %} |
There was a problem hiding this comment.
Ditto, >= 4 would be more future-proof
resource/css/skosmos.css
Outdated
| align-items: center; | ||
| justify-content: center; | ||
| transition: none; | ||
| padding: 0.5rem; |
There was a problem hiding this comment.
Use Bootstrap utility class p-2 or something along those lines?
osma
left a comment
There was a problem hiding this comment.
Please merge after considering my suggestions
|



Reasons for creating this PR
Sidebar tabs end up on two separate lines on narrow screen sizes. This PR adds an initial fix for this.
Link to relevant issue(s), if any
Description of the changes in this PR
Addresses requirement 7.2 in #1747
Known problems or uncertainties in this PR
Checklist
.sr-onlyclass, color contrast)