Skip to content

Commit

Permalink
Align dashboard tables with CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbushnell committed Jun 9, 2020
1 parent be5d0fc commit 83d5df7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 deletions.
4 changes: 4 additions & 0 deletions src/assetbundles/indexcpsection/dist/css/Index.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@
color: #0F78EE;
opacity: .35;
}

.isolate__entries th:first-of-type {
width: 65%;
}
27 changes: 0 additions & 27 deletions src/assetbundles/isolate/dist/js/Isolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@
class Isolate {
constructor() {
this.$mainNav = document.querySelector("#nav");
this.$isolateTables = document.querySelectorAll("[data-isolate-table]");

this.moveIsolateNav();
this.removeEntriesNav();

if (this.$isolateTables.length) {
this.getLargestCell();
}
}

removeEntriesNav() {
Expand All @@ -37,28 +32,6 @@ class Isolate {
$isolateNav.parentNode.removeChild($isolateNav);
$dashboardNav.insertAdjacentHTML("afterend", isolateNavHTML);
}

getLargestCell() {
let largestWidth = 0;

for (let i = 0; i < this.$isolateTables.length; i++) {
const $row = this.$isolateTables[i].querySelector("tbody tr td:first-of-type");

if ($row.scrollWidth > largestWidth) {
largestWidth = $row.scrollWidth;
}
}

this.resizeRows(largestWidth);
}

resizeRows(cellWidth) {
const $rows = document.querySelectorAll("#content-container table tbody tr td:first-of-type");

for (let i = 0; i < $rows.length; i++) {
$rows[i].style.width = `${cellWidth}px`;
}
}
}

new Isolate();
6 changes: 3 additions & 3 deletions src/templates/dashboard/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{% block content %}
{% if craft.app.request.getSegment(3) %}
{% set section = craft.app.sections.getSectionByHandle(craft.app.request.getSegment(3)) %}
<table class="data fullwidth collapsible" data-isolate-table>
<table class="data fullwidth collapsible isolate__entries">
<thead>
<tr>
<th>Title</th>
Expand Down Expand Up @@ -127,9 +127,9 @@

{% paginate craft.isolate.getUserEntries(currentUser.id, section.id, 50, true) as draftInfo, draftEntries %}

{% if draftEntries|length %}
{% if draftEntries | length %}
<h2>Drafts</h2>
<table class="data fullwidth collapsible" data-isolate-table>
<table class="data fullwidth collapsible isolate__entries">
<thead>
<tr>
<th>Title</th>
Expand Down

0 comments on commit 83d5df7

Please sign in to comment.