1
1
import * as React from "react" ;
2
- import Select from "antd/lib/select" ;
3
2
import ReactJson from "react-json-view" ;
4
- import Button from "antd/lib/button" ;
5
- import Layout from "antd/lib/layout" ;
6
3
import { useSource , useSourceLane , } from "react-async-states" ;
7
4
import { DevtoolsJournalEvent } from "react-async-states/dist/devtools" ;
8
5
import { currentJournal , journalSource } from "./sources" ;
9
6
import { addFormattedDate } from "./utils" ;
10
7
11
- const { Content, Sider} = Layout ;
12
-
13
8
const CurrentJournalDisplay = React . memo ( function Journal ( { lane} : { lane : string } ) {
14
9
15
10
return (
16
- < Layout className = 'main-bg' style = { {
17
- height : '100%' ,
18
- padding : 0
19
- } } >
20
- < Sider style = { {
11
+ < div className = 'main-bg'
12
+ style = { {
13
+ display : 'flex' ,
14
+ flexDirection : 'row' ,
15
+ height : '100%' ,
16
+ padding : 0
17
+ } } >
18
+ < div style = { {
19
+ width : 250 ,
20
+ minWidth : 250 ,
21
21
padding : 8 ,
22
22
overflow : 'auto' ,
23
- // height: 'calc(100vh - 40px)',
24
23
borderRight : '1px dashed #C3C3C3' ,
25
- } } className = 'main-bg scroll-y-auto' width = { 250 } >
24
+ } } className = 'main-bg scroll-y-auto' >
26
25
< div className = 'main-color' style = { { height : '100%' } } >
27
26
< JournalView lane = { lane } />
28
27
</ div >
29
- </ Sider >
30
- < Content className = 'main-bg main-color scroll-y-auto'
31
- style = { { height : '100%' , overflowY : 'auto' } } >
28
+ </ div >
29
+ < div className = 'main-bg main-color scroll-y-auto'
30
+ style = { { height : '100%' , overflowY : 'auto' , width : '100% '} } >
32
31
< CurrentJson />
33
- </ Content >
34
- </ Layout > ) ;
32
+ </ div >
33
+ </ div > ) ;
35
34
} ) ;
36
35
37
- const JOURNAL_EVENT_TYPES_FILTER_OPTIONS = Object . values ( DevtoolsJournalEvent ) . map ( t => ( {
38
- label : t , value : t
39
- } ) ) ;
40
36
const initialSelectedEvents = [
41
37
DevtoolsJournalEvent . creation ,
42
38
DevtoolsJournalEvent . update ,
@@ -70,37 +66,71 @@ function JournalView({lane}) {
70
66
}
71
67
} , [ lane ] ) ;
72
68
69
+ // handel select or unselect selectType
70
+ function handleSelectChange ( e : React . ChangeEvent < HTMLSelectElement > ) {
71
+ const value : DevtoolsJournalEvent = e . target . value as DevtoolsJournalEvent ;
72
+ if ( selectedTypes . find ( ( option : DevtoolsJournalEvent ) => option === value ) === undefined ) {
73
+ return setSelectedTypes ( [ ...selectedTypes , value ] )
74
+ } else {
75
+ return setSelectedTypes ( selectedTypes . filter ( ( option : DevtoolsJournalEvent ) => option !== value ) )
76
+ }
77
+ }
78
+
73
79
return (
74
80
< div >
75
81
< span > Available: ({ allLogs . length } ), shown: ({ filteredData . length } )</ span >
76
82
< div style = { { display : "flex" } } >
77
- < Button type = "link" size = "small" shape = "round"
78
- className = "default-button"
79
- onClick = { ( ) => setSelectedTypes ( [ ] ) } > Clear all</ Button >
80
- < Button type = "link" size = "small" shape = "round"
81
- className = "default-button"
82
- style = { { marginLeft : 8 } }
83
+ < button className = "default-button"
84
+ onClick = { ( ) => setSelectedTypes ( [ ] ) }
85
+ style = { {
86
+ backgroundColor : 'transparent' ,
87
+ border : "none" ,
88
+ color : '#00aaff' ,
89
+ cursor : "pointer"
90
+ } } > Clear all
91
+ </ button >
92
+ < button className = "default-button"
93
+ style = { {
94
+ backgroundColor : 'transparent' ,
95
+ border : "none" ,
96
+ color : '#00aaff' ,
97
+ marginLeft : 8 ,
98
+ cursor : "pointer"
99
+ } }
83
100
onClick = { ( ) => setSelectedTypes ( Object . values ( DevtoolsJournalEvent ) ) }
84
101
>
85
102
Select all
86
- </ Button >
103
+ </ button >
87
104
</ div >
88
- < Select
89
- mode = " multiple"
105
+ < select
106
+ multiple
90
107
value = { selectedTypes }
91
- style = { { width : '100%' , marginTop : 8 } }
92
- onChange = { setSelectedTypes }
93
- defaultValue = { selectedTypes }
94
- options = { JOURNAL_EVENT_TYPES_FILTER_OPTIONS }
95
- />
108
+ onChange = { ( e : React . ChangeEvent < HTMLSelectElement > ) => handleSelectChange ( e ) }
109
+ style = { {
110
+ color : '#000' ,
111
+ width : '100%' ,
112
+ marginTop : 8 ,
113
+ background : 'white' ,
114
+ borderRadius : 5 ,
115
+ outline : "none"
116
+ } } >
117
+ { Object . values ( DevtoolsJournalEvent ) ?. map ( ( t : string ) => (
118
+ < option key = { t } value = { t } > { t } </ option > ) ) }
119
+ </ select >
96
120
< ul style = { { marginTop : 8 } } >
97
- { filteredData . map ( ( entry , id ) => (
121
+ { filteredData . map ( ( entry ) => (
98
122
< li
99
123
className = "w-full"
100
- key = { id } >
101
- < Button
102
- type = { json . data ?. eventId === entry . eventId ? "primary" : "link" }
103
- size = "small" shape = "round" className = "default-button"
124
+ key = { entry ?. eventId } >
125
+ < button
126
+ style = { {
127
+ borderRadius : 100 ,
128
+ backgroundColor : json . data ?. eventId === entry . eventId ? '#0059ff' : 'transparent' ,
129
+ color : json . data ?. eventId === entry . eventId ? 'white' : '#00bbff' ,
130
+ padding : '3px 10px' ,
131
+ border : "none"
132
+ } }
133
+ className = "default-button"
104
134
onClick = { ( ) => {
105
135
currentJournal . setState ( {
106
136
data : formJournalEventJson ( entry ) ,
@@ -110,7 +140,7 @@ function JournalView({lane}) {
110
140
} ) ;
111
141
} } >
112
142
{ `› ${ entry . eventType } ` }
113
- </ Button >
143
+ </ button >
114
144
</ li >
115
145
) ) }
116
146
</ ul >
0 commit comments