Skip to content

Commit

Permalink
fix font size and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfast committed Nov 20, 2023
1 parent 508849f commit 38926c7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nbconvert_html5/pytest_axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def from_violations(cls, data):
for violation in (violations := data.get("violations")):
for node in violation["nodes"]:
for exc in node["any"]:
out.append(cls.new(**exc, target=["target"]))
out.append(cls.new(**exc, target=node["target"]))
return exceptiongroup.ExceptionGroup(f"{len(violations)} accessibility violations", out)


Expand Down
5 changes: 4 additions & 1 deletion nbconvert_html5/templates/a11y/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function setStyle(msg) {
activityLog(msg);
}
function changeFont() {
document.forms.settings["font-size"].value;
setStyle(`font size change`);
}
function changeFontFamily() {
Expand Down Expand Up @@ -127,7 +128,9 @@ document.querySelectorAll("table[role=grid]").forEach(
document.forms.settings.elements["color-scheme"].forEach(
(x) => { x.addEventListener("change", toggleColorScheme) }
);
document.forms.settings.elements["font-size"].addEventListener("change", changeFont);
document.forms.settings.elements["font-size"].addEventListener("change", (x) => {
setStyle("change font size");
});
document.forms.settings.elements["font-family"].forEach(
(x) => { x.addEventListener("change", changeFontFamily) }
);
Expand Down
2 changes: 1 addition & 1 deletion nbconvert_html5/templates/a11y/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

body {
font-size: --var(--nb-font-size);
font-size: var(--nb-font-size);
overflow-x: hidden;
accent-color: var(--nb-accent-color);
margin-left: var(--nb-margin);
Expand Down
13 changes: 11 additions & 2 deletions tests/test_axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ def test_dialogs(axe_page, config, notebook, dialog):
page.click(dialog)
run_axe_test(page).raises()


@config_notebooks_dialog
def test_settings(axe_page, config, notebook):
"""test that the settings make their expected changes"""
def test_settings_font_size(axe_page, config, notebook):
"""test that the settings make their expected changes"""
page = axe_page(get_target_html(config, notebook).absolute().as_uri())
font_size = lambda: page.evaluate(
"""window.getComputedStyle(document.querySelector("body")).getPropertyValue("font-size")"""
)
assert font_size() == "16px"
page.click("[aria-controls=nb-settings]")
page.locator("#nb-table-font-size-group").select_option("xx-large")
assert font_size() == "32px", "font size not changed"

0 comments on commit 38926c7

Please sign in to comment.