Skip to content

Commit 3209c98

Browse files
committed
Add beginning of react testing section
1 parent 791b4e6 commit 3209c98

File tree

15 files changed

+228
-81
lines changed

15 files changed

+228
-81
lines changed

apps/components_guide_web/lib/components_guide_web/controllers/react_typescript_controller.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ defmodule ComponentsGuideWeb.ReactTypescriptController do
22
use ComponentsGuideWeb, :controller
33

44
def index(conn, _params) do
5-
render(conn, "index.html")
5+
render(conn, "index.html", article: "tips")
6+
end
7+
8+
@articles ["testing"]
9+
10+
def show(conn, %{"article" => article}) when article in @articles do
11+
render(conn, "index.html", article: article)
612
end
713
end

apps/components_guide_web/lib/components_guide_web/markdown_engine.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ defmodule ComponentsGuideWeb.MarkdownEngine do
33

44
@behaviour Phoenix.Template.Engine
55

6-
# require Earmark
6+
require Earmark
77

88
def compile(path, _name) do
99
IO.puts("compile #{path}")
1010
path
1111
|> File.read!()
12-
|> Earmark.as_html!(%Earmark.Options{code_class_prefix: "language-"})
12+
|> Earmark.as_html!(%Earmark.Options{code_class_prefix: "language-", smartypants: false})
1313
|> EEx.compile_string(engine: Phoenix.HTML.Engine, file: path, line: 1)
1414
end
1515
end

apps/components_guide_web/lib/components_guide_web/router.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ defmodule ComponentsGuideWeb.Router do
3434
live "/color/lab/:definition", ColorLive, :lab
3535

3636
get "/swiftui", SwiftUIController, :index
37+
3738
get "/react+typescript", ReactTypescriptController, :index
39+
get "/react+typescript/:article", ReactTypescriptController, :show
3840

3941
resources "/text", TextController
4042
get "/text/:id/text/:format", TextController, :show_text_format

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
<div class="text-white" style="<%= header_styles() %>">
2+
<header class="mx-auto max-w-4xl">
3+
<h1 class="pt-8 row space-x-4 text-4xl text-center font-bold leading-tight text-shadow">
4+
<div class="row">
5+
<span class="mr-2 text-4xl">💁🏼‍♀️🥇</span>
6+
</div>
7+
<span><%= "Accessibility-First Development" %></span>
8+
</h1>
9+
<nav class="pt-6 pb-4">
10+
<ul class="list-none row font-bold" style="--link-padding: 0.75em">
11+
<li><%= link("Landmarks", to: '/accessibility-first/widgets-cheatsheet') %>
12+
<li><%= link("Widgets", to: '/accessibility-first/widgets-cheatsheet') %>
13+
<li><%= link("Properties", to: '/accessibility-first/properties-cheatsheet') %>
14+
<li><%= link("Forms", to: '/accessibility-first/properties-cheatsheet') %>
15+
<li><%= link("Keyboard Navigation", to: '/accessibility-first/properties-cheatsheet') %>
16+
</ul>
17+
</nav>
18+
</header>
19+
</div>
20+
121
<header class="text-white" style="background: <%= header_background() %>;">
222
<div class="container px-6 pt-12 pb-12">
323
<h1 class="mx-auto max-w-4xl text-5xl text-center font-bold leading-tight text-shadow">

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@ subhead = "Guides to accessibility, TDD, BDD, naming, performance, and the lates
4545
</section>
4646
</div>
4747

48+
<div class="text-white" style="<%= sections_styles(:blue) %>">
49+
<header class="mx-auto max-w-4xl">
50+
<h1 class="pt-8 row space-x-4 text-4xl text-center font-bold leading-tight text-shadow">
51+
<div class="row">
52+
<img class="inline-block mr-2" src="<%= "https://cdn.jsdelivr.net/gh/gilbarbara/logos@618de63f309bbf56b67364fd6a441cbbf79403cc/logos/react.svg" %>" alt="React logo" width=48 height=48>
53+
<span class="mr-2 text-3xl">❤️</span>
54+
<img class="inline-block mr-2" src="<%= "https://cdn.jsdelivr.net/gh/gilbarbara/logos@02e637e09b55966e802dfe0bc93595594e0214bb/logos/typescript-icon.svg" %>" alt="TypeScript logo" width=48 height=48>
55+
</div>
56+
<span><%= "React & TypeScript Guide" %></span>
57+
</h1>
58+
<nav class="pt-6 pb-4">
59+
<ul class="list-none row font-bold" style="--link-padding: 0.75em">
60+
<li><%= link("Fundamentals", to: '/react+typescript') %>
61+
<li><%= link("Testing", to: '/react+typescript/testing') %>
62+
</ul>
63+
</nav>
64+
</header>
65+
</div>
66+
4867
<div class="text-white">
4968
<section class="pt-20 pb-20" style="<%= sections_styles(:dark) %>">
5069
<header class="mb-8 mx-auto max-w-4xl px-2 text-center">

apps/components_guide_web/lib/components_guide_web/templates/layout/_banner.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<header role=banner class="bg-gray-900 text-white">
2-
<div class="container px-0 flex flex-col md:flex-row items-stretch text-center md:text-left">
2+
<div class="px-4 flex flex-col md:flex-row items-stretch text-center md:text-left">
33
<a href="/" class="block px-3 py-2 md:py-4 md:text-right text-sm md:text-base font-bold italic uppercase leading-tight tracking-wide hover:bg-gray-800">
44
<span>Components <br>·Guide</span>
55
</a>

apps/components_guide_web/lib/components_guide_web/templates/layout/root.html.leex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/components/prism-typescript.min.js" integrity="sha256-JJe+nf0dk2dH1Ie4AimrLS4bAH+gW6N31hpdlVlT+30=" crossorigin="anonymous"></script>
2424
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/components/prism-tsx.min.js" integrity="sha256-Lu/zMuTtme4f+TbQrXMjj8OQwAb0x4RApaysYdeJBN0=" crossorigin="anonymous"></script>
2525
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/components/prism-go.min.js" integrity="sha256-Og32rFEm2ICsLGNCdEf+nUE/QDhI4nxQ2SLHXD4Yv90=" crossorigin="anonymous"></script>
26+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.20.0/components/prism-c.min.js" integrity="sha256-7bhB6muzOsleE++vCiHNmfoJr6rN5xct1k2ONF4LI44=" crossorigin="anonymous"></script>
2627
<!--<link href="https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@8a0b50bd5cef0c86154c22b8b17d97348323b343/themes/prism-a11y-dark.css" rel="stylesheet">-->
2728
<link rel="stylesheet" href="https://unpkg.com/[email protected]/build/style.css">
2829
<script>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<div class="bg-white">
2121
<div class="content max-w-4xl mx-auto py-8 text-lg">
22-
<%= render(@view_module, "tips.html") %>
22+
<%= render(@view_module, @article <> ".html") %>
2323
</div>
2424
</div>
2525

78.2 KB
Loading
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## Behavior and markup > implementation details
2+
3+
4+
5+
## Roles > Tag Names
6+
7+
You can find a list of roles here [in the spec](https://www.w3.org/TR/wai-aria/#widget_roles).
8+
9+
![list-of-roles.png](list-of-roles.png)
10+
11+
## Roles > Test IDs
12+
13+
- Test IDs are fragile. They are not part of behaviour.
14+
- Easier to write tests first.
15+
- Reduce coupling to a certain implementation.
16+
- Can swap out third-party components.
17+
- Good accessibility from day one.
18+
19+
## Use accessible names
20+
21+
<table style="width: 100%; text-align: left;">
22+
<thead>
23+
<tr>
24+
<th>Role name</th>
25+
<th>Responsibility</th>
26+
<th>HTML example</th>
27+
</tr>
28+
</thead>
29+
<tbody>
30+
<tr>
31+
<td>Button</td>
32+
<td>Perform action here</td>
33+
<td>`<button>`</td>
34+
</tr>
35+
</tbody>
36+
</table>
37+
38+
## Reduce coupling to specific implementations
39+
40+
- Reach UI or React Modal?
41+
- React Select or Downshift?
42+
- Emotion or CSS Modules?
43+
- React or Vue?
44+
- HTML and ARIA are stable, consistent specifications
45+
- Third-party libraries are unstable, discrepant implementations
46+
47+
## Specs
48+
49+
- <https://www.w3.org/TR/wai-aria-practices/>
50+
- <https://www.w3.org/TR/html-aria/>

0 commit comments

Comments
 (0)