Skip to content

Commit a721d9e

Browse files
committed
fix(examples): fix unintended errors in examples
1 parent b2b8c32 commit a721d9e

File tree

3 files changed

+60
-27
lines changed

3 files changed

+60
-27
lines changed

src/App.module.css

Lines changed: 22 additions & 7 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 {
@@ -249,9 +253,15 @@ video {
249253
}
250254

251255
.keyboardTrap {
252-
margin: 1rem 0;
253-
padding: 1rem;
254-
border: 1px solid var(--ubilabs-gray-500);
256+
border: 2px solid var(--ubilabs-gray-500);
257+
258+
> div {
259+
padding: 1rem;
260+
261+
&:not(:last-child) {
262+
border-bottom: 1px solid var(--ubilabs-gray-500);
263+
}
264+
}
255265
}
256266

257267
.timingAdjustable {
@@ -308,11 +318,16 @@ video {
308318
}
309319

310320
.flashingBox {
321+
display: flex;
322+
align-items: center;
323+
justify-content: center;
311324
padding: 1rem;
312325
background-color: var(--ubilabs-red-800);
313326
color: var(--ubilabs-white);
327+
font-size: 1.5rem; /* 24px */
314328
font-weight: bold;
315-
text-align: center;
329+
letter-spacing: 0.05em;
330+
text-transform: uppercase;
316331
animation: flashWarning 0.25s infinite; /* 4 flashes per second */
317332
}
318333

@@ -322,7 +337,7 @@ video {
322337
background-color: var(--ubilabs-red-800);
323338
}
324339
50% {
325-
background-color: var(--ubilabs-yellow-800);
340+
background-color: var(--ubilabs-yellow-900);
326341
}
327342
}
328343

@@ -410,7 +425,7 @@ video {
410425
.pointerGestures .secretContent {
411426
width: 13rem;
412427
padding: 1rem;
413-
background-color: var(--ubilabs-yellow-800);
428+
background-color: var(--ubilabs-yellow-900);
414429
color: var(--ubilabs-white);
415430
font-weight: 500;
416431
text-transform: uppercase;

src/App.tsx

Lines changed: 37 additions & 19 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>
@@ -1124,30 +1126,35 @@ function App() {
11241126
<p>Users can navigate to and from all content using a keyboard.</p>
11251127
</header>
11261128

1127-
<div>
1128-
<button>Button before the trap</button>
1129+
<div
1130+
role="menu"
1131+
aria-label="Example Menu"
1132+
className={styles.keyboardTrap}>
1133+
<div role="menuitem" tabIndex={0}>
1134+
Menu item before the trap
1135+
</div>
11291136

11301137
<div
1131-
className={styles.keyboardTrap}
1138+
role="menuitem"
11321139
tabIndex={0}
11331140
onKeyDown={event => {
1134-
// Prevent users from tabbing out of this container
1141+
// Prevent users from tabbing out of this element
11351142
if (event.key === 'Tab') {
11361143
event.preventDefault();
11371144
}
11381145
}}>
1139-
<h4>Keyboard Trap</h4>
1140-
<p>
1146+
Keyboard trap
1147+
<br />
1148+
<small>
11411149
This container traps keyboard focus by blocking the <kbd>Tab</kbd>{' '}
11421150
key.
1143-
</p>
1144-
<button>Keyboard focus is trapped after clicking me</button>
1151+
</small>
11451152
</div>
11461153

1147-
<button>
1148-
Button after the trap <wbr />
1154+
<div role="menuitem" tabIndex={0}>
1155+
Menu item after the trap <wbr />
11491156
(not reachable)
1150-
</button>
1157+
</div>
11511158
</div>
11521159

11531160
<div>
@@ -1472,7 +1479,7 @@ function App() {
14721479
</header>
14731480

14741481
<div className={styles.multipleWays}>
1475-
<nav role="tablist">
1482+
<div role="tablist">
14761483
{MULTIPLE_WAYS_TABS.map((tab, index) => (
14771484
<button
14781485
key={tab}
@@ -1488,7 +1495,7 @@ function App() {
14881495
{tab}
14891496
</button>
14901497
))}
1491-
</nav>
1498+
</div>
14921499

14931500
<div role="tabpanel" tabIndex={0} aria-labelledby={activeTab}>
14941501
<h3>{activeTab}</h3>
@@ -1973,7 +1980,7 @@ function App() {
19731980
<form
19741981
onSubmit={event => {
19751982
event.preventDefault();
1976-
alert('Form auto-!!');
1983+
alert('Form auto-submitted!');
19771984
}}>
19781985
<label>
19791986
<input
@@ -1993,8 +2000,8 @@ function App() {
19932000
<h3>Why this violates the rule</h3>
19942001
<ul>
19952002
<li>
1996-
The form is ! immediately when the checkbox is checked — without
1997-
user confirmation.
2003+
The form is submitted immediately when the checkbox is checked —
2004+
without user confirmation.
19982005
</li>
19992006
<li>
20002007
Users may not expect a form to submit from a checkbox alone.
@@ -2036,7 +2043,7 @@ function App() {
20362043
: ['Services', 'Home', 'Contact', 'About']
20372044
).map(link => (
20382045
<li key={link}>
2039-
<a href="#">{link}</a>
2046+
<a href={`#${link.toLowerCase()}`}>{link}</a>
20402047
</li>
20412048
))}
20422049
</ul>
@@ -2096,6 +2103,12 @@ function App() {
20962103
<dialog ref={consistentIdentificationDialogRef}>
20972104
<p>{consistentIdentificationModalContent}</p>
20982105
<button
2106+
/**
2107+
* It's safe to disable the no-autofocus rule here because:
2108+
* - The button is inside a modal <dialog>, which demands immediate keyboard focus.
2109+
* - This improves accessibility by allowing keyboard and screen reader users to act quickly.
2110+
*/
2111+
// eslint-disable-next-line jsx-a11y/no-autofocus
20992112
autoFocus
21002113
onClick={() => {
21012114
setConsistentIdentificationModalContent(null);
@@ -2140,15 +2153,15 @@ function App() {
21402153
<h3>Page 1</h3>
21412154
<p>Content of page 1</p>
21422155
<div className={styles.helpLinkTopRight}>
2143-
<a href="#">Need help?</a>
2156+
<a href="#help">Need help?</a>
21442157
</div>
21452158
</div>
21462159

21472160
<div className={styles.page}>
21482161
<h3>Page 2</h3>
21492162
<p>Content of page 2</p>
21502163
<div className={styles.helpLinkBottomLeft}>
2151-
<a href="#">Support</a>
2164+
<a href="#support">Support</a>
21522165
</div>
21532166
</div>
21542167
</div>
@@ -2480,6 +2493,11 @@ function App() {
24802493
</header>
24812494

24822495
<div className={styles.nameRoleValue}>
2496+
{/**
2497+
* This is an intentionally inaccessible "checkbox"
2498+
* without role, name, and keyboard support.
2499+
*/}
2500+
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
24832501
<div
24842502
className={styles.checkbox}
24852503
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)