-
Notifications
You must be signed in to change notification settings - Fork 295
/
StakingWithNavigation.tsx
64 lines (58 loc) · 1.62 KB
/
StakingWithNavigation.tsx
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
// @flow
import React, { Component, createRef } from 'react';
import type { ElementRef, Node } from 'react';
import classnames from 'classnames';
import { observer } from 'mobx-react';
import StakingNavigation from '../navigation/StakingNavigation';
import styles from './StakingWithNavigation.scss';
type Props = {
children?: Node,
activeItem: string,
showInfoTab: boolean,
onNavItemClick: Function,
isActiveNavItem: Function,
};
type ContextValue = {
scrollElementRef: ?ElementRef<*>,
};
export const StakingPageScrollContext = React.createContext<ContextValue>({
scrollElementRef: null,
});
@observer
export default class StakingWithNavigation extends Component<Props> {
stakingPageRef = createRef<*>();
render() {
const {
children,
onNavItemClick,
activeItem,
isActiveNavItem,
showInfoTab,
} = this.props;
const componentStyles = classnames([styles.component, styles[activeItem]]);
return (
<StakingPageScrollContext.Provider
value={{ scrollElementRef: this.stakingPageRef }}
>
<div className={componentStyles}>
<div className={styles.navigation}>
<StakingNavigation
isActiveNavItem={isActiveNavItem}
onNavItemClick={onNavItemClick}
activeItem={activeItem}
showInfoTab={showInfoTab}
/>
</div>
<div
className={styles.page}
ref={(ref) => {
this.stakingPageRef.current = ref;
}}
>
{children}
</div>
</div>
</StakingPageScrollContext.Provider>
);
}
}