1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
import { Component } from 'react';
import { inject, observer } from 'mobx-react';
import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl';
import { mdiClose } from '@mdi/js';
import { Outlet } from 'react-router-dom';
import ErrorBoundary from '../../util/ErrorBoundary';
import Appear from '../../ui/effects/Appear';
import Icon from '../../ui/icon';
import { isEscKeyPress } from '../../../jsUtils';
import { Actions } from '../../../actions/lib/actions';
import { RealStores } from '../../../stores';
const messages = defineMessages({
closeSettings: {
id: 'settings.app.closeSettings',
defaultMessage: 'Close settings',
},
});
interface IProps extends WrappedComponentProps {
actions?: Actions;
stores?: RealStores;
}
@inject('stores', 'actions')
@observer
class ReleaseNotesLayout extends Component<IProps> {
componentDidMount() {
document.addEventListener('keydown', this.handleKeyDown.bind(this), false);
}
componentWillUnmount() {
document.removeEventListener(
'keydown',
// eslint-disable-next-line unicorn/no-invalid-remove-event-listener
this.handleKeyDown.bind(this),
false,
);
}
handleKeyDown(e) {
if (isEscKeyPress(e.keyCode)) {
this.props.actions!.ui.closeSettings();
}
}
render() {
const { closeSettings } = this.props.actions!.ui;
const { intl } = this.props;
return (
<Appear transitionName="fadeIn-fast">
<div className="settings-wrapper">
<ErrorBoundary>
<button
type="button"
className="settings-wrapper__action"
onClick={closeSettings}
aria-label={intl.formatMessage(messages.closeSettings)}
/>
<div className="settings franz-form">
<Outlet />
<button
type="button"
className="settings__close"
onClick={closeSettings}
aria-label={intl.formatMessage(messages.closeSettings)}
>
<Icon icon={mdiClose} size={1.35} />
</button>
</div>
</ErrorBoundary>
</div>
</Appear>
);
}
}
export default injectIntl<'intl', IProps>(ReleaseNotesLayout);
|