Skip to content

Commit d1e4736

Browse files
committed
fix(examples): fix unintended errors in examples
1 parent 0a0f539 commit d1e4736

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
lines changed

src/App.module.css

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ video {
143143
flex-direction: column;
144144
gap: 0.25rem;
145145
align-items: start;
146+
147+
button {
148+
margin-top: 0.5rem;
149+
}
146150
}
147151

148152
.useOfColor tr > *:first-child {
@@ -155,7 +159,7 @@ video {
155159
}
156160

157161
.audioControlHint {
158-
color: var(--ubilabs-text-secondary-color);
162+
color: var(--ubilabs-font-secondary-color);
159163
}
160164

161165
.contrastMinimum {
@@ -308,11 +312,16 @@ video {
308312
}
309313

310314
.flashingBox {
315+
display: flex;
316+
align-items: center;
317+
justify-content: center;
311318
padding: 1rem;
312319
background-color: var(--ubilabs-red-800);
313320
color: var(--ubilabs-white);
321+
font-size: 1.5rem; /* 24px */
314322
font-weight: bold;
315-
text-align: center;
323+
letter-spacing: 0.05em;
324+
text-transform: uppercase;
316325
animation: flashWarning 0.25s infinite; /* 4 flashes per second */
317326
}
318327

@@ -322,7 +331,7 @@ video {
322331
background-color: var(--ubilabs-red-800);
323332
}
324333
50% {
325-
background-color: var(--ubilabs-yellow-800);
334+
background-color: var(--ubilabs-yellow-900);
326335
}
327336
}
328337

@@ -410,7 +419,7 @@ video {
410419
.pointerGestures .secretContent {
411420
width: 13rem;
412421
padding: 1rem;
413-
background-color: var(--ubilabs-yellow-800);
422+
background-color: var(--ubilabs-yellow-900);
414423
color: var(--ubilabs-white);
415424
font-weight: 500;
416425
text-transform: uppercase;

src/App.tsx

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,8 @@ function App() {
681681

682682
<label htmlFor="tel">Phone Number</label>
683683
<input id="tel" type="tel" />
684+
685+
<button type="submit">Submit</button>
684686
</form>
685687

686688
<div>
@@ -1127,22 +1129,24 @@ function App() {
11271129
<div>
11281130
<button>Button before the trap</button>
11291131

1130-
<div
1132+
<details
11311133
className={styles.keyboardTrap}
1132-
tabIndex={0}
11331134
onKeyDown={event => {
11341135
// Prevent users from tabbing out of this container
11351136
if (event.key === 'Tab') {
11361137
event.preventDefault();
11371138
}
1138-
}}>
1139-
<h4>Keyboard Trap</h4>
1139+
}}
1140+
open>
1141+
<summary>
1142+
<h4>Keyboard Trap</h4>
1143+
</summary>
11401144
<p>
11411145
This container traps keyboard focus by blocking the <kbd>Tab</kbd>{' '}
11421146
key.
11431147
</p>
11441148
<button>Keyboard focus is trapped after clicking me</button>
1145-
</div>
1149+
</details>
11461150

11471151
<button>
11481152
Button after the trap <wbr />
@@ -1472,7 +1476,7 @@ function App() {
14721476
</header>
14731477

14741478
<div className={styles.multipleWays}>
1475-
<nav role="tablist">
1479+
<div role="tablist">
14761480
{MULTIPLE_WAYS_TABS.map((tab, index) => (
14771481
<button
14781482
key={tab}
@@ -1488,7 +1492,7 @@ function App() {
14881492
{tab}
14891493
</button>
14901494
))}
1491-
</nav>
1495+
</div>
14921496

14931497
<div role="tabpanel" tabIndex={0} aria-labelledby={activeTab}>
14941498
<h3>{activeTab}</h3>
@@ -1973,7 +1977,7 @@ function App() {
19731977
<form
19741978
onSubmit={event => {
19751979
event.preventDefault();
1976-
alert('Form auto-!!');
1980+
alert('Form auto-submitted!');
19771981
}}>
19781982
<label>
19791983
<input
@@ -1993,8 +1997,8 @@ function App() {
19931997
<h3>Why this violates the rule</h3>
19941998
<ul>
19951999
<li>
1996-
The form is ! immediately when the checkbox is checked — without
1997-
user confirmation.
2000+
The form is submitted immediately when the checkbox is checked —
2001+
without user confirmation.
19982002
</li>
19992003
<li>
20002004
Users may not expect a form to submit from a checkbox alone.
@@ -2036,7 +2040,7 @@ function App() {
20362040
: ['Services', 'Home', 'Contact', 'About']
20372041
).map(link => (
20382042
<li key={link}>
2039-
<a href="#">{link}</a>
2043+
<a href={`#${link.toLowerCase()}`}>{link}</a>
20402044
</li>
20412045
))}
20422046
</ul>
@@ -2096,6 +2100,13 @@ function App() {
20962100
<dialog ref={consistentIdentificationDialogRef}>
20972101
<p>{consistentIdentificationModalContent}</p>
20982102
<button
2103+
/**
2104+
* It's safe to disable the no-autofocus rule here because:
2105+
* - The button is inside a modal <dialog>, which demands immediate keyboard focus.
2106+
* - This improves accessibility by allowing keyboard and screen reader users to act quickly.
2107+
*
2108+
* eslint-disable-next-line jsx-a11y/no-autofocus
2109+
*/
20992110
autoFocus
21002111
onClick={() => {
21012112
setConsistentIdentificationModalContent(null);
@@ -2140,15 +2151,15 @@ function App() {
21402151
<h3>Page 1</h3>
21412152
<p>Content of page 1</p>
21422153
<div className={styles.helpLinkTopRight}>
2143-
<a href="#">Need help?</a>
2154+
<a href="#help">Need help?</a>
21442155
</div>
21452156
</div>
21462157

21472158
<div className={styles.page}>
21482159
<h3>Page 2</h3>
21492160
<p>Content of page 2</p>
21502161
<div className={styles.helpLinkBottomLeft}>
2151-
<a href="#">Support</a>
2162+
<a href="#support">Support</a>
21522163
</div>
21532164
</div>
21542165
</div>
@@ -2480,6 +2491,12 @@ function App() {
24802491
</header>
24812492

24822493
<div className={styles.nameRoleValue}>
2494+
{/**
2495+
* This is an intentionally inaccessible "checkbox"
2496+
* without role, name, and keyboard support.
2497+
*
2498+
* jsx-a11y/click-events-have-key-events
2499+
*/}
24832500
<div
24842501
className={styles.checkbox}
24852502
onClick={() => setIsChecked(prevState => !prevState)}

src/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
--ubilabs-green-800: #1e8250;
1212
--ubilabs-red: #ff6e78;
1313
--ubilabs-red-800: #cd3c50;
14-
--ubilabs-yellow-800: #cd9128;
14+
--ubilabs-yellow-900: #b47819;
1515

1616
--ubilabs-font-color: var(--ubilabs-white);
1717
--ubilabs-font-secondary-color: var(--ubilabs-gray-500);

0 commit comments

Comments
 (0)