1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-11 02:13:48 +09:00

Merge pull request #845 from anyproto/feature/theme-shortcut

Theme shortcut
This commit is contained in:
Razor 2024-07-24 11:54:47 +02:00 committed by GitHub
commit 171cfaf2bc
Signed by: github
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 9 deletions

View file

@ -1,6 +1,6 @@
import * as React from 'react';
import { Icon, Title, Label, Switch } from 'Component';
import { I, S, U, translate, analytics, Renderer } from 'Lib';
import { I, S, U, translate, Action, Renderer } from 'Lib';
import { observer } from 'mobx-react';
const PopupSettingsPageAppearance = observer(class PopupSettingsPageAppearance extends React.Component<I.PopupSettings> {
@ -26,7 +26,7 @@ const PopupSettingsPageAppearance = observer(class PopupSettingsPageAppearance e
<div
key={i}
className={[ 'btn', (theme == item.id ? 'active' : ''), item.class ].join(' ')}
onClick={() => this.onTheme(item.id)}
onClick={() => Action.themeSet(item.id)}
>
<div className="bg">
<Icon />
@ -60,12 +60,6 @@ const PopupSettingsPageAppearance = observer(class PopupSettingsPageAppearance e
);
};
onTheme (id: string) {
S.Common.themeSet(id);
Renderer.send('setTheme', id);
analytics.event('ThemeSet', { id });
};
});
export default PopupSettingsPageAppearance;

View file

@ -783,6 +783,12 @@ class Action {
});
};
themeSet (id: string) {
S.Common.themeSet(id);
Renderer.send('setTheme', id);
analytics.event('ThemeSet', { id });
};
};
export default new Action();

View file

@ -113,13 +113,13 @@ class Keyboard {
};
onKeyDown (e: any) {
const { theme } = S.Common;
const isMac = U.Common.isPlatformMac();
const key = e.key.toLowerCase();
const cmd = this.cmdKey();
const isMain = this.isMain();
const canWrite = U.Space.canMyParticipantWrite();
const selection = S.Common.getRef('selectionProvider');
const { spaceview } = S.Block;
this.pressed.push(key);
@ -241,6 +241,11 @@ class Keyboard {
$('#button-header-relation').trigger('click');
});
// Switch dark/light mode
this.shortcut(`${cmd}+shift+m`, e, () => {
Action.themeSet(!theme ? 'dark' : '');
});
// Store
this.shortcut(`${cmd}+alt+l`, e, () => {
U.Object.openRoute({ layout: I.ObjectLayout.Store });