diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index fb6686147..b9d26a68a 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -782,7 +782,7 @@ body { } } - table { + /* table { a:not(.btn):not(.dropdown-item) { text-decoration: none; @@ -790,7 +790,7 @@ body { text-decoration: underline; } } - } + } */ dl.show-page_dl { grid-template-columns: auto 1fr; @@ -958,6 +958,11 @@ body { .border-dashed { --bs-border-style: dashed; + border-style: dashed; + } + + .all-small-caps { + font-variant: all-small-caps; } /* Bootstrap clean */ @@ -990,7 +995,7 @@ body { } .ts-dropdown { - z-index: 9999; + z-index: 8888; } /* Tom-Select fix for bootstrap floating label */ diff --git a/app/assets/stylesheets/bootstrap-variables.scss b/app/assets/stylesheets/bootstrap-variables.scss index 46685496b..c36ecf417 100644 --- a/app/assets/stylesheets/bootstrap-variables.scss +++ b/app/assets/stylesheets/bootstrap-variables.scss @@ -1,6 +1,7 @@ $breadcrumb-divider: quote(">"); $enable-negative-margins: true; $min-contrast-ratio: 3; +$table-striped-order: even; :root { --navbar-height: 66px; diff --git a/app/assets/stylesheets/components/table_component.scss b/app/assets/stylesheets/components/table_component.scss new file mode 100644 index 000000000..bf9e89775 --- /dev/null +++ b/app/assets/stylesheets/components/table_component.scss @@ -0,0 +1,90 @@ +.table-component { + table { + --bs-table-hover-bg: rgba(var(--bs-primary-rgb), 0.09); + /* --bs-table-hover-color: var(--bs-link-color); */ + + --bs-table-striped-bg: rgb(var(--bs-tertiary-bg-rgb)); + + th { + a { + font-size: .9rem; + color: var(--bs-tertiary-color); + visibility: hidden; + + &:hover { + color: rgb(var(--bs-primary-rgb)); + + span.bi-arrow-down-short::before { + content: "\f128"; + } + + span.bi-arrow-up-short::before { + content: "\f148"; + } + } + + span.bi-arrow-down-short.link-primary::before { + content: "\f128"; + } + + span.bi-arrow-up-short.link-primary::before { + content: "\f148"; + } + } + + &:hover { + a { + visibility: visible; + } + } + + a:has(span.bi.link-primary) { + visibility: visible; + } + + &:has(a) { + text-decoration: underline dotted; + text-underline-offset: .2em; + text-decoration-color: rgba(var(--bs-body-color-rgb), 0.25); + } + } + + tr { + td { + padding: 1rem .5rem; + + a:not(.btn):not(.dropdown-item) { + color: inherit; + text-decoration: underline dashed; + text-decoration-color: rgba(var(--bs-body-color-rgb), 0.5); + text-underline-offset: 0.4em; + + &:hover { + color: var(--bs-link-color); + text-decoration: underline; + } + } + + /* &:nth-child(even) { + td { + background-color: var(--bs-table-color-state); + } + } */ + + &:hover { + a:not(.btn):not(.dropdown-item) { + &:hover { + text-decoration-color: rgba(var(--bs-link-color-rgb), 0.5); + } + } + } + } + + &:last-child { + td { + border: none !important; + } + } + } + } +} diff --git a/app/components/list/data_table_component.rb b/app/components/list/data_table_component.rb index 368256e7a..1299377ac 100644 --- a/app/components/list/data_table_component.rb +++ b/app/components/list/data_table_component.rb @@ -74,10 +74,10 @@ def render_bulk_head_checkbox def render_head_cell(col) render(List::TableComponent::TableHeadCell.new(data: { name: col.name })) do + concat col.title + if (sort_by = col.sort_by) - link_to_sort col.title, sort_by - else - col.title + links_to_sort sort_by end end end @@ -102,28 +102,32 @@ def render_col(col, row) col.call(row) end - def link_to_sort(label, attribute) + def links_to_sort(attribute) current_attribute = params[:sort_by]&.to_sym - current_direction = current_attribute == attribute ? params[:sort].to_sym : nil + is_current_attribute = current_attribute == attribute + current_direction = is_current_attribute ? params[:sort].to_sym : nil + + concat(link_to_sort(attribute, is_current_attribute, :asc, current_direction)) + concat(link_to_sort(attribute, is_current_attribute, :desc, current_direction)) + end - parameters = case current_direction - when nil then { sort_by: attribute, sort: :asc } - when :asc then { sort_by: attribute, sort: :desc } - else { sort_by: nil, sort: nil } - end + def link_to_sort(attribute, is_current_attribute, direction, current_direction) + caret = direction == :asc ? "arrow-up-short" : "arrow-down-short" + is_current_direction = current_direction == direction + parameters = is_current_direction ? { sort_by: nil, sort: nil } : { sort_by: attribute, sort: direction } url = url_for(controller.request.query_parameters.merge(parameters)) link_to(url) do - concat label - concat " #{sort_caret(current_direction)}" if current_attribute == attribute + # TODO: user tooltip ? + concat tag.span class: class_names("bi bi-#{caret}", + "ms-2": direction == :asc, + "link-primary": is_current_direction && is_current_attribute), + title: direction, + data: { controller: "tooltip" } end end - def sort_caret(direction) - sanitize(direction == :desc ? "↓" : "↑") - end - def displayed_columns @displayed_columns ||= if @columns_to_display.nil? columns diff --git a/app/components/list/table_component.rb b/app/components/list/table_component.rb index be977443b..8660d3926 100644 --- a/app/components/list/table_component.rb +++ b/app/components/list/table_component.rb @@ -3,7 +3,7 @@ module List class TableComponent < ApplicationComponent erb_template <<~ERB -