Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preferences UI: Delegate Classnames to Type Renderers #10870

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/editor/src/browser/editor-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const codeEditorPreferenceProperties = {
'description': nls.localizeByDefault('Controls form what documents word based completions are computed.')
},
'editor.semanticHighlighting.enabled': {
'type': ['boolean', 'string'],
'enum': [true, false, 'configuredByTheme'],
'markdownEnumDescriptions': [
nls.localizeByDefault('Semantic highlighting enabled for all color themes.'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class PreferenceBooleanInputRenderer extends PreferenceLeafNodeRenderer<b
parent.appendChild(interactable);
}

protected override getAdditionalNodeClassnames(): Iterable<string> {
return ['boolean'];
}

protected getFallbackValue(): false {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export abstract class PreferenceNodeRenderer implements Disposable, GeneralPrefe

protected abstract createDomNode(): HTMLElement;

protected getAdditionalNodeClassnames(): Iterable<string> {
return [];
}

insertBefore(nextSibling: HTMLElement): void {
nextSibling.insertAdjacentElement('beforebegin', this.domNode);
this.attached = true;
Expand Down Expand Up @@ -247,9 +251,8 @@ export abstract class PreferenceLeafNodeRenderer<ValueType extends JSONValue, In
cog.title = nls.localizeByDefault('More Actions...');
gutter.appendChild(cog);

const activeType = Array.isArray(this.preferenceNode.preference.data.type) ? this.preferenceNode.preference.data.type[0] : this.preferenceNode.preference.data.type;
const contentWrapper = document.createElement('div');
contentWrapper.classList.add('pref-content-container', activeType ?? 'open-json');
contentWrapper.classList.add('pref-content-container', ...this.getAdditionalNodeClassnames());
wrapper.appendChild(contentWrapper);

const { description, markdownDescription } = this.preferenceNode.preference.data;
Expand Down