Skip to content

Commit

Permalink
Treegrid example: Update to use APG Example template for documentatio…
Browse files Browse the repository at this point in the history
…n (pull #710)

For issue #132 to develop treegrid example:

* Converted documentation to standard APG template format.
* Filled in documentation gaps.
* Changed treegrid label.
* removed use of aria-hidden.
  • Loading branch information
jongund authored and mcking65 committed Jun 18, 2018
1 parent 638e1cf commit 8d56a9a
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 64 deletions.
2 changes: 1 addition & 1 deletion examples/treegrid/css/expand-icon-highlighted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 19 additions & 7 deletions examples/treegrid/css/treegrid-1.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
}

#treegrid tr {
display: table-row;
cursor: default;
}

#treegrid tbody td {
cursor: default;
}

Expand All @@ -30,18 +35,24 @@
padding-left: 3ch;
}

#treegrid :focus {
background-color: hsl(230, 60%, 40%);
color: white;
outline: 0;
#treegrid a {
padding-left: .25ch;
padding-right: .25ch;
}

#treegrid :focus a {
color: white;
#treegrid tr:focus,
#treegrid td:focus,
#treegrid a:focus {
outline: 2px solid hsl(216, 94%, 70%);
background-color: hsl(216, 80%, 97%);
}

#treegrid a:focus {
border-bottom: none;
}

/* Hide collapsed rows */
#treegrid tr[aria-hidden="true"] {
#treegrid tr.hidden {
display: none;
}

Expand All @@ -59,6 +70,7 @@
padding-left: 10ch;
}


/* Collapse/expand icons */
#treegrid tr > td:first-child::before {
font-family: monospace;
Expand Down
13 changes: 9 additions & 4 deletions examples/treegrid/js/treegrid-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function TreeGrid (treegridElem, doAllowRowFocus, doStartRowFocus) {
}

function getAllNavigableRows () {
var nodeList = treegridElem.querySelectorAll('tbody > tr:not([aria-hidden="true"])');
var nodeList = treegridElem.querySelectorAll('tbody > tr:not([class~="hidden"])');
// Convert to array so that we can use array methods on it
return Array.prototype.slice.call(nodeList);
}
Expand Down Expand Up @@ -341,10 +341,15 @@ function TreeGrid (treegridElem, doAllowRowFocus, doStartRowFocus) {
doExpandLevel[rowLevel]
&& isExpanded(nextRow);
var willHideRow = !doExpandLevel[rowLevel];
var isRowHidden = nextRow.getAttribute('aria-hidden') === 'true';
var isRowHidden = nextRow.classList.contains('hidden');

if (willHideRow !== isRowHidden) {
nextRow.setAttribute('aria-hidden', willHideRow);
if (willHideRow) {
nextRow.classList.add('hidden');
}
else {
nextRow.classList.remove('hidden');
}
didChange = true;
}
}
Expand All @@ -366,7 +371,7 @@ function TreeGrid (treegridElem, doAllowRowFocus, doStartRowFocus) {
}
}

function getAriaExpandedElem(row) {
function getAriaExpandedElem (row) {
return doAllowRowFocus ? row : getNavigableCols(row)[0];
}

Expand Down
Loading

0 comments on commit 8d56a9a

Please sign in to comment.