Skip to content

[FEATURE] Add a "Big Number" Metric Card UI Component #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amrutha97 opened this issue Apr 7, 2025 · 2 comments · May be fixed by #629
Closed

[FEATURE] Add a "Big Number" Metric Card UI Component #627

amrutha97 opened this issue Apr 7, 2025 · 2 comments · May be fixed by #629
Labels
enhancement New feature or request

Comments

@amrutha97
Copy link
Member

amrutha97 commented Apr 7, 2025

Data-rich applications built using Preswald often require a visual highlight of KPIs like total revenue, conversion rate, or average score. Currently, Preswald lacks a dedicated UI component to display such single-value summaries prominently and attractively.

There is a clear need for a reusable, visually prominent “big number” metric card.


Feature Overview

Introduce a new big_number() UI component for the Preswald SDK, enabling developers to render high-impact numeric KPIs in a card format, optionally with a label, subtext, icon, or trend indicator.

Example Usage in Python
from preswald import big_number

big_number(
    value=15602,
    label="Total Users",
    delta="+5.4%",
    delta_color="green",
    icon="user",
    description="Since last week"
)

🎯 Functional Requirements

  • Primary Value (Required):

    • Accepts int, float, or str values.
    • Automatically formats large numbers (e.g., 1200000 → 1.2M).
  • Label:

    • String displayed above or below the big number (e.g., “Total Users”).
  • Delta Indicator:

    • Value + color-coded change indicator (e.g., "+5.2%", with green arrow).
    • Accept delta_color: str to customize appearance (green, red, gray).
  • Icon:

    • Icon name to be rendered (integrated with an icon library like lucide-react).
    • Positioned to the left or right of the number.

UI/UX Mock

  • Bold central number
  • Smaller label above or below
  • Optional arrow/delta to right
  • Optional icon to left
  • Light background card with padding and subtle shadow
  • Option to stack horizontally with other metric cards

🛠️ Engineering Tasks

  1. Frontend Implementation:

    • Create a new BigNumberWidget.jsx in frontend/src/components/widgets/.
    • Use Card, Typography, and Tailwind utility classes for layout.
    • Support props: value, label, delta, deltaColor, icon, description.
  2. SDK Integration:

    • Add big_number() to preswald/interfaces/components.py.
    • Register as a new component type in the layout engine and render pipeline.
  3. Testing:

    • Snapshot tests for various display configurations.
  4. Docs & Demo:

    • Add new SDK docs in docs/sdk/big_number.mdx.
    • Include an example in examples/iris/hello.py or a new metrics_demo example.
    • Document in preswald/docs/usage/examples.mdx.
@amrutha97 amrutha97 added the enhancement New feature or request label Apr 7, 2025
@raj978
Copy link

raj978 commented Apr 7, 2025

I would love to work on this issue!

@shivam-singhal
Copy link
Member

Closed with #628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants