3.0 KiB
3.0 KiB
UI Improvement: Resizable Panels & Copy Action
Context: We are polishing the "Main Workspace" area of the LiteRequest application. Goal:
- Add a "Copy Body" button to the Response Panel for quick access to the result.
- Make the vertical split between the Request Panel (top) and Response Panel (bottom) resizable by the user.
1. Feature: Response Copy Button
1.1 UI Changes
- Location: Inside the
ResponsePanel.vue, in the Meta Bar / Header (the row displaying Status Code and Time), aligned to the right. - Icon: Use the
Clipboardicon fromlucide-vue-next. - Interaction:
- Default: Shows the
Clipboardicon. - On Click: Copies the content of the Response Body to the system clipboard.
- Feedback: After clicking, change the icon to
Check(Checkmark) for 2 seconds to indicate success, then revert toClipboard.
- Default: Shows the
- Style: Small, ghost-style button (transparent background, changing color on hover).
1.2 Logic Implementation
- Use the browser API:
navigator.clipboard.writeText(props.body). - Use a local ref
isCopied(boolean) to handle the icon toggle state. - Use
setTimeoutto resetisCopiedback tofalseafter 2000ms.
2. Feature: Resizable Split Pane
2.1 UI Changes
- Location: The parent component that contains
<RequestPanel />and<ResponsePanel />(likelyApp.vueorMainWorkspace.vue). - Visuals: Insert a Resizer Handle (a thin horizontal bar) between the two panels.
- Height: 4px - 6px.
- Color:
bg-slate-800(hover:bg-indigo-500). - Cursor:
cursor-row-resize.
2.2 Logic Implementation
- State: Use a
reffortopPanelHeight(initially50%or50vh). - Drag Logic:
onMouseDown(on the Resizer): Set aisDraggingflag to true. Addmousemoveandmouseupevent listeners to thewindow(global).onMouseMove(on Window): Calculate the new percentage or pixel height based one.clientYrelative to the window height. UpdatetopPanelHeight.onMouseUp(on Window): SetisDraggingto false. Remove the window event listeners.
- Layout Application:
- Apply
:style="{ height: topPanelHeight }"to the Request Panel container. - Apply
flex-1(or calculated remaining height) to the Response Panel container. - Ensure
min-heightis set (e.g., 200px) on both panels to prevent them from collapsing completely.
- Apply
3. Implementation Steps for AI
Please generate the code updates in the following order:
- ResponsePanel.vue:
- Update the template to include the Copy Button in the header.
- Add the script logic for
copyToClipboard.
- Main Layout (App.vue or similar):
- Refactor the template to wrap RequestPanel and ResponsePanel in the resizable structure.
- Implement the
useDraggablelogic (or manual event handlers) in<script setup>. - Add the
<div class="resizer ...">element styles.
Instruction to AI: Generate the specific code to add the copy functionality and the resizable split view logic.