File tree 1 file changed +12
-11
lines changed
1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -7,24 +7,25 @@ import { Button } from "./ui/button";
7
7
import type { FC } from "react" ;
8
8
9
9
export const Wrap : FC = ( ) => {
10
- const explorer = useExplorer ( ) ;
10
+ const {
11
+ tool,
12
+ viewModes : { astView, pathView } ,
13
+ wrap,
14
+ setWrap,
15
+ } = useExplorer ( ) ;
11
16
12
- if ( explorer . tool === "ast" && explorer . astViewMode !== "json" ) {
13
- return null ;
14
- }
17
+ const isAstViewNotJson = tool === "ast" && astView !== "json" ;
18
+ const isPathViewNotCode = tool === "path" && pathView !== "code" ;
15
19
16
- if ( explorer . tool === "path" && explorer . pathViewMode !== "code" ) {
17
- return null ;
18
- }
20
+ if ( isAstViewNotJson || isPathViewNotCode ) return null ;
19
21
20
22
return (
21
23
< Button
22
- onClick = { ( ) => explorer . setWrap ( ! explorer . wrap ) }
23
- variant = { explorer . wrap ? "outline" : "ghost" }
24
+ onClick = { ( ) => setWrap ( ! wrap ) }
25
+ variant = { wrap ? "outline" : "ghost" }
24
26
className = { cn (
25
27
"flex items-center gap-2" ,
26
- ! explorer . wrap &&
27
- "text-muted-foreground border border-transparent" ,
28
+ ! wrap && "text-muted-foreground border border-transparent" ,
28
29
) }
29
30
>
30
31
< WrapTextIcon size = { 16 } />
You can’t perform that action at this time.
0 commit comments