Es6 cmp migration (#113)
* migrate Alert component * convert Mainlist component * add webpack watch task * update build script for different manifests * add types for api responses * convert changeExtensionIcon * convert inArray, getDomainParts, contains to ts * convert changeExtensionTooltip * convert changeExtensionState to ts
This commit is contained in:
28
src/utils/changeExtensionIcon.ts
Normal file
28
src/utils/changeExtensionIcon.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { browser } from 'webextension-polyfill-ts';
|
||||
import config from '../config';
|
||||
|
||||
type ColorIconTypes = 'gray' | 'red' | 'white' | '';
|
||||
|
||||
/**
|
||||
* It changes the extension icon color.
|
||||
*/
|
||||
export default async function changeExtensionIcon(color?: ColorIconTypes): Promise<void> {
|
||||
if (color) {
|
||||
const path = `./graphics/wakatime-logo-38-${color}.png`;
|
||||
|
||||
await browser.browserAction.setIcon({
|
||||
path: path,
|
||||
});
|
||||
} else {
|
||||
const { theme } = await browser.storage.sync.get({
|
||||
theme: config.theme,
|
||||
});
|
||||
const path =
|
||||
theme === config.theme
|
||||
? './graphics/wakatime-logo-38.png'
|
||||
: './graphics/wakatime-logo-38-white.png';
|
||||
await browser.browserAction.setIcon({
|
||||
path: path,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user