@@ -8,10 +8,9 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
8
8
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar' ;
9
9
import { ButtonBar , ButtonWithDescription , IButtonStyles } from 'vs/base/browser/ui/button/button' ;
10
10
import { ICheckboxStyles , Checkbox } from 'vs/base/browser/ui/toggle/toggle' ;
11
- import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox' ;
11
+ import { IInputBoxStyles , InputBox } from 'vs/base/browser/ui/inputbox/inputBox' ;
12
12
import { Action } from 'vs/base/common/actions' ;
13
13
import { Codicon } from 'vs/base/common/codicons' ;
14
- import { Color } from 'vs/base/common/color' ;
15
14
import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
16
15
import { mnemonicButtonLabel } from 'vs/base/common/labels' ;
17
16
import { Disposable } from 'vs/base/common/lifecycle' ;
@@ -39,6 +38,9 @@ export interface IDialogOptions {
39
38
readonly disableCloseAction ?: boolean ;
40
39
readonly disableDefaultAction ?: boolean ;
41
40
readonly buttonStyles : IButtonStyles ;
41
+ readonly checkboxStyles : ICheckboxStyles ;
42
+ readonly inputBoxStyles : IInputBoxStyles ;
43
+ readonly dialogStyles : IDialogStyles ;
42
44
}
43
45
44
46
export interface IDialogResult {
@@ -47,19 +49,15 @@ export interface IDialogResult {
47
49
readonly values ?: string [ ] ;
48
50
}
49
51
50
- export interface IDialogStyles extends ICheckboxStyles {
51
- readonly dialogForeground ?: Color ;
52
- readonly dialogBackground ?: Color ;
53
- readonly dialogShadow ?: Color ;
54
- readonly dialogBorder ?: Color ;
55
- readonly errorIconForeground ?: Color ;
56
- readonly warningIconForeground ?: Color ;
57
- readonly infoIconForeground ?: Color ;
58
- readonly inputBackground ?: Color ;
59
- readonly inputForeground ?: Color ;
60
- readonly inputBorder ?: Color ;
61
- readonly textLinkForeground ?: Color ;
62
-
52
+ export interface IDialogStyles {
53
+ readonly dialogForeground : string | undefined ;
54
+ readonly dialogBackground : string | undefined ;
55
+ readonly dialogShadow : string | undefined ;
56
+ readonly dialogBorder : string | undefined ;
57
+ readonly errorIconForeground : string | undefined ;
58
+ readonly warningIconForeground : string | undefined ;
59
+ readonly infoIconForeground : string | undefined ;
60
+ readonly textLinkForeground : string | undefined ;
63
61
}
64
62
65
63
interface ButtonMapEntry {
@@ -78,7 +76,6 @@ export class Dialog extends Disposable {
78
76
private readonly checkbox : Checkbox | undefined ;
79
77
private readonly toolbarContainer : HTMLElement ;
80
78
private buttonBar : ButtonBar | undefined ;
81
- private styles : IDialogStyles | undefined ;
82
79
private focusToReturn : HTMLElement | undefined ;
83
80
private readonly inputs : InputBox [ ] ;
84
81
private readonly buttons : string [ ] ;
@@ -140,6 +137,7 @@ export class Dialog extends Disposable {
140
137
const inputBox = this . _register ( new InputBox ( inputRowElement , undefined , {
141
138
placeholder : input . placeholder ,
142
139
type : input . type ?? 'text' ,
140
+ inputBoxStyles : options . inputBoxStyles
143
141
} ) ) ;
144
142
145
143
if ( input . value ) {
@@ -155,7 +153,9 @@ export class Dialog extends Disposable {
155
153
if ( this . options . checkboxLabel ) {
156
154
const checkboxRowElement = this . messageContainer . appendChild ( $ ( '.dialog-checkbox-row' ) ) ;
157
155
158
- const checkbox = this . checkbox = this . _register ( new Checkbox ( this . options . checkboxLabel , ! ! this . options . checkboxChecked ) ) ;
156
+ const checkbox = this . checkbox = this . _register (
157
+ new Checkbox ( this . options . checkboxLabel , ! ! this . options . checkboxChecked , options . checkboxStyles )
158
+ ) ;
159
159
160
160
checkboxRowElement . appendChild ( checkbox . domNode ) ;
161
161
@@ -166,6 +166,8 @@ export class Dialog extends Disposable {
166
166
167
167
const toolbarRowElement = this . element . appendChild ( $ ( '.dialog-toolbar-row' ) ) ;
168
168
this . toolbarContainer = toolbarRowElement . appendChild ( $ ( '.dialog-toolbar' ) ) ;
169
+
170
+ this . applyStyles ( ) ;
169
171
}
170
172
171
173
private getIconAriaLabel ( ) : string {
@@ -391,7 +393,7 @@ export class Dialog extends Disposable {
391
393
} ) ;
392
394
} ) ) ;
393
395
394
- actionBar . push ( action , { icon : true , label : false , } ) ;
396
+ actionBar . push ( action , { icon : true , label : false } ) ;
395
397
}
396
398
397
399
this . applyStyles ( ) ;
@@ -416,60 +418,47 @@ export class Dialog extends Disposable {
416
418
}
417
419
418
420
private applyStyles ( ) {
419
- if ( this . styles ) {
420
- const style = this . styles ;
421
-
422
- const fgColor = style . dialogForeground ;
423
- const bgColor = style . dialogBackground ;
424
- const shadowColor = style . dialogShadow ? `0 0px 8px ${ style . dialogShadow } ` : '' ;
425
- const border = style . dialogBorder ? `1px solid ${ style . dialogBorder } ` : '' ;
426
- const linkFgColor = style . textLinkForeground ;
427
-
428
- this . shadowElement . style . boxShadow = shadowColor ;
429
-
430
- this . element . style . color = fgColor ?. toString ( ) ?? '' ;
431
- this . element . style . backgroundColor = bgColor ?. toString ( ) ?? '' ;
432
- this . element . style . border = border ;
421
+ const style = this . options . dialogStyles ;
433
422
434
- this . checkbox ?. style ( style ) ;
423
+ const fgColor = style . dialogForeground ;
424
+ const bgColor = style . dialogBackground ;
425
+ const shadowColor = style . dialogShadow ? `0 0px 8px ${ style . dialogShadow } ` : '' ;
426
+ const border = style . dialogBorder ? `1px solid ${ style . dialogBorder } ` : '' ;
427
+ const linkFgColor = style . textLinkForeground ;
435
428
436
- if ( fgColor && bgColor ) {
437
- const messageDetailColor = fgColor . transparent ( .9 ) ;
438
- this . messageDetailElement . style . color = messageDetailColor . makeOpaque ( bgColor ) . toString ( ) ;
439
- }
429
+ this . shadowElement . style . boxShadow = shadowColor ;
440
430
441
- if ( linkFgColor ) {
442
- for ( const el of this . messageContainer . getElementsByTagName ( 'a' ) ) {
443
- el . style . color = linkFgColor . toString ( ) ;
444
- }
445
- }
431
+ this . element . style . color = fgColor ?. toString ( ) ?? '' ;
432
+ this . element . style . backgroundColor = bgColor ?. toString ( ) ?? '' ;
433
+ this . element . style . border = border ;
446
434
447
- let color ;
448
- switch ( this . options . type ) {
449
- case 'error' :
450
- color = style . errorIconForeground ;
451
- break ;
452
- case 'warning' :
453
- color = style . warningIconForeground ;
454
- break ;
455
- default :
456
- color = style . infoIconForeground ;
457
- break ;
458
- }
459
- if ( color ) {
460
- this . iconElement . style . color = color . toString ( ) ;
461
- }
435
+ // TODO fix
436
+ // if (fgColor && bgColor) {
437
+ // const messageDetailColor = fgColor.transparent(.9);
438
+ // this.messageDetailElement.style.mixBlendMode = messageDetailColor.makeOpaque(bgColor).toString();
439
+ // }
462
440
463
- for ( const input of this . inputs ) {
464
- input . style ( style ) ;
441
+ if ( linkFgColor ) {
442
+ for ( const el of this . messageContainer . getElementsByTagName ( 'a' ) ) {
443
+ el . style . color = linkFgColor ;
465
444
}
466
445
}
467
- }
468
446
469
- style ( style : IDialogStyles ) : void {
470
- this . styles = style ;
471
-
472
- this . applyStyles ( ) ;
447
+ let color ;
448
+ switch ( this . options . type ) {
449
+ case 'error' :
450
+ color = style . errorIconForeground ;
451
+ break ;
452
+ case 'warning' :
453
+ color = style . warningIconForeground ;
454
+ break ;
455
+ default :
456
+ color = style . infoIconForeground ;
457
+ break ;
458
+ }
459
+ if ( color ) {
460
+ this . iconElement . style . color = color ;
461
+ }
473
462
}
474
463
475
464
override dispose ( ) : void {
0 commit comments