Skip to content
Permalink
Browse files

Habits keyboard shortcuts, partial refactor

- Added mousetrap dependency

- Two simple keybindings have been added, documented in
  docs/keybindings.md. More will be added soon.

- Some Habits components have been given their own file; more will be
  added in the future.
  • Loading branch information...
upvalue committed Jun 25, 2018
1 parent 03f54d0 commit 1023338c3040fe02f011c92063b8d4aa37ea4a62
@@ -0,0 +1,14 @@
### Keybindings

All keybindings are preceded by the letter g, as modifier keys (shift, alt, ctrl) are too often
taken up by browsers.

#### Common

`Esc` Quit modal

#### Habits

`g a` Add new task on current day (only available in the current month)
`g s` Filter by task name

@@ -14,3 +14,13 @@ export const MOUNT_NEXT_DAY_TIME = 4;
* In hours.
*/
export const JOURNAL_ROLLOVER_TIME = 4;

/**
* Keybinding to add a task to the current day. Only available when viewing the current month.
*/
export const KEYSEQ_TASK_ADD = 'g a';

/**
* Mousetrap key sequence that will trigger focus on the filter by name field.
*/
export const KEYSEQ_FILTER_FOCUS = 'g s';
@@ -87,11 +87,15 @@ interface ModalPromptOptions {
checker?: (chk: string) => string;
}

export interface ModalProviderProps {
socketClosed: boolean;
}

/**
* Modal provider handles global modal state. It is also responsible for styling the entire app
* in the case of error notifications or modals.
*/
export class ModalProvider extends React.Component<{ socketClosed: boolean }, ModalState> {
export class ModalProvider extends React.Component<ModalProviderProps, ModalState> {
modalInput?: HTMLInputElement;

constructor(props: any) {
@@ -102,8 +106,19 @@ export class ModalProvider extends React.Component<{ socketClosed: boolean }, Mo
modalType: 'EMPTY',
modalData: null,
};
}

/*
componentWillUpdate(nextProps : ModalProviderProps, nextState: ModalState) {
if (this.state.modalOpen && !nextState.modalOpen) {
mousetrap.unbind(KEYSEQ_MODAL_EXIT);
} else if (!this.state.modalOpen && nextState.modalOpen) {
mousetrap.bindGlobal('escape', () => {
console.log('quit modal');
});
}
}
*/

openModalPrompt(body: string, ok: string, callback: (result: string) => void,
defaultValue?: string, options?: ModalPromptOptions) {
Oops, something went wrong.

0 comments on commit 1023338

Please sign in to comment.
You can’t perform that action at this time.