1
1
// @flow
2
2
3
3
import * as React from 'react' ;
4
- import Link from './Link' ;
5
4
import styled from 'styled-components' ;
6
5
import { Spring , Trail } from 'react-spring' ;
7
- import type { User } from '../data/types' ;
6
+ import Link from './Link' ;
7
+ import { linksList } from '../tools/links' ;
8
+ import firstName from '../tools/firstName' ;
9
+ import type { User } from '../tools/types' ;
8
10
9
11
type Props = {
10
12
open : boolean ,
11
13
selectedUser : User ,
12
14
} ;
13
15
14
- const links = [
15
- { href : '/' , name : 'Home' } ,
16
- { href : '/place' , name : 'Places' } ,
17
- { href : '/group' , name : 'Group Trips' } ,
18
- ] ;
19
-
20
16
export default class AppMenuDrawer extends React . Component < Props > {
21
17
render ( ) {
22
18
const { open, selectedUser } = this . props ;
@@ -35,14 +31,14 @@ export default class AppMenuDrawer extends React.Component<Props> {
35
31
< Trail
36
32
from = { { opacity : 0 } }
37
33
to = { { opacity : 1 } }
38
- keys = { links . map ( link => link . name ) }
34
+ keys = { linksList . map ( ( [ href ] ) => href ) }
39
35
delay = { 100 }
40
36
>
41
- { links . map ( link => styles => (
37
+ { linksList . map ( ( [ href , name ] ) => styles => (
42
38
< div style = { styles } >
43
- < Link href = { link . href } color = "white" >
39
+ < Link href = { href } color = "white" >
44
40
{ firstName ( selectedUser . name ) }
45
- 's { link . name }
41
+ 's { name }
46
42
</ Link >
47
43
</ div >
48
44
) ) }
@@ -54,11 +50,6 @@ export default class AppMenuDrawer extends React.Component<Props> {
54
50
}
55
51
}
56
52
57
- function firstName ( input : string ) : string {
58
- const lastIndex = input . lastIndexOf ( ' ' ) ;
59
- return input . substring ( 0 , lastIndex ) ;
60
- }
61
-
62
53
const Drawer = styled . div `
63
54
transform-origin: 100% 0%;
64
55
background: rgba(0, 0, 0, 0.8);
0 commit comments