-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Input box and checkbox list (#45589)
- Loading branch information
Showing
4 changed files
with
282 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,10 @@ | |
margin-left: -300px; | ||
} | ||
|
||
.quick-input-box { | ||
margin: 6px; | ||
} | ||
|
||
.quick-input-actions { | ||
padding: 3px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/vs/workbench/browser/parts/quickinput/quickInputBox.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
import 'vs/css!./quickInput'; | ||
import * as dom from 'vs/base/browser/dom'; | ||
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox'; | ||
import * as nls from 'vs/nls'; | ||
import { inputBackground, inputForeground, inputBorder } from 'vs/platform/theme/common/colorRegistry'; | ||
import { ITheme } from 'vs/platform/theme/common/themeService'; | ||
import { IDisposable } from 'vs/base/common/lifecycle'; | ||
|
||
const $ = dom.$; | ||
|
||
const DEFAULT_INPUT_ARIA_LABEL = nls.localize('quickInputBoxAriaLabel', "Type to narrow down results."); | ||
|
||
export class QuickInputBox { | ||
|
||
public container: HTMLElement; | ||
private inputBox: InputBox; | ||
|
||
constructor( | ||
private parent: HTMLElement | ||
) { | ||
this.container = dom.append(this.parent, $('.quick-input-box')); | ||
this.inputBox = new InputBox(this.container, null, { | ||
ariaLabel: DEFAULT_INPUT_ARIA_LABEL | ||
}); | ||
|
||
// ARIA | ||
const inputElement = this.inputBox.inputElement; | ||
inputElement.setAttribute('role', 'combobox'); | ||
inputElement.setAttribute('aria-haspopup', 'false'); | ||
inputElement.setAttribute('aria-autocomplete', 'list'); | ||
} | ||
|
||
onInput(handler: (event: string) => void): IDisposable { | ||
return this.inputBox.onDidChange(handler); | ||
} | ||
|
||
setPlaceholder(placeholder: string) { | ||
this.inputBox.setPlaceHolder(placeholder); | ||
} | ||
|
||
setFocus(): void { | ||
this.inputBox.focus(); | ||
} | ||
|
||
layout(): void { | ||
this.inputBox.layout(); | ||
} | ||
|
||
style(theme: ITheme) { | ||
this.inputBox.style({ | ||
inputForeground: theme.getColor(inputForeground), | ||
inputBackground: theme.getColor(inputBackground), | ||
inputBorder: theme.getColor(inputBorder) | ||
}); | ||
} | ||
} |
Oops, something went wrong.