diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 75af048..c95e13f 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -321,22 +321,26 @@ table.items td { border-top: solid 1px #dddddd; padding-block: 0.1em; } -/* TODO: change selector to td:has(a) when :has() available on FF. - * That will fix lack of padding for form elements in first column. */ -table.items td:first-child { +/* NOTE: for to fill completely, we use 2 copies of same . 1st is + * left transparent in to resize to link length. 2nd is positioned + * absolutely over whole cell. */ +table.items td.link { padding: 0; + position: relative; } -/* FIXME: size to fill keeping vertical alignment */ -/* td:absolute > a:relative(0,0,0,0) > div:flex > span */ -table.items a { - color: inherit; - display: block; +table.items td.link a { + color: transparent; font: inherit; - line-height: 2.4; padding-inline-start: 1em; text-align: left; } -table.items a.subunit { +table.items td.link a:last-child { + color: inherit; + display: flex; + inset: 0; + position: absolute; +} +table.items td.link a.subunit { padding-inline-start: 1.6em; } table.items td.actions { diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 70c60a5..c8083d7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -88,6 +88,11 @@ module ApplicationHelper image_element_to(:link, name, image, options, html_options) end + # Workaround to fill with link completely, see CSS for details. + def table_link_to(...) + link_to(...) * 2 + end + private diff --git a/app/views/units/index.html.erb b/app/views/units/index.html.erb index 4a6e500..efa9f5b 100644 --- a/app/views/units/index.html.erb +++ b/app/views/units/index.html.erb @@ -20,9 +20,8 @@ <% Unit.each_with_level(@units) do |unit, level| %> - - <%= link_to unit.symbol, edit_unit_path(unit), - {style: level > 0 ? 'padding-left:0.6em;': ''} %> + + <%= table_link_to unit.symbol, edit_unit_path(unit), class: level > 0 ? 'subunit' : '' %> <%= unit.name %> <%= scientifize(unit.multiplier) unless unit.multiplier == 1 %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 56df7b4..6455d7a 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -11,7 +11,7 @@ <% @users.each do |user| %> - <%= link_to user.email, user_path(user) %> + <%= table_link_to user.email, user_path(user) %> <% if user == current_user %> <%= user.status %>