-
-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom saturation values for icons
- Loading branch information
Showing
13 changed files
with
122 additions
and
36 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
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
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
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
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
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
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,43 @@ | ||
import * as vscode from 'vscode'; | ||
import { getDefaultIconOptions, validateSaturationValue } from '../icons'; | ||
import * as helpers from './../helpers'; | ||
import * as i18n from './../i18n'; | ||
|
||
/** Command to toggle the folder icons. */ | ||
export const changeSaturation = () => { | ||
return getCurrentSaturationValue() | ||
.then(showInput) | ||
.catch(err => console.log(err)); | ||
}; | ||
|
||
/** Show input to enter the saturation value. */ | ||
const showInput = (saturation: number) => { | ||
vscode.window.showInputBox({ | ||
placeHolder: i18n.translate('saturation.inputPlaceholder'), | ||
ignoreFocusOut: true, | ||
value: String(saturation), | ||
validateInput: validateSaturationInput | ||
}).then(value => setSaturationConfig(+value)); | ||
}; | ||
|
||
/** Validate the saturation value which was inserted by the user. */ | ||
const validateSaturationInput = (saturationInput: string) => { | ||
if (!validateSaturationValue(+saturationInput)) { | ||
return i18n.translate('saturation.wrongValue'); | ||
} | ||
return undefined; | ||
}; | ||
|
||
/** Get the current value of the saturation of the icons. */ | ||
export const getCurrentSaturationValue = (): Promise<number> => { | ||
const defaultOptions = getDefaultIconOptions(); | ||
return helpers.getMaterialIconsJSON().then((config) => | ||
config.options.saturation === undefined ? | ||
defaultOptions.saturation : config.options.saturation); | ||
}; | ||
|
||
const setSaturationConfig = (saturation: number) => { | ||
if (saturation !== undefined) { | ||
helpers.setThemeConfig('saturation', saturation, true); | ||
} | ||
}; |
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
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
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
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
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
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