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;
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 <a> to fill <td> completely, we use 2 copies of same <a>. 1st is
* left transparent in <td> to resize <td> to link length. 2nd is positioned
* absolutely over whole <td> cell. */
table.items td.link {
padding: 0;
position: relative;
}
/* FIXME: size <a> to fill <td> 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 {

View File

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

View File

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

View File

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