Skip to content

feat: add delta display cell#3574

Open
FaithAdekunle wants to merge 1 commit intomainfrom
value-display-delta-cell
Open

feat: add delta display cell#3574
FaithAdekunle wants to merge 1 commit intomainfrom
value-display-delta-cell

Conversation

@FaithAdekunle
Copy link
Contributor

@FaithAdekunle FaithAdekunle commented Mar 3, 2026

Description

Adds a new delta value-display renderer to the React value-display system, enabling rendering of positive/negative deltas with directional icons for use in data-collection/table contexts.

Screenshots (if applicable)

Screenshot 2026-03-03 at 12 51 32

Link to Figma Design

Implementation details

  • Introduces DeltaCell renderer and registers it under the delta renderer type.
  • Adds Storybook stories and MDX docs for the new delta value type.
  • Extends shared Storybook mock data with positive/negative delta examples.

Copilot AI review requested due to automatic review settings March 3, 2026 12:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new delta value-display renderer to the React value-display system, enabling rendering of positive/negative deltas with directional icons for use in data-collection/table contexts.

Changes:

  • Introduces DeltaCell renderer and registers it under the delta renderer type.
  • Adds Storybook stories and MDX docs for the new delta value type.
  • Extends shared Storybook mock data with positive/negative delta examples.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/react/src/components/value-display/types/delta/index.tsx Barrel export for the new delta value-display type.
packages/react/src/components/value-display/types/delta/delta.tsx Implements DeltaCell UI (icon + label with status-based color).
packages/react/src/components/value-display/types/delta/stories/delta.stories.tsx Adds Storybook stories demonstrating positive/negative delta rendering.
packages/react/src/components/value-display/types/delta/stories/delta.mdx Adds MDX documentation for the delta value type.
packages/react/src/components/value-display/renderers.tsx Registers delta: DeltaCell in the renderer map.
packages/react/src/components/value-display/stories/shared.tsx Adds positiveDelta / negativeDelta to Storybook mock item data.

import { TagListCell } from "./types/tagList"
import { TeamCell } from "./types/team"
import { TextCell } from "./types/text"
import { DeltaCell } from "./types/delta/index.tsx"
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The DeltaCell import path is inconsistent with the other value-display type imports in this file (it’s the only one importing an explicit /index.tsx). Prefer importing the folder (./types/delta) like the other renderers to keep import style consistent and avoid coupling to the barrel filename/extension.

Suggested change
import { DeltaCell } from "./types/delta/index.tsx"
import { DeltaCell } from "./types/delta"

Copilot uses AI. Check for mistakes.

return (
<div className={cn("flex items-center gap-1", colorClass)}>
{icon ? <F0Icon icon={icon} /> : null}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The arrow icon conveys the delta direction (positive/negative) but currently has no accessible name and isn’t marked decorative. This can result in screen readers missing the direction information (or announcing an unlabeled graphic). Add an aria-label (e.g., based on deltaStatus) or mark the icon aria-hidden and include the direction in accessible text.

Suggested change
{icon ? <F0Icon icon={icon} /> : null}
{icon ? (
<F0Icon
icon={icon}
aria-label={args.deltaStatus === "positive" ? "Positive change" : "Negative change"}
/>
) : null}

Copilot uses AI. Check for mistakes.
@FaithAdekunle FaithAdekunle force-pushed the value-display-delta-cell branch from 1e181d6 to 769d385 Compare March 3, 2026 12:58
@github-actions github-actions bot added feat react Changes affect packages/react labels Mar 3, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

✅ No New Circular Dependencies

No new circular dependencies detected. Current count: 0

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

🔍 Visual review for your branch is published 🔍

Here are the links to:

Copilot AI review requested due to automatic review settings March 3, 2026 13:02
@FaithAdekunle FaithAdekunle force-pushed the value-display-delta-cell branch from 769d385 to 9cc732d Compare March 3, 2026 13:02
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

📦 Alpha Package Version Published

Use pnpm i github:factorialco/f0#npm/alpha-pr-3574 to install the package

Use pnpm i github:factorialco/f0#4eca5e2669fb5e6cabc150397e1064ece45f1802 to install this specific commit

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment on lines +27 to +31
export const DeltaCell = (args: DeltaCellValue) => {
const icon = iconMap[args.deltaStatus]
const colorClass = colorMap[args.deltaStatus]

return (
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

This PR introduces a new renderer type ("delta") but there are no unit tests for DeltaCell. Similar value-display renderers like IconCell have tests; adding a small test suite (positive/negative render + icon presence + color class) would help prevent regressions.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +17 to +20
const iconMap: Record<DeltaStatus, IconType | undefined> = {
positive: ArrowUp,
negative: ArrowDown,
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

iconMap is typed as Record<DeltaStatus, IconType | undefined>, but DeltaStatus only includes "positive" and "negative" and both entries are always defined. This makes icon non-optional in practice and the conditional rendering branch unnecessary; either remove | undefined or add a status that can map to undefined.

Copilot uses AI. Check for mistakes.

return (
<div className={cn("flex items-center gap-1", colorClass)}>
{icon ? <F0Icon icon={icon} /> : null}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The arrow icon is decorative because the label is always rendered. Consider setting aria-hidden on the F0Icon here (or providing an accessible label) to avoid screen readers announcing an unlabeled SVG.

Suggested change
{icon ? <F0Icon icon={icon} /> : null}
{icon ? <F0Icon icon={icon} aria-hidden /> : null}

Copilot uses AI. Check for mistakes.
return (
<div className={cn("flex items-center gap-1", colorClass)}>
{icon ? <F0Icon icon={icon} /> : null}
<span className={colorClass}>{args.label}</span>
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

colorClass is applied to the wrapper div and again to the span. Since text color is inherited, the span class is redundant and can be removed to avoid duplication.

Suggested change
<span className={colorClass}>{args.label}</span>
<span>{args.label}</span>

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Coverage Report for packages/react

Status Category Percentage Covered / Total
🔵 Lines 40.65% 8112 / 19951
🔵 Statements 40.03% 8323 / 20791
🔵 Functions 31.73% 1769 / 5574
🔵 Branches 30.32% 4786 / 15781
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/ui/value-display/renderers.tsx 81.81% 60% 100% 81.81% 123, 127
packages/react/src/ui/value-display/__stories__/shared.tsx 0% 100% 0% 0% 8-86
packages/react/src/ui/value-display/types/delta/delta.tsx 50% 0% 0% 50% 28-35
packages/react/src/ui/value-display/types/delta/index.tsx 100% 100% 100% 100%
Generated in workflow #11450 for commit cae3bbb by the Vitest Coverage Report Action

@FaithAdekunle FaithAdekunle force-pushed the value-display-delta-cell branch from 9cc732d to cae3bbb Compare March 3, 2026 13:09
@FaithAdekunle FaithAdekunle marked this pull request as ready for review March 3, 2026 14:56
@FaithAdekunle FaithAdekunle requested a review from a team as a code owner March 3, 2026 14:56
Copilot AI review requested due to automatic review settings March 3, 2026 14:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment on lines +1 to +49
import { Meta, StoryObj } from "@storybook/react-vite"

import { Cell, mockItem } from "../../../__stories__/shared"

const meta = {
title: "Value Display/Delta",
component: Cell,
parameters: {
layout: "padded",
docs: {
description: {
component:
"Renders a single delta value with an icon indicating the direction of change. Used for displaying changes or differences in data collections.",
},
source: {
code: null,
},
},
},
} satisfies Meta

export default meta
type Story = StoryObj<typeof meta>

export const DeltaType: Story = {
args: {
item: mockItem,
property: {
label: "Delta",
render: (item) => ({
type: "delta",
value: item.positiveDelta,
}),
},
},
}

export const NegativeDeltaType: Story = {
args: {
item: mockItem,
property: {
label: "Delta",
render: (item) => ({
type: "delta",
value: item.negativeDelta,
}),
},
},
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

Storybook stories for components/renderer types in this repo commonly include a dedicated Snapshot story using withSnapshot({}) (often wrapped with withSkipA11y) for Chromatic visual regression. Adding a Snapshot story for both positive and negative delta variants would help prevent regressions.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@sauldom102 sauldom102 left a comment

Choose a reason for hiding this comment

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

Could we better use TagBalance and rename delta to balance? Just to reuse what we already have

https://ds.factorial.dev/?path=/docs/components-tags-tagbalance--documentation

As an example, you can see how we reused it in DetailsItemsList https://ds.factorial.dev/?path=/docs/components-list-detailsitemslist--documentation

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

Labels

feat react Changes affect packages/react

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants