From 8fc4dbbf9328dd9712e980d2040924f1827f113e Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Mon, 1 Dec 2025 10:39:35 -0400 Subject: [PATCH] modify sidebar --- spec/feat-history-ui.md | 67 ++++++++++++++++++++++++ src/App.vue | 58 +-------------------- src/components/Sidebar.vue | 104 +++++++++++++++++++++++++++++++++++++ src/stores/requestStore.ts | 33 +++++++++++- 4 files changed, 205 insertions(+), 57 deletions(-) create mode 100644 spec/feat-history-ui.md create mode 100644 src/components/Sidebar.vue diff --git a/spec/feat-history-ui.md b/spec/feat-history-ui.md new file mode 100644 index 0000000..9ef5106 --- /dev/null +++ b/spec/feat-history-ui.md @@ -0,0 +1,67 @@ +# Feature Upgrade: History UI Overhaul + +**Context:** +We are polishing the "Sidebar" component of the "LiteRequest" application. +**Goal:** Improve the information density of the History list and add management features (Delete/Clear All). + +## 1. UI/UX Changes + +### 1.1 History Item Layout (Sidebar.vue) +* **Current State:** Shows Method, URL, and Timestamp. +* **New Layout:** + * **Remove:** Completely remove the Date/Time display to save space. + * **Flex Row:** The item should be a flex container (`flex items-center justify-between`). + * **Left Side (Info):** + * **Method Badge:** (Existing) e.g., "GET". + * **Status Badge (New):** Add a badge immediately after the Method. + * *Content:* The HTTP Status Code (e.g., 200, 404, 500). + * *Style:* Small, pill-shaped, lighter opacity background. + * *Color Logic:* + * 2xx: Text Green / Bg Green-500/20 + * 3xx: Text Blue / Bg Blue-500/20 + * 4xx: Text Orange / Bg Orange-500/20 + * 5xx: Text Red / Bg Red-500/20 + * **URL:** Truncate text if it's too long (`truncate` class). + * **Right Side (Actions):** + * **Delete Button (New):** A small "Trash" icon (`Trash2` from lucide-vue-next). + * *Behavior:* Visible on hover (group-hover) or always visible with low opacity. + * *Interaction:* Clicking this **must not** trigger the "Load Request" action of the list item (use `.stop` modifier). + +### 1.2 "Clear All" Functionality +* **Location:** Add a "Clear" or "Trash" icon button in the **Header** of the Sidebar (next to the "History" tab label or the "LiteRequest" title). +* **Style:** Subtle button, turns red on hover. +* **Tooltip (Optional):** "Clear All History". + +## 2. Logic & State Management + +### 2.1 Store Updates (`stores/requestStore.ts`) +* Add two new actions: + 1. `deleteHistoryItem(id: string)`: Removes a specific item from the `history` array by ID. + 2. `clearHistory()`: Empties the `history` array completely. +* **Persistence:** Ensure `localStorage` is updated immediately after these actions. + +## 3. Implementation Details + +### A. Sidebar Component (`Sidebar.vue`) +* **Status Badge Implementation:** + * Create a helper function `getStatusColor(code)` inside the component to return the correct Tailwind classes. +* **Event Handling:** + * `