Skip to content

✨ feat(statistic-card): add StatisticCard, Statistic, TitleWithPercentage components - #565

Open
Innei wants to merge 1 commit into
masterfrom
feat/statistic-card
Open

Innei wants to merge 1 commit into
masterfrom
feat/statistic-card

Conversation

@Innei

@Innei Innei commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Adds a self-contained StatisticCard component family to lobe-ui, so lobe-chat can drop its @ant-design/pro-components-based wrapper.

Linear: LOBE-11988

Components (all exported from @lobehub/ui)

  • StatisticCard β€” metric card with flat API: title / extra / loading / value / precision / prefix / suffix / description / variant, plus classNames / styles slot overrides (root/header/title/extra/content/value/description)
  • Statistic β€” compact label + value pair for the description slot
  • TitleWithPercentage β€” title with growth-percentage tag (↑ 14.4% / ↓ 3.2%) for the title slot

Design

  • Zero antd / pro-components dependency; self-drawn styles following the base-ui conventions (cva variants, cssVar tokens, prefers-reduced-motion)
  • Typography ported from antd Statistic then refined: muted 14/500 title (colorTextSecondary), hero 28/500 value with tabular-nums and βˆ’1% tracking, 12px description 4px below
  • variant: borderless (default) / outlined / filled; outlined hover brightens the border only (160ms cubic-bezier(0.32,0.72,0,1)), matching base-ui Button
  • Mobile (responsive.sm): drops border/radius, uses colorBgContainer
  • Loading: Loader2 spin icon in the extra slot

Docs

  • src/StatisticCard/index.mdx (Data Display) + StoryBook demo with leva controls
  • Registered in site/content/navigationSections.json
  • Design spec: docs/superpowers/specs/2026-07-17-statistic-card-design.md

Testing

  • Verified in the docs site via browser automation: light/dark demo themes, loading state, API table rendering; no console errors
  • eslint clean on changed files; tsc --noEmit passes

Follow-up (separate PR in lobe-chat)

Replace the three pro-components usages (StatisticCard wrapper, ProTable in ApiKey, ProDescriptions in AgentInfoDescription) and remove the dependency.

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobe-ui Error Error Jul 16, 2026 7:38pm

Request Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 234717f30a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

>
{title}
</Text>
{count && prvCount && percentage && percentage !== 0 ? (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Render zero-count percentage changes

When either metric is legitimately zero, this truthiness guard drops the percentage tag even though calcGrowthPercentage handles those cases. For example count={0} with prvCount={100} should show a 100% decrease, and count={5} with prvCount={0} should show the 100% increase path from the helper, but both render no badge because count && prvCount is false.

Useful? React with πŸ‘Β / πŸ‘Ž.

{title}
</Text>
{count && prvCount && percentage && percentage !== 0 ? (
<Tag className={isUp ? styles.percentUp : styles.percentDown} variant={'borderless'}>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use Tag color props for percentage badges

Passing the success/warning class here does not color the badge because Tag always writes an inline color: colors?.textColor defaulting to colorTextSecondary (src/Tag/Tag.tsx lines 41 and 98-103), and that inline style overrides styles.percentUp/percentDown. As a result all TitleWithPercentage badges render neutral instead of green/orange; pass the appropriate color or inline style based on isUp.

Useful? React with πŸ‘Β / πŸ‘Ž.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant