Skip to content

Commit f6a466d

Browse files
committed
a11y: Add opt-in setting to underline links within p elements
1 parent 68ca9a7 commit f6a466d

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

build/lib/stylelint/vscode-known-variables.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@
854854
"--z-index-run-button-container",
855855
"--zoom-factor",
856856
"--test-bar-width",
857-
"--widget-color"
857+
"--widget-color",
858+
"--text-link-decoration"
858859
]
859860
}

src/vs/platform/accessibility/browser/accessibilityService.ts

+29
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export class AccessibilityService extends Disposable implements IAccessibilitySe
2424
protected _systemMotionReduced: boolean;
2525
protected readonly _onDidChangeReducedMotion = new Emitter<void>();
2626

27+
private _linkUnderlinesEnabled: boolean;
28+
protected readonly _onDidChangeLinkUnderline = new Emitter<void>();
29+
2730
constructor(
2831
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
2932
@ILayoutService private readonly _layoutService: ILayoutService,
@@ -50,7 +53,10 @@ export class AccessibilityService extends Disposable implements IAccessibilitySe
5053
this._systemMotionReduced = reduceMotionMatcher.matches;
5154
this._configMotionReduced = this._configurationService.getValue<'auto' | 'on' | 'off'>('workbench.reduceMotion');
5255

56+
this._linkUnderlinesEnabled = this._configurationService.getValue('accessibility.underlineLinks');
57+
5358
this.initReducedMotionListeners(reduceMotionMatcher);
59+
this.initLinkUnderlineListeners();
5460
}
5561

5662
private initReducedMotionListeners(reduceMotionMatcher: MediaQueryList) {
@@ -72,6 +78,29 @@ export class AccessibilityService extends Disposable implements IAccessibilitySe
7278
this._register(this.onDidChangeReducedMotion(() => updateRootClasses()));
7379
}
7480

81+
private initLinkUnderlineListeners() {
82+
this._register(this._configurationService.onDidChangeConfiguration(e => {
83+
if (e.affectsConfiguration('accessibility.underlineLinks')) {
84+
const linkUnderlinesEnabled = this._configurationService.getValue<boolean>('accessibility.underlineLinks');
85+
this._linkUnderlinesEnabled = linkUnderlinesEnabled;
86+
this._onDidChangeLinkUnderline.fire();
87+
}
88+
}));
89+
90+
const updateLinkUnderlineClasses = () => {
91+
const underlineLinks = this._linkUnderlinesEnabled;
92+
this._layoutService.mainContainer.classList.toggle('underline-links', underlineLinks);
93+
};
94+
95+
updateLinkUnderlineClasses();
96+
97+
this._register(this.onDidChangeLinkUnderlines(() => updateLinkUnderlineClasses()));
98+
}
99+
100+
public onDidChangeLinkUnderlines(listener: () => void) {
101+
return this._onDidChangeLinkUnderline.event(listener);
102+
}
103+
75104
get onDidChangeScreenReaderOptimized(): Event<void> {
76105
return this._onDidChangeScreenReaderOptimized.event;
77106
}

src/vs/workbench/browser/media/style.css

+9
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ body.web {
8787
text-decoration: none;
8888
}
8989

90+
91+
.monaco-workbench p > a {
92+
text-decoration: var(--text-link-decoration);
93+
}
94+
95+
.monaco-workbench.underline-links {
96+
--text-link-decoration: underline;
97+
}
98+
9099
.monaco-workbench.hc-black p > a,
91100
.monaco-workbench.hc-light p > a {
92101
text-decoration: underline !important;

src/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration.ts

+5
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,11 @@ const configuration: IConfigurationNode = {
662662
'announcement': 'never'
663663
}
664664
},
665+
'accessibility.underlineLinks': {
666+
'type': 'boolean',
667+
'description': localize('accessibility.underlineLinks', "Controls whether links should be underlined in the workbench."),
668+
'default': false,
669+
},
665670
}
666671
};
667672

0 commit comments

Comments
 (0)