mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-28 00:35:25 +08:00
Added commands to add/remove the current theme to favorites (#3682) varunKT001
* Added 'Add current theme to favorite...' command * Remove toggle for 'Add current theme to favorite...' command * Added 'Remove current theme from favorite...' command * Merge add/remove commands in a single file * removed dots * updated icon * only showing favorite commands if custom theme is disabled Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
parent
6adbdb19fd
commit
1afca8204a
2 changed files with 36 additions and 0 deletions
|
@ -65,6 +65,7 @@ import ResultSavingCommands from "./lists/result-saving";
|
|||
import NavigationCommands from "./lists/navigation";
|
||||
import FontSizeCommands from "./lists/font-size";
|
||||
import ResultScreenCommands from "./lists/result-screen";
|
||||
import AddOrRemoveThemeToFavorite from "./lists/add-or-remove-theme-to-favorites";
|
||||
|
||||
import TagsCommands from "./lists/tags";
|
||||
import CustomThemesListCommands from "./lists/custom-themes-list";
|
||||
|
@ -248,6 +249,7 @@ export const commands: MonkeyTypes.CommandsSubgroup = {
|
|||
...CustomThemesListCommands,
|
||||
...FlipTestColorsCommands,
|
||||
...ColorfulModeCommands,
|
||||
...AddOrRemoveThemeToFavorite,
|
||||
{
|
||||
id: "changeCustomBackground",
|
||||
display: "Custom background...",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
import Config, * as UpdateConfig from "../../config";
|
||||
|
||||
const commands: MonkeyTypes.Command[] = [
|
||||
{
|
||||
id: "addThemeToFavorite",
|
||||
display: "Add current theme to favorite",
|
||||
icon: "fa-heart",
|
||||
available: (): boolean => {
|
||||
return !Config.customTheme && !Config.favThemes.includes(Config.theme);
|
||||
},
|
||||
exec: (): void => {
|
||||
const { theme, favThemes, customTheme } = Config;
|
||||
if (!customTheme && !favThemes.includes(theme)) {
|
||||
UpdateConfig.setFavThemes([...favThemes, theme]);
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "removeThemeFromFavorite",
|
||||
display: "Remove current theme from favorite",
|
||||
icon: "fa-heart-broken",
|
||||
available: (): boolean => {
|
||||
return !Config.customTheme && Config.favThemes.includes(Config.theme);
|
||||
},
|
||||
exec: (): void => {
|
||||
const { theme, favThemes, customTheme } = Config;
|
||||
if (!customTheme && favThemes.includes(theme)) {
|
||||
UpdateConfig.setFavThemes([...favThemes.filter((t) => t !== theme)]);
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default commands;
|
Loading…
Reference in a new issue