Skip to content

Commit d8e2466

Browse files
committed
Add consistent nav to accessibility first pages
1 parent b40eb39 commit d8e2466

File tree

9 files changed

+91
-56
lines changed

9 files changed

+91
-56
lines changed

apps/components_guide_web/lib/components_guide_web.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ defmodule ComponentsGuideWeb do
4444
alias ComponentsGuideWeb.Router.Helpers, as: Routes
4545
# import Phoenix.LiveView.Helpers
4646
import Phoenix.LiveView, only: [live_render: 2, live_render: 3]
47+
48+
import ComponentsGuideWeb.DownView
4749
alias ComponentsGuideWeb.StylingHelpers, as: Styling
4850
end
4951
end

apps/components_guide_web/lib/components_guide_web/controllers/accessibility_first_controller.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ defmodule ComponentsGuideWeb.AccessibilityFirstController do
1010
render(conn, "landmarks.html")
1111
end
1212

13-
def show(conn, %{"id" => "roles-cheatsheet"}) do
14-
render(conn, "roles-cheatsheet.html")
13+
def show(conn, %{"id" => "widgets-cheatsheet"}) do
14+
render(conn, "widgets-cheatsheet.html")
1515
end
1616

1717
def show(conn, %{"id" => "properties-cheatsheet"}) do
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<%
2+
topics = [
3+
"Landmarks",
4+
{"Widgets", "/accessibility-first/widgets-cheatsheet"},
5+
{"Properties", "/accessibility-first/properties-cheatsheet"},
6+
"Forms",
7+
"Tables",
8+
"ARIA",
9+
"Keyboard Navigation",
10+
"TDD",
11+
"BDD with Jest",
12+
"Integration Testing",
13+
"Atomic Design",
14+
]
15+
link_class = "inline-block mx-1 mb-2 px-4 py-2 text-white rounded shadow-xl"
16+
link_style = "background-color: rgba(255,255,255,0.1)"
17+
%>
18+
<nav class="py-2 text-xl text-center">
19+
<%= for topic <- topics do
20+
case topic do
21+
{text, url} ->
22+
link(text, to: url, class: link_class, style: link_style)
23+
text ->
24+
link(text, to: "#", class: link_class, style: link_style)
25+
end
26+
end %>
27+
</nav>

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/index.html.eex

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,19 @@
1-
<%
2-
topics = [
3-
"Landmarks",
4-
"Roles",
5-
"Widgets",
6-
"States",
7-
"Forms",
8-
"Tables",
9-
"ARIA",
10-
"Keyboard Navigation",
11-
"TDD",
12-
"BDD",
13-
"Integration Testing",
14-
"Jest",
15-
"Atomic Design",
16-
]
17-
%>
18-
191
<header class="text-white" style="background: <%= header_background() %>;">
20-
<section class="container px-6 pt-12 pb-12">
2+
<div class="container px-6 pt-12 pb-12">
213
<h1 class="mx-auto max-w-4xl text-5xl text-center font-bold leading-tight text-shadow">
224
<%= "🥇 Accessibility-First Development" %>
235
</h1>
246
<p class="my-8 mx-auto max-w-3xl text-4xl text-center leading-snug italic text-shadow">
257
<%#= "Write simpler, more robust tests using accessibility affordances." %>
268
<%= "Write simpler, more robust tests via user-friendly accessibility affordances." %>
279
</p>
28-
<p class="py-2 text-xl text-center">
29-
<span>Topics include:</span>
30-
<%= for topic <- topics do %>
31-
<a href="#" class="inline-block mx-1 mb-3 px-4 py-2 text-white rounded shadow-xl" style="background-color: rgba(255,255,255,0.1)"><%= topic %></a>
32-
<% end %>
33-
</p>
34-
</section>
10+
<%= render @view_module, "_nav.html" %>
11+
</div>
3512
</header>
3613

3714
<div class="bg-white">
3815
<%= section "Topics", class: "container pt-8 pb-16 text-2xl" do %>
39-
<%= topic_article(title: "Landmarks and roles", link: Routes.accessibility_first_path(@conn, :show, "roles-cheatsheet")) do %>
16+
<%= topic_article(title: "Landmarks", link: Routes.accessibility_first_path(@conn, :show, "landmarks")) do %>
4017
<ul>
4118
<li><%= link("Orienting web visitors using landmarks", to: "#") %>
4219
</ul>

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/landmarks.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<%
22
theme = %Theme{text_color: "blue"}
3-
[h2, h3] = Theme.headings(theme)
3+
[h2, h3, h4] = Theme.headings(theme)
44
%>
55
<header class="text-white" style="background: <%= header_background %>;">
66
<section class="container px-6 pt-6 pb-6">

apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/properties-cheatsheet.html.eex

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<%
22
theme = %Theme{text_color: "blue"}
3-
[h2, h3] = Theme.headings(theme)
3+
[h2, h3, h4] = Theme.headings(theme)
44
%>
55
<header class="text-white" style="background: <%= header_background %>;">
6-
<section class="container px-6 pt-6 pb-6">
6+
<div class="container px-6 pt-6 pb-6">
77
<h1 class="mx-auto max-w-4xl text-4xl text-center font-bold leading-tight text-shadow">
88
<%= "Accessible Properties Cheatsheet" %>
99
</h1>
10-
<p class="mt-4 mx-auto max-w-3xl text-3xl text-center leading-snug italic text-gray-100 text-shadow">
11-
<%= "Learn properties." %>
10+
<p class="mt-4 text-3xl text-center leading-snug italic text-gray-100 text-shadow">
11+
<%= "Learn one way that works for testing, accessibility, and styling." %>
1212
</p>
13-
</section>
13+
<%= render @view_module, "_nav.html" %>
14+
</div>
1415
</header>
1516

17+
1618
<div class="text-base lg:text-lg flex items-stretch bg-gray-900">
1719
<nav class="w-48 lg:w-64 bg-gray-100 border-r border-gray-200">
1820
<h2 class="pt-4 pl-4 italic">I want to make an element:</h2>
@@ -29,66 +31,80 @@
2931
</nav>
3032
<div class="mx-auto flex-shrink">
3133
<section aria-label="Roles Cheatsheet" class="max-w-xl lg:max-w-4xl px-6 pt-8 pb-16 text-white">
32-
<article>
34+
<article aria-labelledby="hidden" class="space-y-4">
3335
<%= h2.("I want to hide an element", id: "hidden") %>
3436

3537
<p>You can hide using a large range of techniques. What you first want to ask is, from whom do I want to hide the content?
3638

3739
<ul>
38-
<li>Hide to all users.
39-
<li>Hide to sighted users, but show to screen reader users.
40-
<li>Hide to screen reader users, but show to sighted users.
40+
<li><%= down "Hide to **everyone**." %>
41+
<li><%= down "**Screen reader affordance:** hide to sighted users, but show to screen reader users." %>
42+
<li><%= down "**Visual affordance:** hide to screen reader users, but show to sighted users." %>
4143
</ul>
4244

4345
<section aria-labelledby="hidden-all-heading">
44-
<%= h3.("Hide to all users", id: "hidden-all-heading") %>
46+
<%= h3.("Hide to everyone", id: "hidden-all-heading") %>
47+
<%= h4.("Test") %>
4548
<%=
4649
"""
4750
it("is hidden", () => {
4851
expect(screen.queryByRole('link', { name: 'Sign In' })).toBeNull();
4952
})
5053
""" |> code_block(:js)
5154
%>
55+
<%= h4.("Markup") %>
5256
<%=
5357
"""
54-
{{ if .ShowSignIn }}
55-
<a href="/signin">Sign In</a>
56-
{{ end }}
58+
<a href="/signin" hidden>Sign In</a>
5759
""" |> code_block(:html)
5860
%>
61+
<%= h4.("Styling") %>
62+
<%=
63+
"""
64+
[hidden] {
65+
display: none !important;
66+
}
67+
""" |> code_block(:css)
68+
%>
5969
</section>
6070

6171
<section aria-labelledby="hidden-visually-heading">
62-
<%= h3.("Hide only visually", id: "hidden-visually-heading") %>
72+
<%= h3.("Screen reader affordance: hide visually", id: "hidden-visually-heading") %>
73+
<%= h4.("Test") %>
6374
<%=
6475
"""
65-
it("is shown to non-visual users", () => {
76+
it("can still be found by our tests and by screen readers", () => {
6677
expect(
6778
screen.getByRole('link', { name: 'Sign In' })
6879
).toBeInTheDocument();
6980
})
7081
""" |> code_block(:js)
7182
%>
83+
<%= h4.("Markup") %>
7284
<%=
7385
"""
7486
<a href="/signin" class="visually-hidden">Sign In</a>
7587
""" |> code_block(:html)
7688
%>
89+
<%= h4.("Styling") %>
7790
<%=
7891
"""
7992
.visually-hidden {
8093
position: absolute;
8194
overflow: hidden;
8295
clip: rect(0 0 0 0);
83-
height: 1px; width: 1px;
84-
margin: -1px; padding: 0; border: 0;
96+
width: 1px;
97+
height: 1px;
98+
margin: -1px;
99+
padding: 0;
100+
border: 0;
85101
}
86102
""" |> code_block(:css)
87103
%>
88104
</section>
89105

90106
<section aria-labelledby="hidden-screen-heading">
91-
<%= h3.("Hide to screen-reader users", id: "hidden-screen-heading") %>
107+
<%= h3.("Visual affordance: hide to screen reader users", id: "hidden-screen-heading") %>
92108
<%=
93109
"""
94110
it("ignores emoji in accessible name", () => {
@@ -117,6 +133,12 @@
117133
</section>
118134
</article>
119135

136+
<article aria-labelledby="current" class="space-y-4">
137+
<%= h2.(down("I want to make an element **current**"), id: "current") %>
138+
139+
<p>You can hide using a large range of techniques. What you first want to ask is, from whom do I want to hide the content?
140+
</article>
141+
120142
</section>
121143
</div>
122144
</div>
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<%
22
theme = %Theme{text_color: "blue"}
3-
[h2, h3] = Theme.headings(theme)
3+
[h2, h3, h4] = Theme.headings(theme)
44
%>
55
<header class="text-white" style="background: <%= header_background %>;">
6-
<section class="container px-6 pt-6 pb-6">
6+
<div class="container px-6 pt-6 pb-6">
77
<h1 class="mx-auto max-w-4xl text-4xl text-center font-bold leading-tight text-shadow">
8-
<%= "Widgets Cheatsheet" %>
8+
<%= "Accessible Widgets Cheatsheet" %>
99
</h1>
10-
<p class="mt-4 mx-auto max-w-3xl text-3xl text-center leading-snug italic text-yellow-100 text-shadow">
10+
<p class="mt-4 mx-auto max-w-3xl text-3xl text-center leading-snug italic text-gray-100 text-shadow">
1111
<%= "UI roles and their pre-written tests." %>
1212
</p>
13-
</section>
13+
<%= render @view_module, "_nav.html" %>
14+
</div>
1415
</header>
1516

17+
1618
<div class="text-base lg:text-lg flex items-stretch bg-gray-900">
1719
<nav class="w-48 lg:w-64 bg-gray-100 border-r border-gray-200">
1820
<ul class="sticky top-0 p-4 pl-6 list-none leading-loose">

apps/components_guide_web/lib/components_guide_web/views/accessibility_first_view.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ defmodule ComponentsGuideWeb.AccessibilityFirstView do
4646
content_tag(:h3, content, [{:class, class} | attrs])
4747
end
4848

49+
def h4(theme = %Theme{}, content) do
50+
class = "mt-4 mb-2 text-lg leading-normal text-#{theme.text_color}-300"
51+
content_tag(:h4, content, [{:class, class}])
52+
end
53+
4954
def headings(theme = %Theme{}) do
5055
[
5156
fn content, attrs -> h2(theme, content, attrs) end,
52-
fn content, attrs -> h3(theme, content, attrs) end
57+
fn content, attrs -> h3(theme, content, attrs) end,
58+
fn content -> h4(theme, content) end
5359
]
5460
end
5561
end

apps/components_guide_web/lib/components_guide_web/views/down_view.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1+
# Paredown: simplified Markdown subset
12
defmodule ComponentsGuideWeb.DownView do
2-
use ComponentsGuideWeb, :view
3-
43
defmodule ParserState do
54
defstruct html: [], italics: nil, bold: nil, link: nil, link_references: %{}
65

0 commit comments

Comments
 (0)