1
1
import { Tab , Tabs } from "@heroui/tabs" ;
2
2
import { useSearchParams } from "react-router-dom" ;
3
- import { useEffect , useState } from "react" ;
3
+ import { useEffect , useRef , useState } from "react" ;
4
4
import { Repository } from "@/types.ts" ;
5
5
import { Badge } from "@heroui/react" ;
6
+ import {
7
+ BugIcon ,
8
+ ChatIcon , FileIcon ,
9
+ IconWrapper ,
10
+ LayoutIcon ,
11
+ PlayCircleIcon ,
12
+ PullRequestIcon ,
13
+ SettingIcon , WikiIcon
14
+ } from "@/app/repo/Repo.Icons.tsx" ;
6
15
7
16
export const RepoHeader = ( props : { setTab : ( arg0 : string ) => void , info : Repository , owner : string , repo : string } ) => {
8
17
const [ Query , setQuery ] = useSearchParams ( ) ;
9
18
const [ Tabes , setTab ] = useState ( "file" ) ;
19
+ const State = useRef ( false ) ;
10
20
useEffect ( ( ) => {
21
+ if ( State . current ) return ;
11
22
if ( ! Query . get ( "tab" ) ) {
12
23
Query . set ( "tab" , "file" )
13
24
setQuery ( Query )
14
25
setTab ( "file" )
15
26
props . setTab ( "file" )
27
+ State . current = true
16
28
} else {
17
29
setTab ( Query . get ( "tab" ) as string )
18
30
props . setTab ( Query . get ( "tab" ) as string )
31
+ State . current = true
19
32
}
20
- } , [ Query , props , setQuery ] )
33
+ } , [ props ] )
34
+ useEffect ( ( ) => {
35
+ setTab ( Query . get ( "tab" ) as string )
36
+ props . setTab ( Query . get ( "tab" ) as string )
37
+ } , [ Query , State , props , setQuery ] )
21
38
return (
22
39
< div className = "repo-header" >
23
40
< div className = "repo-header-tab" >
@@ -27,28 +44,101 @@ export const RepoHeader = (props: { setTab: (arg0: string) => void, info: Reposi
27
44
setQuery ( Query )
28
45
props . setTab ( x . toString ( ) )
29
46
} } selectedKey = { Tabes } >
30
- < Tab key = "file" title = "File" />
31
- < Tab key = "wiki" title = "wiki" />
47
+ < Tab key = "file" title = {
48
+ < div style = { {
49
+ display : "flex"
50
+ } } >
51
+ < IconWrapper className = "bg-cyan-100 text-success" >
52
+ < FileIcon className = "text-lg " />
53
+ </ IconWrapper >
54
+ < span style = { {
55
+ padding : "3px"
56
+ } } > Files</ span >
57
+ </ div >
58
+ } />
59
+ < Tab key = "wiki" title = {
60
+ < div style = { {
61
+ display : "flex"
62
+ } } >
63
+ < IconWrapper className = "bg-white text-foreground" >
64
+ < WikiIcon className = "text-lg " />
65
+ </ IconWrapper >
66
+ < span style = { {
67
+ padding : "3px"
68
+ } } > Wiki</ span >
69
+ </ div >
70
+ } />
32
71
< Tab key = "issues" title = {
33
72
< Badge color = "primary" placement = { "top-right" } content = { props . info . nums_issue } size = "sm" >
34
- < span style = { {
35
- padding : "3px"
36
- } } > issues</ span >
73
+
74
+ < IconWrapper className = "bg-success/10 text-success" >
75
+ < BugIcon className = "text-lg " />
76
+ </ IconWrapper >
77
+ < span style = { {
78
+ padding : "3px"
79
+ } } > Issues</ span >
37
80
</ Badge >
38
81
} />
39
82
40
83
< Tab key = "pr" title = {
41
84
< Badge color = "primary" placement = { "top-right" } content = { props . info . nums_pullrequest } size = "sm" >
42
- < span style = { {
43
- padding : "3px"
44
- } } > pull request</ span >
85
+
86
+ < IconWrapper className = "bg-primary/10 text-primary" >
87
+ < PullRequestIcon className = "text-lg " />
88
+ </ IconWrapper >
89
+ < span style = { {
90
+ padding : "3px"
91
+ } } > Pull Request</ span >
45
92
</ Badge >
46
93
} />
47
- < Tab key = "discission" title = "discission" />
48
- < Tab key = "action" title = "action" />
49
- < Tab key = "project" title = "project" />
50
- < Tab key = "insights" title = "insights" />
51
- < Tab key = "setting" title = "setting" />
94
+ < Tab key = "discission" title = {
95
+ < div style = { {
96
+ display : "flex"
97
+ } } >
98
+ < IconWrapper className = "bg-secondary/10 text-secondary" >
99
+ < ChatIcon className = "text-lg " />
100
+ </ IconWrapper >
101
+ < span style = { {
102
+ padding : "3px"
103
+ } } > Discission</ span >
104
+ </ div >
105
+ } />
106
+ < Tab key = "action" title = {
107
+ < div style = { {
108
+ display : "flex"
109
+ } } >
110
+ < IconWrapper className = "bg-warning/10 text-warning" >
111
+ < PlayCircleIcon className = "text-lg " />
112
+ </ IconWrapper >
113
+ < span style = { {
114
+ padding : "3px"
115
+ } } > Actions</ span >
116
+ </ div >
117
+ } />
118
+ < Tab key = "project" title = {
119
+ < div style = { {
120
+ display : "flex"
121
+ } } >
122
+ < IconWrapper className = "bg-default/50 text-foreground" >
123
+ < LayoutIcon className = "text-lg " />
124
+ </ IconWrapper >
125
+ < span style = { {
126
+ padding : "3px"
127
+ } } > Project</ span >
128
+ </ div >
129
+ } />
130
+ < Tab key = "setting" title = {
131
+ < div style = { {
132
+ display : "flex"
133
+ } } >
134
+ < IconWrapper className = "bg-amber-400 text-foreground" >
135
+ < SettingIcon className = "text-lg text-amber-800" />
136
+ </ IconWrapper >
137
+ < span style = { {
138
+ padding : "3px"
139
+ } } > Setting</ span >
140
+ </ div >
141
+ } />
52
142
</ Tabs >
53
143
54
144
</ div >
0 commit comments