|
| 1 | +<% |
| 2 | + theme = %Theme{text_color: "blue"} |
| 3 | + [h2, h3] = Theme.headings(theme) |
| 4 | +%> |
| 5 | +<header class="text-white" style="background: <%= header_background %>;"> |
| 6 | + <section class="container px-6 pt-6 pb-6"> |
| 7 | + <h1 class="mx-auto max-w-4xl text-4xl text-center font-bold leading-tight text-shadow"> |
| 8 | + <%= "Properties Cheatsheet" %> |
| 9 | + </h1> |
| 10 | + <p class="mt-4 mx-auto max-w-3xl text-3xl text-center leading-snug italic text-yellow-100 text-shadow"> |
| 11 | + <%= "UI roles and their pre-written tests." %> |
| 12 | + </p> |
| 13 | + </section> |
| 14 | +</header> |
| 15 | + |
| 16 | +<div class="text-base lg:text-lg flex items-stretch bg-gray-900"> |
| 17 | + <nav class="w-48 lg:w-64 bg-gray-100 border-r border-gray-200"> |
| 18 | + <ul class="sticky top-0 p-4 pl-6 list-none leading-loose"> |
| 19 | + <li><%= link "Hide", to: "#hide" %> |
| 20 | + <li><%= link("Queries 🔗", to: "https://testing-library.com/docs/dom-testing-library/api-queries") %> |
| 21 | + <li><%= link("Matchers 🔗", to: "https://github.com/testing-library/jest-dom") %> |
| 22 | + </ul> |
| 23 | + </nav> |
| 24 | + <div class="mx-auto flex-shrink"> |
| 25 | + <section aria-label="Roles Cheatsheet" class="max-w-xl lg:max-w-3xl px-4 pt-8 pb-16 text-white"> |
| 26 | + <article> |
| 27 | + <%= h2.("I want to hide an element", id: "hidden") %> |
| 28 | + |
| 29 | + <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? |
| 30 | + |
| 31 | + <ul> |
| 32 | + <li>Hide to all users. |
| 33 | + <li>Hide to sighted users, but show to screen reader users. |
| 34 | + <li>Hide to screen reader users, but show to sighted users. |
| 35 | + </ul> |
| 36 | + |
| 37 | + <section aria-labelledby="hidden-all-heading"> |
| 38 | + <%= h3.("Hide to all users", id: "hidden-all-heading") %> |
| 39 | + <%= |
| 40 | + """ |
| 41 | + it("is hidden", () => { |
| 42 | + expect(queryByRole('link', { name: 'Sign In' })).toBeNull(); |
| 43 | + }) |
| 44 | + """ |> code_block(:js) |
| 45 | + %> |
| 46 | + <%= |
| 47 | + """ |
| 48 | + {{ if .ShowSignIn }} |
| 49 | + <a href="/signin">Sign In</a> |
| 50 | + {{ end }} |
| 51 | + """ |> code_block(:html) |
| 52 | + %> |
| 53 | + </section> |
| 54 | + |
| 55 | + <section aria-labelledby="hidden-visually-heading"> |
| 56 | + <%= h3.("Hide only visually", id: "hidden-visually-heading") %> |
| 57 | + <%= |
| 58 | + """ |
| 59 | + it("is shown to non-visual users", () => { |
| 60 | + expect( |
| 61 | + getByRole('link', { name: 'Sign In' }) |
| 62 | + ).toBeInTheDocument(); |
| 63 | + }) |
| 64 | + """ |> code_block(:js) |
| 65 | + %> |
| 66 | + <%= |
| 67 | + """ |
| 68 | + <a href="/signin" class="visually-hidden">Sign In</a> |
| 69 | + """ |> code_block(:html) |
| 70 | + %> |
| 71 | + <%= |
| 72 | + """ |
| 73 | + .visually-hidden { |
| 74 | + position: absolute; |
| 75 | + overflow: hidden; |
| 76 | + clip: rect(0 0 0 0); |
| 77 | + height: 1px; width: 1px; |
| 78 | + margin: -1px; padding: 0; border: 0; |
| 79 | + } |
| 80 | + """ |> code_block(:css) |
| 81 | + %> |
| 82 | + </section> |
| 83 | + |
| 84 | + <section aria-labelledby="hidden-screen-heading"> |
| 85 | + <%= h3.("Hide to screen-reader users", id: "hidden-screen-heading") %> |
| 86 | + <%= |
| 87 | + """ |
| 88 | + it("ignores emoji in accessible name", () => { |
| 89 | + expect( |
| 90 | + getByRole('link', { name: 'Sign In' }) |
| 91 | + ).toBeInTheDocument(); |
| 92 | + }) |
| 93 | + """ |> code_block(:js) |
| 94 | + %> |
| 95 | + <%= |
| 96 | + """ |
| 97 | + <a href="/signin"> |
| 98 | + <span aria-hidden="true">👉</span> |
| 99 | + Sign In |
| 100 | + </a> |
| 101 | + """ |> code_block(:html) |
| 102 | + %> |
| 103 | + </section> |
| 104 | + |
| 105 | + <section aria-labelledby="hidden-notes-heading"> |
| 106 | + <%= h3.("Notes", id: "hidden-notes-heading") %> |
| 107 | + <ul> |
| 108 | + <li><%= link("MDN: Using the aria-hidden attribute", to: "https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-hidden_attribute") %> |
| 109 | + <li><%= link("Places it’s tempting to use `display: none;`, but don’t ", to: "https://css-tricks.com/places-its-tempting-to-use-display-none-but-dont/") %> |
| 110 | + </ul> |
| 111 | + </section> |
| 112 | + </article> |
| 113 | + |
| 114 | + </section> |
| 115 | + </div> |
| 116 | +</div> |
0 commit comments