Frontend School

Dynamic Dashboard Widget Skeleton

Machine Coding
hard

Dynamic Dashboard Widget Skeleton

Hard
React
CSS
UI/UX
Component Design
Performance

Overview

In high-performance applications like Browserstack's testing dashboards, perceived loading speed is as crucial as actual loading speed. Skeleton loaders provide an excellent user experience by giving users immediate visual feedback that content is on its way, reducing perceived wait times and improving engagement. This problem challenges you to implement a robust and reusable skeleton loader for a complex dashboard widget.

What you need to do / Task

Your primary task is to create a versatile Skeleton React component and integrate it into a DashboardWidget to simulate a loading state.

  1. Develop a reusable Skeleton component:
    • It should accept props to define its shape and size, such as variant (e.g., 'text', 'rect', 'circle'), width, and height.
    • For text variants, it should optionally support a count prop to render multiple lines of text, with varying widths for realism.
    • It must apply a visually appealing "shimmer" animation to indicate activity.
  2. Integrate the Skeleton component into DashboardWidget:
    • When isLoading is true, the DashboardWidget should display a skeleton representation that closely mimics the layout and proportions of the actual content.
    • Map different parts of the DashboardWidget (title, user avatars & names, metrics, chart area, action button) to appropriate Skeleton variants and sizes.
  3. Ensure a smooth transition:
    • The skeleton should disappear, and the actual content should appear once the mock fetchDashboardData promise resolves.

UI/UX expectations

  • Layout Matching: The skeleton layout should mirror the final content layout as closely as possible. For example, if user items are displayed horizontally, their skeleton counterparts should also be horizontal.
  • Shimmer Animation: Implement a subtle, continuous left-to-right shimmer animation on the skeleton elements.
  • Colors: Use a light grey base color (e.g., #e2e8f0 or similar) for the skeleton background, with a lighter gradient for the shimmer effect.
  • Accessibility: Consider adding aria-busy="true" to the loading container to inform assistive technologies that content is being loaded.
  • Responsiveness: The skeleton should adapt to the layout of the DashboardWidget component, which already has some basic responsive styling.

Acceptance criteria

  • The Skeleton component is implemented as a functional React component.
  • The Skeleton component supports variant props (e.g., 'text', 'rect', 'circle').
  • The Skeleton component supports width and height props for custom sizing.
  • The text variant of the Skeleton component renders multiple lines with realistic, slightly varying widths when count is provided.
  • A shimmer animation is visible on all skeleton elements.
  • The DashboardWidget correctly displays the skeleton when isLoading is true.
  • The skeleton accurately represents the layout and approximate dimensions of the DashboardWidget's title, user list (avatars and names), metrics grid (labels and values), chart area, and action button.
  • Upon data fetch completion, the skeleton is replaced by the actual DashboardData content.
  • The solution integrates basic accessibility attributes for loading states.

Constraints

Constraints & assumptions

  • You must use React (functional components) and plain CSS for styling the skeleton and its animation. No external animation libraries are allowed for the skeleton itself.
  • The provided fetchDashboardData function simulates data loading; do not modify its behavior or delay.
  • The problem focuses on the UI implementation of the skeleton; you do not need to implement the actual chart visualization or complex data handling logic.
  • Assume a modern browser environment.

Out of scope

  • Extensive error handling for data fetching.
  • Deep performance optimizations beyond basic good practices (e.g., memoization for static parts of the skeleton).
  • Server-Side Rendering (SSR) specific implementations.
  • Advanced state management libraries (e.g., Redux, Zustand).

What interviewers evaluate

  • Component Design & Reusability: How effectively the Skeleton component is designed for reusability and configurability.
  • CSS & Animation Proficiency: Skill in implementing complex CSS layouts and animations (shimmer effect).
  • React State Management: Correct handling of loading states and conditional rendering.
  • UI/UX Fidelity: Adherence to the specified visual and interactive requirements, including layout accuracy and accessibility.
  • Code Quality: Cleanliness, readability, type safety (if TypeScript is used), and maintainability of the code.

Loading editor...