Browse Source

fixed sidebar animation

Skylsmoi 6 years ago
parent
commit
cc9d3e26ba

+ 1 - 1
src/component/Workspace/Folder.jsx View File

@@ -31,7 +31,7 @@ class Folder extends React.Component {
31 31
           </div>
32 32
           <div className='folder__header__name'>
33 33
             <div className='folder__header__name__icon'>
34
-              <i className='fa fa-folder-open-o' />
34
+              <i className={classnames('fa', {'fa-folder-open-o': this.state.open, 'fa-folder-o': !this.state.open})} />
35 35
             </div>
36 36
             <div className='folder__header__name__text'>
37 37
               { title }

+ 1 - 0
src/container/Account.jsx View File

@@ -46,6 +46,7 @@ class Account extends React.Component {
46 46
 
47 47
   componentDidUpdate () {
48 48
     const { user, workspaceList, dispatch } = this.props
49
+
49 50
     if (user.id !== -1 && workspaceList.length > 0 && workspaceList.some(ws => ws.role === undefined)) dispatch(getUserRole(user))
50 51
   }
51 52
 

+ 4 - 1
src/container/Sidebar.jsx View File

@@ -16,19 +16,22 @@ class Sidebar extends React.Component {
16 16
     super(props)
17 17
     this.state = {
18 18
       sidebarClose: false,
19
-      workspaceIdInUrl: parseInt(props.match.params.idws)
19
+      workspaceIdInUrl: props.match.params.idws ? parseInt(props.match.params.idws) : null
20 20
     }
21 21
   }
22 22
 
23 23
   componentDidMount () {
24 24
     const { workspaceIdInUrl } = this.state
25 25
     const { user, workspaceList, dispatch } = this.props
26
+
26 27
     user.id !== -1 && workspaceList.length === 0 && dispatch(getWorkspaceList(user.id, workspaceIdInUrl))
27 28
   }
28 29
 
29 30
   componentDidUpdate (prevProps, prevState) {
30 31
     const { user, match, dispatch } = this.props
31 32
 
33
+    if (this.state.workspaceIdInUrl === null) return
34
+
32 35
     const newWorkspaceId = parseInt(match.params.idws)
33 36
     prevState.workspaceIdInUrl !== newWorkspaceId && this.setState({workspaceIdInUrl: newWorkspaceId})
34 37
 

+ 2 - 2
src/css/Folder.styl View File

@@ -13,7 +13,7 @@ border-style = 1px solid darkBlue
13 13
   border border-style
14 14
   &.item-last
15 15
     border-bottom border-style
16
-// @TODO the very last line of file or folder has to be added a border bottom in js
16
+// @Info: the very last line of file or folder has it's border bottom added in js
17 17
 // -----------------------------------------------------
18 18
 
19 19
 folderclose()
@@ -25,7 +25,7 @@ folderopen()
25 25
   height 100%
26 26
   opacity 1
27 27
   visibility visible
28
-  transition opacity 1s
28
+  transition opacity 0.3s
29 29
 
30 30
 .folder
31 31
   padding-left 30px

+ 9 - 10
src/css/Sidebar.styl View File

@@ -20,6 +20,7 @@
20 20
   z-index 1
21 21
 
22 22
 sidebar-width = 300px
23
+sidebar-animate-speed = 0.5s
23 24
 
24 25
 leftside()
25 26
   flex-grow 0
@@ -29,16 +30,15 @@ leftside()
29 30
 
30 31
 .sidebar
31 32
   position relative
32
-  transition all 0.5s
33
-  width 300px
33
+  transition all sidebar-animate-speed
34
+  width sidebar-width
34 35
   &.sidebarclose
35 36
     width 0
36
-    transform translateX("-%s" % sidebar-width)
37 37
     .sidebar__expand
38
-      right "calc(-%s - 39px)" % sidebar-width
38
+      border-bottom-right-radius 0
39 39
   &__expand
40 40
     position absolute
41
-    top 0
41
+    top -1px
42 42
     right -39px
43 43
     padding 5px 8px
44 44
     border 1px solid white
@@ -46,22 +46,21 @@ leftside()
46 46
     cursor pointer
47 47
     background-color blue
48 48
     color white
49
-    transition all 0.5s
49
+    transition all sidebar-animate-speed
50 50
   &__btnnewworkspace
51
-    margin-top 40px
52
-    padding 10px
53
-    width 100%
51
+    margin-top 50px
52
+    overflow hidden
54 53
     &__btn
55 54
       display block
56 55
       margin 0 auto
57 56
       padding 15px 30px
58 57
   &__navigation
59 58
     padding 0
59
+    overflow hidden
60 60
     &__workspace
61 61
       padding-left 0
62 62
       list-style none
63 63
       &__item
64
-        width sidebar-width
65 64
         &__wrapper
66 65
           display flex
67 66
           align-items center