diff --git a/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md b/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md index a7f1b62..8ff8485 100644 --- a/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md +++ b/docs/superpowers/plans/2026-03-22-brave-search-frontend-redesign.md @@ -478,49 +478,49 @@ Replace the entire file content: {{end}} ``` -- [ ] **Step 3: Update PageData struct to include new fields** +- [ ] **Step 3: Add FilterOption struct and update PageData struct** -Modify `internal/views/views.go` — add to `PageData` struct: +Add `FilterOption` struct at package level in `views.go` (near `PageNumber` struct): ```go -type PageData struct { - // ... existing fields ... - - // New fields for three-column layout - Categories []string - CategoryIcons map[string]string - ActiveCategory string - TimeFilters []FilterOption - TypeFilters []FilterOption - ActiveTime string - ActiveType string -} - -// FilterOption represents a filter radio option +// FilterOption represents a filter radio option for the sidebar. type FilterOption struct { Label string Value string } ``` -- [ ] **Step 4: Update FromResponse to accept filter params** - -Update `FromResponse` signature to accept `activeCategory`, `activeTime`, and `activeType` from the request. First update the `Search` handler in `handlers.go` to pass these params: +Then update `PageData` struct to include new fields: ```go -// In handlers.go, update Search handler: -pd := views.FromResponse(resp, req.Query, req.Pageno) -pd.ActiveCategory = r.FormValue("category") -pd.ActiveTime = r.FormValue("time") -pd.ActiveType = r.FormValue("type") +type PageData struct { + // ... existing fields (SourceURL, Query, Pageno, etc.) ... + + // New fields for three-column layout + Categories []string + CategoryIcons map[string]string + DisabledCategories []string + ActiveCategory string + TimeFilters []FilterOption + TypeFilters []FilterOption + ActiveTime string + ActiveType string +} ``` -Then update `FromResponse` in `views.go` to accept these params: +- [ ] **Step 4: Update FromResponse signature and body** + +Update `FromResponse` signature to accept filter params and set defaults: ```go func FromResponse(resp contracts.SearchResponse, query string, pageno int, activeCategory, activeTime, activeType string) PageData { + // Set defaults + if activeCategory == "" { + activeCategory = "all" + } + pd := PageData{ - // ... existing initialization ... + // ... existing initialization (NumberOfResults, Results, etc.) ... // New: categories with icons Categories: []string{"all", "news", "images", "videos", "maps"}, @@ -536,7 +536,6 @@ func FromResponse(resp contracts.SearchResponse, query string, pageno int, activ "weather": "🌤️", }, ActiveCategory: activeCategory, - if activeCategory == "" { activeCategory = "all" } // Time filters TimeFilters: []FilterOption{ @@ -562,7 +561,12 @@ func FromResponse(resp contracts.SearchResponse, query string, pageno int, activ } ``` -Add `DisabledCategories []string` field to `PageData`. +Update the `Search` handler in `handlers.go` to pass filter params: + +```go +pd := views.FromResponse(resp, req.Query, req.Pageno, + r.FormValue("category"), r.FormValue("time"), r.FormValue("type")) +``` - [ ] **Step 5: Update results.html sidebar to show disabled state**