@@ -2,7 +2,6 @@ import { FileContext } from "@githubnext/blocks";
2
2
import {
3
3
GitCommitIcon ,
4
4
SidebarCollapseIcon ,
5
- SidebarExpandIcon ,
6
5
XCircleIcon ,
7
6
} from "@primer/octicons-react" ;
8
7
import { Avatar , Box , IconButton , Text , Timeline } from "@primer/react" ;
@@ -11,7 +10,8 @@ import { getRelativeTime } from "lib/date-utils";
11
10
import { useSession } from "next-auth/react" ;
12
11
import Link from "next/link" ;
13
12
import { useRouter } from "next/router" ;
14
- import { useState } from "react" ;
13
+ import { useHistoryPane } from "state" ;
14
+ import { Tooltip } from "./Tooltip" ;
15
15
16
16
type ActivityFeedProps = {
17
17
context : Omit < FileContext , "file" > ;
@@ -31,100 +31,100 @@ export const ActivityFeed = ({
31
31
blockType,
32
32
} : ActivityFeedProps ) => {
33
33
const session = useSession ( ) ;
34
-
35
- const [ open , setOpen ] = useState ( true ) ;
34
+ const { toggle } = useHistoryPane ( ) ;
36
35
37
36
return (
38
- < div
39
- className = { `h-full transition-width overflow-hidden ${
40
- open ? "w-80" : "w-12"
41
- } `}
42
- >
43
- < div className = { `h-full overflow-y-auto w-80 duration-200` } >
44
- < div className = "flex flex-col h-full" >
45
- < Box
46
- bg = "canvas.subtle"
47
- borderBottom = "1px solid"
48
- display = "flex"
49
- alignItems = "center"
50
- p = { 2 }
51
- borderColor = "border.muted"
52
- flex = "none"
53
- >
37
+ < div className = { `h-full overflow-hidden` } >
38
+ < div className = "flex flex-col h-full" >
39
+ < Box
40
+ bg = "canvas.subtle"
41
+ borderBottom = "1px solid"
42
+ display = "flex"
43
+ alignItems = "center"
44
+ p = { 2 }
45
+ borderColor = "border.muted"
46
+ flex = "none"
47
+ className = "h-panelHeader flex-shrink-0"
48
+ >
49
+ < Tooltip placement = "top" label = "Close Commits Pane" >
54
50
< IconButton
55
- icon = { open ? SidebarCollapseIcon : SidebarExpandIcon }
56
- onClick = { ( ) => setOpen ( ! open ) }
51
+ icon = { SidebarCollapseIcon }
52
+ onClick = { toggle }
57
53
sx = { { mr : 2 } }
58
- title = { open ? "Hide history" : "Show history "}
54
+ title = { "Close Commits Pane "}
59
55
/>
60
- < Box
61
- sx = { { fontWeight : "bold" , display : "flex" , alignItems : "center" } }
62
- >
63
- < div className = "flex-none" >
64
- Commits { blockType ? `for this ${ blockType } ` : "" }
65
- </ div >
66
- </ Box >
56
+ </ Tooltip >
57
+ < Box
58
+ sx = { {
59
+ fontWeight : "bold" ,
60
+ display : "flex" ,
61
+ alignItems : "center" ,
62
+ } }
63
+ >
64
+ < div className = "flex-none" >
65
+ Commits { blockType ? `for this ${ blockType } ` : "" }
66
+ </ div >
67
67
</ Box >
68
+ </ Box >
68
69
69
- < Box className = "relative" >
70
- { ! open && < div className = "absolute inset-0 bg-white z-10" > </ div > }
71
- { timeline && (
72
- < LayoutGroup >
73
- < Timeline >
74
- < AnimatePresence initial = { false } >
75
- { updatedContent && (
76
- < motion . div
77
- layoutId = "ghost-commit"
78
- key = "ghost-commit"
79
- className = "z-10"
80
- >
81
- < Commit
82
- username = { session . data . user ?. name }
83
- message = { "Working changes" }
84
- isSelected = { context . sha === branchName }
85
- onClickRef = { branchName }
86
- onRemove = { clearUpdatedContent }
87
- />
88
- </ motion . div >
89
- ) }
90
- </ AnimatePresence >
91
- { timeline . map ( ( item , index ) => {
92
- // When `context.sha === branchName` (i.e. `fileRef` is empty or
93
- // set to `branchName`) we show the current version of the file.
94
- // If there is updated content for the file, the current version
95
- // is the ghost commit; otherwise it is the tip of the selected
96
- // branch.
97
- //
98
- // To make it easier to compare an older version of a file against
99
- // the current version, clicking the selected version takes you to
100
- // the current version (so you can swap between them with repeated
101
- // clicks).
70
+ < Box className = "relative flex-1 overflow-auto " >
71
+ { ! open && < div className = "absolute inset-0 bg-white z-10" > </ div > }
72
+ { timeline && (
73
+ < LayoutGroup >
74
+ < Timeline >
75
+ < AnimatePresence initial = { false } >
76
+ { updatedContent && (
77
+ < motion . div
78
+ layoutId = "ghost-commit"
79
+ key = "ghost-commit"
80
+ className = "z-10"
81
+ >
82
+ < Commit
83
+ username = { session . data . user ?. name }
84
+ message = { "Working changes" }
85
+ isSelected = { context . sha === branchName }
86
+ onClickRef = { branchName }
87
+ onRemove = { clearUpdatedContent }
88
+ />
89
+ </ motion . div >
90
+ ) }
91
+ </ AnimatePresence >
92
+ { timeline . map ( ( item , index ) => {
93
+ // When `context.sha === branchName` (i.e. `fileRef` is empty or
94
+ // set to `branchName`) we show the current version of the file.
95
+ // If there is updated content for the file, the current version
96
+ // is the ghost commit; otherwise it is the tip of the selected
97
+ // branch.
98
+ //
99
+ // To make it easier to compare an older version of a file against
100
+ // the current version, clicking the selected version takes you to
101
+ // the current version (so you can swap between them with repeated
102
+ // clicks).
102
103
103
- const isCurrent = index === 0 && ! updatedContent ;
104
+ const isCurrent = index === 0 && ! updatedContent ;
104
105
105
- const isSelected =
106
- item . sha === context . sha ||
107
- ( isCurrent && context . sha === branchName ) ;
106
+ const isSelected =
107
+ item . sha === context . sha ||
108
+ ( isCurrent && context . sha === branchName ) ;
108
109
109
- const onClickRef =
110
- isSelected || isCurrent ? branchName : item . sha ;
110
+ const onClickRef =
111
+ isSelected || isCurrent ? branchName : item . sha ;
111
112
112
- return (
113
- < motion . div layout layoutId = { item . sha } key = { item . sha } >
114
- < Commit
115
- { ...item }
116
- onClickRef = { onClickRef }
117
- isSelected = { isSelected }
118
- key = { item . sha }
119
- />
120
- </ motion . div >
121
- ) ;
122
- } ) }
123
- </ Timeline >
124
- </ LayoutGroup >
125
- ) }
126
- </ Box >
127
- </ div >
113
+ return (
114
+ < motion . div layout layoutId = { item . sha } key = { item . sha } >
115
+ < Commit
116
+ { ...item }
117
+ onClickRef = { onClickRef }
118
+ isSelected = { isSelected }
119
+ key = { item . sha }
120
+ />
121
+ </ motion . div >
122
+ ) ;
123
+ } ) }
124
+ </ Timeline >
125
+ </ LayoutGroup >
126
+ ) }
127
+ </ Box >
128
128
</ div >
129
129
</ div >
130
130
) ;
0 commit comments