Expand link to whole table cell

This commit is contained in:
cryptogopher 2023-12-05 19:10:36 +01:00
parent 3127c72288
commit bad64c5dbf
4 changed files with 22 additions and 14 deletions

View File

@ -321,22 +321,26 @@ table.items td {
border-top: solid 1px #dddddd; border-top: solid 1px #dddddd;
padding-block: 0.1em; padding-block: 0.1em;
} }
/* TODO: change selector to td:has(a) when :has() available on FF. /* NOTE: for <a> to fill <td> completely, we use 2 copies of same <a>. 1st is
* That will fix lack of padding for form elements in first column. */ * left transparent in <td> to resize <td> to link length. 2nd is positioned
table.items td:first-child { * absolutely over whole <td> cell. */
table.items td.link {
padding: 0; padding: 0;
position: relative;
} }
/* FIXME: size <a> to fill <td> keeping vertical alignment */ table.items td.link a {
/* td:absolute > a:relative(0,0,0,0) > div:flex > span */ color: transparent;
table.items a {
color: inherit;
display: block;
font: inherit; font: inherit;
line-height: 2.4;
padding-inline-start: 1em; padding-inline-start: 1em;
text-align: left; 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; padding-inline-start: 1.6em;
} }
table.items td.actions { table.items td.actions {

View File

@ -88,6 +88,11 @@ module ApplicationHelper
image_element_to(:link, name, image, options, html_options) image_element_to(:link, name, image, options, html_options)
end end
# Workaround to fill <td> with link completely, see CSS for details.
def table_link_to(...)
link_to(...) * 2
end
private private

View File

@ -20,9 +20,8 @@
<tbody> <tbody>
<% Unit.each_with_level(@units) do |unit, level| %> <% Unit.each_with_level(@units) do |unit, level| %>
<tr> <tr>
<td> <td class="link">
<%= link_to unit.symbol, edit_unit_path(unit), <%= table_link_to unit.symbol, edit_unit_path(unit), class: level > 0 ? 'subunit' : '' %>
{style: level > 0 ? 'padding-left:0.6em;': ''} %>
</td> </td>
<td><%= unit.name %></td> <td><%= unit.name %></td>
<td class="number"><%= scientifize(unit.multiplier) unless unit.multiplier == 1 %></td> <td class="number"><%= scientifize(unit.multiplier) unless unit.multiplier == 1 %></td>

View File

@ -11,7 +11,7 @@
<tbody> <tbody>
<% @users.each do |user| %> <% @users.each do |user| %>
<tr> <tr>
<td><%= link_to user.email, user_path(user) %></td> <td class="link"><%= table_link_to user.email, user_path(user) %></td>
<td> <td>
<% if user == current_user %> <% if user == current_user %>
<%= user.status %> <%= user.status %>