-
-
Notifications
You must be signed in to change notification settings - Fork 6
Refactor: Move map analysis button to navigation bars #318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| 'use client' | ||
|
|
||
| import React from 'react' | ||
| import Image from 'next/image' | ||
| import { ModeToggle } from './mode-toggle' | ||
|
|
@@ -13,8 +15,13 @@ import { | |
| } from 'lucide-react' | ||
| import { MapToggle } from './map-toggle' | ||
| import { ProfileToggle } from './profile-toggle' | ||
| import { useAnalysisTool } from './analysis-tool-context' | ||
| import { useMap } from './map/map-context' | ||
|
|
||
| export const Header = () => { | ||
| const { isAnalyzing, handleResolutionSearch } = useAnalysisTool() | ||
| const { map } = useMap() | ||
|
|
||
|
Comment on lines
+22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is a correctness issue that will manifest as an immediate runtime error due to the explicit throw in SuggestionWrap the part of the app that renders // e.g., app/layout.tsx (or wherever Header is rendered)
import { MapDataProvider } from '@/components/map/map-data-context'
import { MapProvider } from '@/components/map/map-context'
import { AnalysisToolProvider } from '@/components/analysis-tool-context'
import { Header } from '@/components/header'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<MapDataProvider>
<MapProvider>
<AnalysisToolProvider>
<Header />
{children}
</AnalysisToolProvider>
</MapProvider>
</MapDataProvider>
</body>
</html>
)
}Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion |
||
| return ( | ||
| <header className="fixed w-full p-1 md:p-2 flex justify-between items-center z-10 backdrop-blur md:backdrop-blur-none bg-background/80 md:bg-transparent"> | ||
| <div> | ||
|
|
@@ -39,8 +46,18 @@ export const Header = () => { | |
| <CalendarDays className="h-[1.2rem] w-[1.2rem]" /> | ||
| </Button> | ||
|
|
||
| <Button variant="ghost" size="icon"> | ||
| <Search className="h-[1.2rem] w-[1.2rem]" /> | ||
| <Button | ||
| variant="ghost" | ||
| size="icon" | ||
| onClick={handleResolutionSearch} | ||
| disabled={isAnalyzing || !map} | ||
| title="Analyze current map view" | ||
| > | ||
| {isAnalyzing ? ( | ||
| <div className="h-[1.2rem] w-[1.2rem] animate-spin rounded-full border-b-2 border-current"></div> | ||
| ) : ( | ||
| <Search className="h-[1.2rem] w-[1.2rem]" /> | ||
| )} | ||
| </Button> | ||
|
Comment on lines
+49
to
61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Extract analysis button to eliminate duplication. The analysis button implementation (lines 49-61) is identical to the one in Consider extracting a reusable // components/analysis-button.tsx
'use client'
import { Button } from '@/components/ui/button'
import { Search } from 'lucide-react'
import { useAnalysisTool } from './analysis-tool-context'
import { useMap } from './map/map-context'
export const AnalysisButton = () => {
const { isAnalyzing, handleResolutionSearch } = useAnalysisTool()
const { map } = useMap()
return (
<Button
variant="ghost"
size="icon"
onClick={handleResolutionSearch}
disabled={isAnalyzing || !map}
title="Analyze current map view"
>
{isAnalyzing ? (
<div className="h-[1.2rem] w-[1.2rem] animate-spin rounded-full border-b-2 border-current"></div>
) : (
<Search className="h-[1.2rem] w-[1.2rem]" />
)}
</Button>
)
}Then replace the duplicated button code in both files with: <AnalysisButton />🤖 Prompt for AI Agents |
||
|
|
||
| <Button variant="ghost" size="icon"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1 @@ | ||
| $ next dev --turbo | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Committing SuggestionDelete # logs
*.log
/dev_server.logI can add a cleanup commit to remove the file and update |
||
| ▲ Next.js 15.3.3 (Turbopack) | ||
| - Local: http://localhost:3000 | ||
| - Network: http://192.168.0.2:3000 | ||
| - Environments: .env.local, .env | ||
|
|
||
| ✓ Starting... | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate 'use client' directive.
The
'use client'directive appears twice (lines 1 and 3), which is unnecessary and should be removed.Apply this diff to remove the duplicate:
📝 Committable suggestion
🤖 Prompt for AI Agents