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

Fix some accessibility issues #1005

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion public/lp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/nitter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ routes:
resp renderMain(renderSearch(), request, cfg, themePrefs())

get "/about":
resp renderMain(renderAbout(), request, cfg, themePrefs())
resp renderMain(renderAbout(), request, cfg, themePrefs(), "About")

get "/explore":
redirect("/about")
Expand Down
5 changes: 4 additions & 1 deletion src/sass/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ a {
fieldset {
border: 0;
padding: 0;
margin-top: -0.6em;
}

legend {
Expand All @@ -96,6 +95,10 @@ legend {
margin-bottom: 8px;
}

.preferences > form:first-of-type {
margin-top: -.6em;
}

.preferences .note {
border-top: 1px solid var(--border_grey);
border-bottom: 1px solid var(--border_grey);
Expand Down
53 changes: 22 additions & 31 deletions src/sass/inputs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,6 @@ input::-webkit-datetime-edit-year-field:focus {
}
}

.checkbox {
position: absolute;
top: 1px;
right: 0;
height: 17px;
width: 17px;
background-color: var(--bg_elements);
border: 1px solid var(--accent_border);

&:after {
content: "";
position: absolute;
display: none;
}
}

.checkbox-container {
display: block;
position: relative;
Expand All @@ -114,31 +98,38 @@ input::-webkit-datetime-edit-year-field:focus {

input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
right: 0;
height: 19px;
width: 19px;
background-color: var(--bg_elements);
border: 1px solid var(--accent_border);
appearance: none;
box-sizing: border-box;
cursor: inherit;

&:after {
left: 2px;
bottom: 0;
font-size: 13px;
font-family: $font_4;
content: '\e803';
position: absolute;
display: none;
bottom: 2px;
}

&:checked ~ .checkbox:after {
&:checked:after {
display: block;
}
}

&:hover input ~ .checkbox {
&:hover input {
border-color: var(--accent);
}

&:active input ~ .checkbox {
&:active input {
border-color: var(--accent_light);
}

.checkbox:after {
left: 2px;
bottom: 0;
font-size: 13px;
font-family: $font_4;
content: '\e803';
}
}

.pref-group {
Expand Down
7 changes: 4 additions & 3 deletions src/sass/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@
margin-left: 23px;
}

.checkbox {
input[type=checkbox] {
right: unset;
left: -22px;
top: 1px;
}

.checkbox-container .checkbox:after {
top: -4px;
.checkbox-container input[type=checkbox]:after {
top: 1px;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/views/general.nim
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ proc renderNavbar(cfg: Config; req: Request; rss, canonical: string): VNode =
if cfg.enableRss and rss.len > 0:
icon "rss-feed", title="RSS Feed", href=rss
icon "bird", title="Open in Twitter", href=canonical
a(href="https://liberapay.com/zedeus"): verbatim lp
a(href="https://liberapay.com/zedeus", title="Liberapay — zedeus"): verbatim lp
icon "info", title="About", href="/about"
icon "cog", title="Preferences", href=("/settings?referer=" & encodeUrl(path))

Expand All @@ -42,7 +42,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
var theme = prefs.theme.toTheme
if "theme" in req.params:
theme = req.params["theme"].toTheme

let ogType =
if video.len > 0: "video"
elif rss.len > 0: "object"
Expand Down Expand Up @@ -134,7 +134,7 @@ proc renderMain*(body: VNode; req: Request; cfg: Config; prefs=defaultPrefs;
body:
renderNavbar(cfg, req, rss, canonical)

tdiv(class="container"):
main(class="container"):
body

result = doctype & $node
Expand Down
26 changes: 14 additions & 12 deletions src/views/preferences.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ macro renderPrefs*(): untyped =
ident("buildHtml"), ident("tdiv"), nnkStmtList.newTree())

for header, options in prefList:
result[2].add nnkCall.newTree(
var prefGroup = nnkCall.newTree(ident("fieldset"), nnkStmtList.newTree())
prefGroup[1].add nnkCall.newTree(
ident("legend"),
nnkStmtList.newTree(
nnkCommand.newTree(ident("text"), newLit(header))))
Expand All @@ -30,20 +31,21 @@ macro renderPrefs*(): untyped =
else:
stmt[0].add newLit(pref.options)

result[2].add stmt
prefGroup[1].add stmt

result[2].add prefGroup

proc renderPreferences*(prefs: Prefs; path: string; themes: seq[string]): VNode =
buildHtml(tdiv(class="overlay-panel")):
fieldset(class="preferences"):
form(`method`="post", action="/saveprefs", autocomplete="off"):
refererField path
buildHtml(tdiv(class="overlay-panel preferences")):
form(`method`="post", action="/saveprefs", autocomplete="off"):
refererField path

renderPrefs()
renderPrefs()

h4(class="note"):
text "Preferences are stored client-side using cookies without any personal information."
h4(class="note"):
text "Preferences are stored client-side using cookies without any personal information."

button(`type`="submit", class="pref-submit"):
text "Save preferences"
button(`type`="submit", class="pref-submit"):
text "Save preferences"

buttonReferer "/resetprefs", "Reset preferences", path, class="pref-reset"
buttonReferer "/resetprefs", "Reset preferences", path, class="pref-reset"
11 changes: 5 additions & 6 deletions src/views/renderutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,21 @@ proc buttonReferer*(action, text, path: string; class=""; `method`="post"): VNod
text text

proc genCheckbox*(pref, label: string; state: bool): VNode =
buildHtml(label(class="pref-group checkbox-container")):
text label
input(name=pref, `type`="checkbox", checked=state)
span(class="checkbox")
buildHtml(tdiv(class="pref-group checkbox-container")):
label(`for`=pref): text label
input(id=pref, name=pref, `type`="checkbox", checked=state)

proc genInput*(pref, label, state, placeholder: string; class=""; autofocus=true): VNode =
let p = placeholder
buildHtml(tdiv(class=("pref-group pref-input " & class))):
if label.len > 0:
label(`for`=pref): text label
input(name=pref, `type`="text", placeholder=p, value=state, autofocus=(autofocus and state.len == 0))
input(id=pref, name=pref, `type`="text", placeholder=p, value=state, autofocus=(autofocus and state.len == 0))

proc genSelect*(pref, label, state: string; options: seq[string]): VNode =
buildHtml(tdiv(class="pref-group pref-input")):
label(`for`=pref): text label
select(name=pref):
select(id=pref, name=pref):
for opt in options:
option(value=opt, selected=(opt == state)):
text opt
Expand Down