Skip to content

Commit e50a371

Browse files
Home screen keyboard focus (microsoft#10446)
* Addresses the lack of contrast on some of focus-visible highlights on the home screen, as well as making the carousel buttons a single tab stop, which brings it closer to the WAI-ARIA recommendations for tabbed carousels. * Use the focus border color on the home screen
1 parent c8382ef commit e50a371

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

theme/home.less

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,39 @@
9090

9191
.action {
9292
margin: 1rem 0;
93+
a:focus-visible, button:focus-visible {
94+
outline-width: 4px !important;
95+
outline-style: solid;
96+
outline-color: var(--pxt-neutral-stencil3);
97+
}
9398
}
9499

95-
.dots button {
96-
transition: background-color 0.5s;
97-
border: 2px solid @heroBannerDotOutlineColor;
98-
margin-right: 1.25rem;
100+
.dots {
101+
align-self: flex-start;
102+
border-radius: 50px;
103+
line-height: 0;
104+
margin-top: 8px;
105+
106+
&:focus-visible {
107+
outline-width: 3px !important;
108+
outline-style: solid;
109+
outline-color: white;
110+
outline-offset: 4px;
111+
}
112+
113+
button {
114+
transition: background-color 0.5s;
115+
border: 2px solid @heroBannerDotOutlineColor;
116+
margin-right: 1.25rem;
117+
118+
&.active {
119+
border-color: @heroBannerDotOutlineAtiveColor;
120+
background-color: transparent;
121+
}
99122

100-
&.active {
101-
border-color: @heroBannerDotOutlineAtiveColor;
102-
background-color: transparent;
123+
&:last-child {
124+
margin-right: 0px;
125+
}
103126
}
104127
}
105128

@@ -152,6 +175,12 @@
152175
&:hover, &:focus {
153176
border-color: var(--pxt-primary-background);
154177
}
178+
&:focus-visible {
179+
outline-width: @homeCardBorderSize !important;
180+
outline-style: solid;
181+
outline-color: var(--pxt-focus-border);
182+
outline-offset: 2px;
183+
}
155184
}
156185
}
157186
}
@@ -173,6 +202,12 @@
173202
.import-dialog-btn {
174203
position: relative;
175204
z-index: 1; /* Move up so it's above the carousel container that has an offset margin */
205+
&:focus-visible {
206+
outline-width: @homeCardBorderSize !important;
207+
outline-style: solid;
208+
outline-color: var(--pxt-focus-border);
209+
outline-offset: 2px;
210+
}
176211
}
177212
/* Footer, Privary, Terms of Use */
178213
.homefooter {
@@ -350,8 +385,7 @@
350385
transform: translateX(-50%) translateY(-50%);
351386
pointer-events: none;
352387
}
353-
.card-action:hover,
354-
.card-action:focus-within {
388+
.card-action:hover {
355389
cursor: pointer;
356390
border-color: @white;
357391
.ui.button {
@@ -449,7 +483,9 @@
449483
}
450484
.ui.card:focus {
451485
border: 2px solid transparent;
452-
outline: @homeCardBorderSize solid var(--pxt-primary-background) !important;
486+
outline-width: @homeCardBorderSize !important;
487+
outline-style: solid;
488+
outline-color: var(--pxt-focus-border);
453489
}
454490
}
455491

webapp/src/projects.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ class HeroBanner extends data.Component<ISettingsProps, HeroBannerState> {
350350

351351
protected handleRefreshCard = (backwards?: boolean) => {
352352
pxt.debug(`next hero carousel`);
353+
353354
if (this.prevGalleries?.length) {
354355
const cardIndex = this.state.cardIndex;
355356
const nextOffset = backwards ? this.prevGalleries.length - 1 : 1;
@@ -527,6 +528,8 @@ class HeroBanner extends data.Component<ISettingsProps, HeroBannerState> {
527528
return <div className="ui segment getting-started-segment hero"
528529
style={{ backgroundImage: encodedBkgd }}
529530
onKeyDown={this.onKeyDown}
531+
role="region"
532+
aria-label={lf("Banner")}
530533
onPointerDown={this.onPointerDown} onTouchStart={this.onTouchstart}
531534
onPointerUp={this.onPointerUp} onTouchEnd={this.onTouchEnd}
532535
>
@@ -549,9 +552,9 @@ class HeroBanner extends data.Component<ISettingsProps, HeroBannerState> {
549552
this.handleCardClick
550553
)}
551554
</div>}
552-
{isGallery && <div key="cards" className="dots">
555+
{isGallery && <div key="cards" className="dots" tabIndex={0} role="group" aria-label={lf("Carousel controls")}>
553556
{cards.map((card, i) => <button key={"dot" + i} className={`ui button empty circular label clear ${i === cardIndex && "active"}`}
554-
onClick={handleSetCard(i)} aria-label={lf("View {0} hero image", card.title || card.name)} title={lf("View {0} hero image", card.title || card.name)}>
557+
onClick={handleSetCard(i)} aria-label={lf("View {0} hero image", card.title || card.name)} tabIndex={-1} title={lf("View {0} hero image", card.title || card.name)}>
555558
</button>)}
556559
</div>}
557560
</div>

0 commit comments

Comments
 (0)