Skip to content

Commit 3ecff92

Browse files
committed
Add helper for code
1 parent fe8ae58 commit 3ecff92

File tree

2 files changed

+78
-12
lines changed

2 files changed

+78
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,83 @@
11
<header class="text-white" style="background: <%= header_background %>;">
2-
<section class="container px-6 pt-12 pb-12">
3-
<h1 class="mx-auto max-w-4xl text-5xl text-center font-bold leading-tight text-shadow">
2+
<section class="container px-6 pt-6 pb-6">
3+
<h1 class="mx-auto max-w-4xl text-4xl text-center font-bold leading-tight text-shadow">
44
<%= "Roles Cheatsheet" %>
55
</h1>
6-
<p class="my-8 mx-auto max-w-3xl text-4xl text-center leading-snug italic text-yellow-100 text-shadow">
6+
<p class="mt-4 mx-auto max-w-3xl text-3xl text-center leading-snug italic text-yellow-100 text-shadow">
77
<%= "Find the role and copy the tests for a particular UI widget." %>
88
</p>
99
</section>
1010
</header>
1111

12-
<div class="bg-white">
13-
<section aria-label="Roles Cheatsheet" class="container pt-8 pb-16 text-2xl">
12+
<div class="flex items-stretch bg-white">
13+
<nav class="w-64 p-4 pl-6 text-xl bg-gray-100 border-r border-gray-200">
14+
<ul class="fixed list-none leading-loose">
15+
<li><%= link "Link", to: "#link" %>
16+
<li><%= link "Button", to: "#button" %>
17+
<li><%= link "Checkbox", to: "#checkbox" %>
18+
<li><%= link "Radio", to: "#radio" %>
19+
<li><%= link "Tab", to: "#tab" %>
20+
</ul>
21+
</nav>
22+
<div class="ml-64">
23+
<section aria-label="Roles Cheatsheet" class="container px-4 pt-8 pb-16 text-2xl">
1424

15-
<article>
16-
<h2 class="mb-2 text-4xl leading-normal text-teal-800">Link</h2>
17-
<pre><code>
18-
getByRole('link')
19-
</code></pre>
20-
</article>
25+
<article>
26+
<h2 id="link" class="mb-2 text-4xl leading-normal text-teal-800">Link</h2>
27+
<%=
28+
"""
29+
getByRole('link', { name: 'About' });
30+
""" |> code_block(:js)
31+
%>
32+
<%=
33+
"""
34+
<a href="/about">About</a>
35+
""" |> code_block(:html)
36+
%>
37+
</article>
2138

22-
</section>
39+
<article>
40+
<h2 id="button" class="mb-2 text-4xl leading-normal text-teal-800">Button</h2>
41+
<%=
42+
"""
43+
getByRole('button', { name: 'Click me' });
44+
""" |> code_block(:js)
45+
%>
46+
<%=
47+
"""
48+
<button>Click me</button>
49+
""" |> code_block(:html)
50+
%>
51+
</article>
52+
53+
<article>
54+
<h2 id="checkbox" class="mb-2 text-4xl leading-normal text-teal-800">Checkbox</h2>
55+
<%=
56+
"""
57+
getByRole('button', { name: 'Click me' });
58+
""" |> code_block(:js)
59+
%>
60+
<%=
61+
"""
62+
<button>Click me</button>
63+
""" |> code_block(:html)
64+
%>
65+
</article>
66+
67+
<article>
68+
<h2 id="radio" class="mb-2 text-4xl leading-normal text-teal-800">Radio</h2>
69+
<%=
70+
"""
71+
getByRole('button', { name: 'Click me' });
72+
""" |> code_block(:js)
73+
%>
74+
<%=
75+
"""
76+
<button>Click me</button>
77+
""" |> code_block(:html)
78+
%>
79+
</article>
80+
81+
</section>
82+
</div>
2383
</div>

apps/components_guide_web/lib/components_guide_web/views/accessibility_first_testing_view.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ defmodule ComponentsGuideWeb.AccessibilityFirstTestingView do
1919
</article>
2020
"""
2121
end
22+
23+
def code_block(code, type) do
24+
~E"""
25+
<pre><code class='<%= "lang-#{type}" %>'><%= code %></code></pre>
26+
"""
27+
end
2228
end

0 commit comments

Comments
 (0)