You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(#62): Add support for code block line highlighting comments (#111)
* feat(#62): adjust code block styles to accomodate line highlighting
* chore(#62): bump versions @testing-library/* versions
- Needed to be able to access <code/> elements by role (see: testing-library/dom-testing-library#1100)
* chore(#62): major version update for prism-react-renderer
* refactor(#62): improve code readability
* feat(#62): add support for highlight-line comments
* fix(#62): lint
* feat(#62): add support for highlight-start / highlight-end comments
* feat(#62): add support for highlight-next-line comments
* refactor(#62): group initial shouldHighlightLine values
* fix(#62): move codeClassNames into getLineProps, to avoid overwriting the token-line class from prism-react-renderer
* fix(#62): update line highlight color to match Night Owl theme
* refactor(#62): clean up semantic HTML structure
- use figure/figcaption instead of div
- use only one code element (vs one per line)
* fix(#62): fix padding on pre element when no language tag or file tag
* feat(#62): update semantics for highlighted lines to use <mark>
* content(#62): refactor code blocks to use line highlights instead of comments
* fix(#62): make font size consistent on iOS
@@ -283,7 +283,7 @@ With that big picture in mind, let's get into the code to implement this:
283
283
colors={activeCell}
284
284
hideSidebar={hideSidebar}
285
285
isHidden={!showSidebar}
286
-
sidebarRef={sidebarRef} //add this
286
+
sidebarRef={sidebarRef} //highlight-line
287
287
/>
288
288
// ...
289
289
)
@@ -295,14 +295,14 @@ With that big picture in mind, let's get into the code to implement this:
295
295
colors,
296
296
hideSidebar,
297
297
isHidden,
298
-
sidebarRef, //add this
298
+
sidebarRef, //highlight-line
299
299
}) => {
300
300
// ...
301
301
return (
302
302
// ...
303
303
<h1
304
-
ref={sidebarRef} //add this
305
-
tabIndex={-1} //add this
304
+
ref={sidebarRef} //highlight-line
305
+
tabIndex={-1} //highlight-line
306
306
>
307
307
{colors.output}
308
308
</h1>
@@ -324,7 +324,7 @@ With that big picture in mind, let's get into the code to implement this:
324
324
constupdateSidebar= (colors) => {
325
325
setActiveCell(colors)
326
326
setShowSidebar(true)
327
-
sidebarRef.current.focus() //add this
327
+
sidebarRef.current.focus() //highlight-line
328
328
}
329
329
// ...
330
330
}
@@ -384,7 +384,7 @@ Now let's implement this in code:
384
384
1. Create `buttonRef`. Which component should we create it in? Since we want to have a separate `ref` object for each TableCell, let's define `buttonRef` in the TableCell component. That way, each TableCell that mounts will have its own unique `ref` that can be focused independently.
385
385
```javascript
386
386
constTableCell= ({ colors, updateSidebar }) => {
387
-
constbuttonRef=useRef(null) //add this
387
+
constbuttonRef=useRef(null) //highlight-line
388
388
// ...
389
389
}
390
390
```
@@ -396,7 +396,7 @@ Now let's implement this in code:
396
396
<td>
397
397
<button
398
398
onClick={() =>updateSidebar(colors)}
399
-
ref={buttonRef} //add this
399
+
ref={buttonRef} //highlight-line
400
400
>
401
401
{colors.output}
402
402
</button>
@@ -411,7 +411,7 @@ Now let's implement this in code:
@@ -455,7 +454,7 @@ Now let's implement this in code:
455
454
// ...
456
455
consthideSidebar= () => {
457
456
setShowSidebar(false)
458
-
lastCellClicked.current.focus() //add this
457
+
lastCellClicked.current.focus() //highlight-line
459
458
}
460
459
// ...
461
460
}
@@ -585,7 +584,7 @@ In this post, you learned about how to programmatically move a user's focus when
585
584
586
585
The next improvement I'm hoping to make is trapping focus inside the sidebar when it's open. That is, when users have the sidebar open and they repeatedly hit the Tab key, their focus should stay inside of the sidebar and not end up back in the rest of the body of the page. I'm planning on using something like the inert polyfill described in this [A11ycasts YouTube Video: Inert Polyfill](https://www.youtube.com/watch?v=fGLp_gfMMGU).
587
586
588
-
Until then, [reach out to me on Twitter](https://twitter.com/meganesulli) and let me know what you think about this post! I'm by no means an accessibility expert, and I'm always looking for new things to learn. What other opportunities do you see for accessibility improvements, in this project or in general?
587
+
Until then, [reach out to me on Twitter](https://twitter.com/meganesulli) and let me know what you think about this post! I'm always looking for new things to learn. What other opportunities do you see for accessibility improvements, in this project or in general?
0 commit comments