Skip to content

Commit

Permalink
Indent
Browse files Browse the repository at this point in the history
Add indent logic and styles. Adapted from getprooph.org
  • Loading branch information
jelofson authored and tobiju committed Jul 29, 2017
1 parent 8fa32b8 commit 6c95bd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions templates/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/**
* Render a nested list of elements as HTML list item. The function calls itself in case
* of nested elements (identified by the key 'nested').
*
* Adds a level- css class to aid in indentation. Thanks to prooph (getprooph.org)
* for the code.
* @param array $elements
* @param Aura\View\View $context
*/
Expand All @@ -11,7 +14,7 @@ function renderTocList(array $elements, Aura\View\View $context)
foreach ($elements as $entry) {
$entryObj = new Bookdown\Bookdown\Content\Heading($entry['number'], $entry['title'], $entry['href'], $entry['id']);

echo '<li class="list-group-item">';
echo '<li class="list-group-item level-' . $entryObj->getLevel() . '">';
echo '<div class="row clearfix">';
echo '<div class="col-sm-2">' . '<span class="text-number">' . "{$entryObj->getNumber()}" . '</span></div>';
echo '<div class="col-sm-10">' . $context->anchorRaw($entryObj->getHref(), $entryObj->getTitle()) . '</div>';
Expand Down Expand Up @@ -57,4 +60,4 @@ function tocEntriesToNestedList(array $entries, $nestLevel)
$nestedEntries[$parent]['nested'][] = $entry->asArray();
}
return $nestedEntries;
}
}
12 changes: 12 additions & 0 deletions templates/style.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@
font-weight: bold;
padding: 0;
}

.list-toc .list-group-item.level-2 {
padding-left: 20px;
}

.list-toc .list-group-item.level-3 {
padding-left: 40px;
}

.list-toc .list-group-item.level-4 {
padding-left: 60px;
}

.list-toc .list-group-item .row {
padding: 7px 0;
Expand Down

0 comments on commit 6c95bd4

Please sign in to comment.