1
1
import React , { useEffect } from 'react' ;
2
2
3
3
import useLocalStorage from 'react-use-localstorage' ;
4
- import { MagnifyingGlassIcon , Cog6ToothIcon , ArrowUpRightIcon , MoonIcon , SunIcon , XMarkIcon , ChatBubbleLeftIcon } from '@heroicons/react/24/solid'
4
+ import { MagnifyingGlassIcon , Cog6ToothIcon , ArrowUpRightIcon , MoonIcon , SunIcon , XMarkIcon , ChatBubbleLeftIcon } from '@heroicons/react/24/solid'
5
5
6
6
interface Props {
7
7
handleChangeSettings : (
@@ -62,6 +62,11 @@ export default function TopNav(props: Props) {
62
62
handleChangeSettings ( showGet , showPost , showDelete , showPut , showPatch , e . target . checked , sort , groupby )
63
63
}
64
64
65
+ const handleClearLocalStorage = ( ) => {
66
+ localStorage . clear ( )
67
+ window . location . reload ( )
68
+ }
69
+
65
70
66
71
const toggleDarkMode = ( ) => {
67
72
const dataTheme = document . documentElement . getAttribute ( 'data-theme' ) ;
@@ -108,22 +113,22 @@ export default function TopNav(props: Props) {
108
113
</ div >
109
114
< div className = "flex-none" >
110
115
< div className = "form-control" >
111
- < label htmlFor = "search" className = "relative text-gray-400 focus-within:text-gray-600 block" >
112
- < MagnifyingGlassIcon className = "pointer-events-none w-4 h-4 absolute top-1/2 transform -translate-y-1/2 left-3" />
113
- < input type = "text" placeholder = "Filter APIs" className = "input pl-10 input-sm input-bordered" onChange = { ( e ) => handleSearch ( e . target . value ) } />
114
- </ label >
115
-
116
- </ div >
116
+ < label htmlFor = "search" className = "relative text-gray-400 focus-within:text-gray-600 block" >
117
+ < MagnifyingGlassIcon className = "pointer-events-none w-4 h-4 absolute top-1/2 transform -translate-y-1/2 left-3" />
118
+ < input type = "text" placeholder = "Filter APIs" className = "input pl-10 input-sm input-bordered" onChange = { ( e ) => handleSearch ( e . target . value ) } />
119
+ </ label >
120
+
121
+ </ div >
117
122
< div className = "menu menu-horizontal px-6 " >
118
123
< label className = "swap swap-rotate" >
119
124
< input type = "checkbox" onChange = { toggleDarkMode } />
120
- { theme === 'dark' ? < SunIcon className = "h-6 w-6" /> : < MoonIcon className = "h-6 w-6" /> }
125
+ { theme === 'dark' ? < SunIcon className = "h-6 w-6" /> : < MoonIcon className = "h-6 w-6" /> }
121
126
</ label >
122
127
</ div >
123
128
< div className = "ml-1" >
124
129
< a href = "#modal-settings" className = "btn btn-ghost btn-sm" >
125
130
< span className = "pr-1" >
126
- < Cog6ToothIcon className = "h-6 w-6" />
131
+ < Cog6ToothIcon className = "h-6 w-6" />
127
132
</ span >
128
133
</ a >
129
134
< div className = "modal" id = "modal-settings" >
@@ -132,29 +137,29 @@ export default function TopNav(props: Props) {
132
137
< h4 className = "font-bold mt-10" > Sort By</ h4 >
133
138
< div className = "form-control" >
134
139
< label className = "label" >
135
-
140
+
136
141
< input type = "radio" onChange = { handleChangeSort } value = "default" className = "radio" checked = { sort == "default" } />
137
142
< span className = "label-text" > Default</ span >
138
-
143
+
139
144
< input type = "radio" onChange = { handleChangeSort } value = "route_names" className = "radio" checked = { sort == "route_names" } />
140
- < span className = "label-text" > Routes </ span >
141
-
145
+ < span className = "label-text" > Route Names </ span >
146
+
142
147
< input type = "radio" onChange = { handleChangeSort } value = "method_names" className = "radio" checked = { sort == "method_names" } />
143
148
< span className = "label-text" > HTTP Methods</ span >
144
149
</ label >
145
150
</ div >
146
151
< h4 className = "font-bold mt-10" > Group By</ h4 >
147
152
< div className = "form-control" >
148
153
< label className = "label" >
149
-
154
+
150
155
< input type = "radio" onChange = { handleChangeGroupby } value = "default" className = "radio" checked = { groupby == "default" } />
151
156
< span className = "label-text" > Default</ span >
152
-
157
+
153
158
< input type = "radio" onChange = { handleChangeGroupby } value = "api_uri" className = "radio" checked = { groupby == "api_uri" } />
154
- < span className = "label-text" > API URI </ span >
155
-
159
+ < span className = "label-text" > API Name </ span >
160
+
156
161
< input type = "radio" onChange = { handleChangeGroupby } value = "controller_full_path" className = "radio" checked = { groupby == "controller_full_path" } />
157
- < span className = "label-text" > Controller Names </ span >
162
+ < span className = "label-text" > Controller Name </ span >
158
163
</ label >
159
164
</ div >
160
165
< h4 className = "font-bold mt-10" > Display Settings</ h4 >
@@ -184,9 +189,19 @@ export default function TopNav(props: Props) {
184
189
< input type = "checkbox" onChange = { handleChangeHead } className = "toggle toggle-success" checked = { showHead == 'true' } />
185
190
</ label >
186
191
</ div >
192
+ < h4 className = "font-bold mt-10" > Storage</ h4 >
193
+ < div className = "form-control" >
194
+ < label className = "label" >
195
+ < span className = "label-text" >
196
+ Clear localstorage
197
+ < p > < small > Delete localstorage data, request body and queries</ small > </ p >
198
+ </ span >
199
+ < button className = "btn btn-sm btn-error" onClick = { handleClearLocalStorage } > Clear</ button >
200
+ </ label >
201
+ </ div >
187
202
< div className = "modal-action" >
188
203
< a href = "#" className = "btn btn-sm" >
189
- < XMarkIcon className = "h-6 w-6" /> Close
204
+ < XMarkIcon className = "h-6 w-6" /> Close
190
205
</ a >
191
206
</ div >
192
207
</ div >
@@ -195,16 +210,16 @@ export default function TopNav(props: Props) {
195
210
< div className = "ml-1 " >
196
211
< a className = "btn btn-ghost btn-sm" href = '/request-docs/api?openapi=true' target = "_blank" >
197
212
< span className = "pr-1" >
198
- < ArrowUpRightIcon className = "h-6 w-6" />
199
- </ span >
213
+ < ArrowUpRightIcon className = "h-6 w-6" />
214
+ </ span >
200
215
OpenAPI 3.0
201
216
</ a >
202
217
</ div >
203
218
< div className = "ml-1 " >
204
219
< a className = "btn btn-ghost btn-sm" href = 'https://github.com/rakutentech/laravel-request-docs/issues/new' target = "_blank" rel = "noreferrer" >
205
220
< span className = "pr-1" >
206
- < ChatBubbleLeftIcon className = "h-6 w-6" />
207
- </ span >
221
+ < ChatBubbleLeftIcon className = "h-6 w-6" />
222
+ </ span >
208
223
Feature request
209
224
</ a >
210
225
</ div >
0 commit comments