Skip to content

Commit

Permalink
Replace <fieldset> with <section> on show pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Uaitt committed Feb 1, 2024
1 parent b589a14 commit 6b001a5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@
.attribute--nested {
border: $base-border;
padding: $small-spacing;
display: table;
width: 100%;
}

.attribute--nested--legend {
display: inline;
background: #fff;
position: relative;
top: -1.5em;
}
13 changes: 13 additions & 0 deletions app/assets/stylesheets/administrate/components/_field-unit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@
content: " *";
}
}

section .field-unit--nested {
display: table;
margin-bottom: 1rem;
width: 90%;
}

.field-unit--legend {
display: inline;
background: #fff;
position: relative;
top: -1.5rem;
}
10 changes: 7 additions & 3 deletions app/views/administrate/application/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ as well as a link to its edit page.
<section class="main-content__body">
<dl>
<% page.attributes.each do |title, attributes| %>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<section class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{page.resource_name}.#{title}", default: title %></legend>
<h1>
<nav class="<%= "field-unit--legend" %>">
<%= t "helpers.label.#{page.resource_name}.#{title}", default: title %>
</nav>
</h1>
<% end %>
<% attributes.each do |attribute| %>
Expand All @@ -59,7 +63,7 @@ as well as a link to its edit page.
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute, page: page %></dd>
<% end %>
</fieldset>
</section>
<% end %>
</dl>
</section>
20 changes: 13 additions & 7 deletions app/views/fields/has_one/_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@ All show page attributes of has_one relationship would be rendered
%>
<% if field.linkable? %>
<fieldset class="attribute--nested">
<legend>
<section class="attribute--nested">
<h1>
<nav class="attribute--nested--legend">
<%= link_to_if(
accessible_action?(field.data, :show),
field.display_associated_resource,
[namespace, field.data],
) %>
</legend>
</nav>
</h1>
<% field.nested_show.attributes.each do |title, attributes| -%>
<fieldset class="<%= "field-unit--nested" if title.present? %>">
<section class="<%= "field-unit--nested" if title.present? %>">
<% if title.present? %>
<legend><%= t "helpers.label.#{namespace}.#{title}", default: title %></legend>
<h1>
<nav class="<%= "field-unit--legend" %>">
<%= t "helpers.label.#{namespace}.#{title}", default: title %>
</nav>
</h1>
<% end %>
<% attributes.each do |attribute| %>
Expand All @@ -41,7 +47,7 @@ All show page attributes of has_one relationship would be rendered
<%= render_field attribute, { page: page } %>
</dd>
<% end %>
</fieldset>
</section>
<% end -%>
</fieldset>
</section>
<% end %>

0 comments on commit 6b001a5

Please sign in to comment.