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:
Vu Nguyen
2021-01-16 19:31:52 -06:00
committed by GitHub
parent 9ecc2144aa
commit d194bcfe60
21 changed files with 660 additions and 10 deletions

View 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,
});
}
}