You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement Sticky Kernel Selector in Overview (#43)
Summary:
This pull request introduces a significant UI/UX enhancement to the `KernelOverview` page by implementing a sticky/floating header for the "Available Kernels" selector. This feature improves usability, especially on pages with many kernels, by ensuring the kernel selection controls are always accessible.
**Key Features and Changes:**
1. **Sticky by Default:** The "Available Kernels" section now sticks to the top of the viewport by default as the user scrolls down the page.
2. **User-Controlled Toggle:** A toggle switch has been added next to the "Available Kernels" title, allowing users to enable or disable the sticky functionality as needed.
3. **Smart Collapsing:**
* To conserve screen space, the sticky header automatically collapses to show only the first row. This preserves the context of adjacent kernels, which was a key part of the feedback during development.
* When the user hovers over the collapsed bar, it smoothly expands to show all available kernels.
4. **Compact Sticky Design:** When in the sticky state, the entire header becomes more compact:
* The "Available Kernels" title text is smaller.
* The kernel selection buttons and the gaps between them are reduced in size.
* Overall padding and margins are tightened.
5. **Robust and Responsive:** The component is fully responsive. It uses a `useLayoutEffect` hook to track the positions of the kernel buttons and correctly scrolls the active row into view. A `resize` event listener ensures this logic re-runs if the browser window is resized, so the correct row is always shown.
**Implementation Details:**
* A new reusable `ToggleSwitch.tsx` component was created.
* The logic is self-contained within `KernelOverview.tsx`, using React hooks (`useState`, `useRef`, `useCallback`, `useLayoutEffect`) for state management and DOM interaction.
* Styling is handled with conditional Tailwind CSS classes to ensure a smooth transition between states.
*Default sticky and collapsed view:*
<img width="1087" height="872" alt="sticky" src="https://github.com/user-attachments/assets/92385db8-1ea4-4a22-bc8c-e0786ae7e5a3" />
*Expanded view on hover:*
<img width="1077" height="738" alt="hover" src="https://github.com/user-attachments/assets/62249419-a55b-43ba-b4a1-5d58f64305a6" />
Pull Request resolved: #43
Reviewed By: sfzhu93
Differential Revision: D78920093
Pulled By: FindHao
fbshipit-source-id: 4dada09e9474f1a8012d5ae878969efbffc3003e
0 commit comments