@@ -390,38 +390,72 @@ export class ElementProvider implements vscode.TreeDataProvider<any>{
390390 } 
391391
392392
393-  public  adjustBrightness ( item  : Element  |  ElementTreeGroup )  { 
394- 393+  public  async  adjustBrightness ( item  : Element  |  ElementTreeGroup )  { 
395394 if ( item  instanceof  Element ) { 
396395 const  infoProvider  =  getInfoProvider ( ) ; 
397396 infoProvider . updateSelectedElement ( item ) ; 
398397 } 
399398
400-  vscode . window . showQuickPick ( [ "Darken (10%)" ,  "Lighten (10%)" ] ) . then ( ( actionSelection  : any )  =>  { 
401-  if ( actionSelection ) { 
402-  if ( actionSelection  ===  "Darken (10%)" ) { 
403-  darken ( item ,  this ) ; 
404-  } 
405-  if ( actionSelection  ===  "Lighten (10%)" ) { 
406-  lighten ( item ,  this ) ; 
399+  const  darken10  =  "Darken (10%)" ; 
400+  const  lighten10  =  "Lighten (10%)" ; 
401+  const  darkenCustom  =  "Darken (Custom value)" ; 
402+  const  lightenCustom  =  "Lighten (Custom value)" ; 
403+  const  actionSelection  =  await  vscode . window . showQuickPick ( [ darken10 ,  lighten10 ,  darkenCustom ,  lightenCustom ] ) ; 
404+  if ( ! actionSelection )  { 
405+  return ; 
406+  } 
407+  if ( actionSelection  ===  lighten10 )  { 
408+  lighten ( item ,  this ) ; 
409+  } else  if ( actionSelection  ===  darken10 )  { 
410+  darken ( item ,  this ) ; 
411+  } else  if ( actionSelection  ===  lightenCustom )  { 
412+  const  lightenCustomValueNumber  =  await  showPercentInput ( ) ; 
413+  if ( ! lightenCustomValueNumber )  { 
414+  return ; 
415+  } 
416+  lighten ( item ,  this ,  lightenCustomValueNumber ) ; 
417+  } else  if ( actionSelection  ===  darkenCustom )  { 
418+  const  darkenCustomValueNumber  =  await  showPercentInput ( ) ; 
419+  if ( ! darkenCustomValueNumber )  { 
420+  return ; 
421+  } 
422+  darken ( item ,  this ,  darkenCustomValueNumber ) ; 
423+  } 
424+ 425+  async  function  showPercentInput ( )  : Promise < number  |  undefined >  { 
426+  const  percentString  =  await  vscode . window . showInputBox ( { 
427+  prompt : 'Enter a number (Percent)' , 
428+  validateInput ( input  : string )  { 
429+  input  =  removePercentSign ( input ) ; 
430+  const  percentNumber  =  Number ( input ) ; 
431+  if ( ! isNaN ( percentNumber )  &&  isFinite ( percentNumber ) )  { 
432+  return  '' ; 
407433 } 
434+  return  'Value is not a valid number.' ; 
435+  } 
436+  } ) ; 
437+  if ( percentString )  { 
438+  return  Number ( removePercentSign ( percentString ) ) ; 
408439 } 
409-  } ) ; 
440+  } 
410441
442+  function  removePercentSign ( str : string ) : string  { 
443+  return  str . endsWith ( '%' )  ? str . slice ( 0 ,  - 1 )  : str ; 
444+  } 
411445
412-  function  darken ( item  : Element  |  ElementTreeGroup ,  provider  : any )  { 
446+  function  darken ( item  : Element  |  ElementTreeGroup ,  provider  : any , value = 5 )  { 
413447
414448 let  customizations  : WorkbenchCustomizations  =  { } ; 
415449
416450 if ( item  instanceof  Element ) { 
417-  let  darkenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( item . colorConfig ) ) . darken ( 5 ) . toHex ( ) ; 
451+  let  darkenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( item . colorConfig ) ) . darken ( value ) . toHex ( ) ; 
418452 customizations [ item . elementData [ 'fullName' ] ]  =  darkenedValue ; 
419453 } 
420454
421455 if ( item  instanceof  ElementTreeGroup ) { 
422456 for ( let  key  in  item . children ) { 
423457 let  value  =  item . children [ key ] ; 
424-  let  darkenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( value . colorConfig ) ) . darken ( 5 ) . toHex ( ) ; 
458+  let  darkenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( value . colorConfig ) ) . darken ( value ) . toHex ( ) ; 
425459 customizations [ value . elementData [ 'fullName' ] ]  =  darkenedValue ;  
426460 } 
427461 } 
@@ -430,19 +464,19 @@ export class ElementProvider implements vscode.TreeDataProvider<any>{
430464 } 
431465
432466
433-  function  lighten ( item  : Element  |  ElementTreeGroup ,  provider  : any )  { 
467+  function  lighten ( item  : Element  |  ElementTreeGroup ,  provider  : any , value = 5 )  { 
434468
435469 let  customizations  : WorkbenchCustomizations  =  { } ; 
436470
437471 if ( item  instanceof  Element ) { 
438-  let  lightenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( item . colorConfig ) ) . lighten ( 5 ) . toHex ( ) ; 
472+  let  lightenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( item . colorConfig ) ) . lighten ( value ) . toHex ( ) ; 
439473 customizations [ item . elementData [ 'fullName' ] ]  =  lightenedValue ; 
440474 } 
441475
442476 if ( item  instanceof  ElementTreeGroup ) { 
443477 for ( let  key  in  item . children ) { 
444478 let  value  =  item . children [ key ] ; 
445-  let  lightenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( value . colorConfig ) ) . lighten ( 5 ) . toHex ( ) ; 
479+  let  lightenedValue  =  "#"  +  tinycolor ( getEffectiveColor ( value . colorConfig ) ) . lighten ( value ) . toHex ( ) ; 
446480 customizations [ value . elementData [ 'fullName' ] ]  =  lightenedValue ;  
447481 } 
448482 } 
0 commit comments