Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add expanded-row class and styling to expando-row #388

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/documentation/components/table-expando-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,27 @@ <h2>Instelbare variabelen</h2>
<td>Subtitel binnen de openklapbare cel - h2</td>
<td>SASS</td>
</tr>
<tr>
<td>--expando-rows-row-background-color</td>
<td><a href="../variables.html#background-color">background-color</a></td>
<td>transparent</td>
<td>De openklapbare rij</td>
<td>CSS</td>
</tr>
<tr>
<td>--expando-rows-row-striping-background-color</td>
<td><a href="../variables.html#background-color">background-color</a></td>
<td>var(--table-row-background-color-striping, initial)</td>
<td>De openklapbare rij</td>
<td>CSS</td>
</tr>
<tr>
<td>--expando-rows-row-font-weight</td>
<td><a href="../variables.html#font-weight">font-weight</a></td>
<td>bold</td>
<td>De openklapbare rij</td>
<td>CSS</td>
</tr>
</tbody>
</table>
</div>
Expand Down
3 changes: 3 additions & 0 deletions manon/expando-rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,22 @@ function initExpandoButton(button) {

button.addEventListener("click", function () {
var expand = button.getAttribute("aria-expanded") === "false";

if (expand) {
button.innerText = closeLabel;

button.setAttribute("aria-expanded", "true");
button.classList.remove.apply(button.classList, iconOpenClasses);
button.classList.add.apply(button.classList, iconCloseClasses);
button.parentElement.parentElement.classList.add("expanded-row")
row.removeAttribute("hidden");
} else {
button.innerText = openLabel;

button.setAttribute("aria-expanded", "false");
button.classList.remove.apply(button.classList, iconCloseClasses);
button.classList.add.apply(button.classList, iconOpenClasses);
button.parentElement.parentElement.classList.remove("expanded-row")
row.setAttribute("hidden", "");
}
});
Expand Down
8 changes: 8 additions & 0 deletions manon/table-expando-rows-variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@

/* After breakpoint */
--expando-rows-table-cell-after-breakpoint-padding: 2rem 3rem;

/* Parent row styling when their content is expanded */
--expando-rows-row-background-color: transparent;
--expando-rows-row-striping-background-color: var(
--table-row-background-color-striping,
initial
);
--expando-rows-row-font-weight: bold;
}
11 changes: 11 additions & 0 deletions manon/table-expando-rows.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ table {
}
}
}

.expanded-row {
background-color: var(--expando-rows-row-background-color);
font-weight: var(--expando-rows-row-font-weight);

/* Zebra striping with opacity to keep background color. e.g for warnings or errors */
&:nth-child(even):not(.odd),
&:nth-child(odd).even {
background-color: var(--expando-rows-row-striping-background-color);
}
}