Skip to content

feat: add flow animations to supply-chain graph edges (#154) - #165

Merged
arghya29 merged 3 commits into
arghya29:devfrom
Dev1822:feat/add-flow-animations-154
Jul 22, 2026
Merged

feat: add flow animations to supply-chain graph edges (#154)#165
arghya29 merged 3 commits into
arghya29:devfrom
Dev1822:feat/add-flow-animations-154

Conversation

@Dev1822

@Dev1822 Dev1822 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements dynamic flow animations to the supply-chain graph edges to visually simulate the movement of goods and emissions through the network.

Key changes include:

  • Integrated React Flow's animated property for all connecting routes.
  • Added custom inline CSS to dynamically adjust the edge thickness (from 1.5px to 6px) and animation speed (from 2s to 0.5s) based on the carbon volume (emissions) of each specific route.
  • Implemented a persistent global user preference store using Zustand.
  • Added an "Accessibility" card to the dashboard settings page allowing users to toggle "Disable Animations" on or off for reduced motion preference.

Related Issue

Closes #154

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Tests

Checklist

  • I have read CONTRIBUTING.md
  • My code follows the existing style
  • I have run npm test and all tests pass
  • I have run npm run lint with no errors
  • I have added/updated tests for my changes (if applicable)
  • I have tested on mobile (320px width) if this is a UI change

Summary by CodeRabbit

  • New Features
    • Added an Accessibility setting to disable animations across the application.
    • The animation preference is persisted and restored between sessions.
  • Improvements
    • Supply chain graph animations now respect the user’s animation preference.
    • Route visuals (including animation timing) better reflect route emissions when available.
  • Chores
    • Introduced a shared preferences hook and re-exported it for reuse.

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

@Dev1822 is attempting to deploy a commit to the Arghya's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a persisted animation preference, a hydration-safe settings toggle, and graph edge animation controlled by that preference with emissions-based thickness and duration.

Changes

Animation Preferences and Graph Flow

Layer / File(s) Summary
Persisted animation preference
hooks/use-preferences.ts, hooks/index.ts, package.json
Defines and re-exports a persisted Zustand store for animationsDisabled and its setter, and adds the Zustand dependency.
Settings accessibility control
app/[locale]/(dashboard)/settings/page.tsx
Adds a hydration-safe “Disable Animations” checkbox connected to the preferences store.
Preference-driven graph edges
components/graph/supply-chain-graph.tsx
Controls route edge animation from the preference and derives edge thickness and animation duration from emissions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant SettingsPage
  participant PreferencesStore
  participant SupplyChainGraph
  User->>SettingsPage: Toggle Disable Animations
  SettingsPage->>PreferencesStore: Persist animationsDisabled
  SupplyChainGraph->>PreferencesStore: Read animationsDisabled
  SupplyChainGraph->>SupplyChainGraph: Recompute animated route edges
Loading

Suggested labels: enhancement, feature, frontend

Suggested reviewers: arghya29

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: animated supply-chain graph edges.
Description check ✅ Passed The description follows the template and covers the change, issue, type, and checklist; only screenshots are missing for this UI update.
Linked Issues check ✅ Passed The changes implement animated edges, route-specific styling, a disable-animations toggle, and a persisted preference store as requested.
Out of Scope Changes check ✅ Passed The added hook, settings UI, graph changes, and Zustand dependency all support the feature; no unrelated changes stand out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from arghya29 July 21, 2026 11:50
@coderabbitai coderabbitai Bot added the enhancement New feature or request label Jul 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c48450ad-10dc-4c92-b82f-f4de988771ef

📥 Commits

Reviewing files that changed from the base of the PR and between 34e9880 and a37451a.

📒 Files selected for processing (4)
  • app/[locale]/(dashboard)/settings/page.tsx
  • components/graph/supply-chain-graph.tsx
  • hooks/index.ts
  • hooks/use-preferences.ts
📜 Review details
⚠️ CI failures not shown inline (1)

Commit Status: Vercel: Vercel

Conclusion: failure

Authorization required to deploy.
🧰 Additional context used
🪛 React Doctor (0.7.6)
app/[locale]/(dashboard)/settings/page.tsx

[warning] 74-74: Blind users can't tell what this control does because screen readers find no label, so add visible text, aria-label, or aria-labelledby.

Give every interactive control a label screen readers can read.

(control-has-associated-label)

🔇 Additional comments (1)
hooks/index.ts (1)

5-5: LGTM!

Comment thread app/[locale]/(dashboard)/settings/page.tsx Outdated
Comment thread components/graph/supply-chain-graph.tsx
Comment thread hooks/use-preferences.ts
Signed-off-by: Arghyadeep Bag <arghyadeep192@gmail.com>
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
eco-sphere Ready Ready Preview, Comment Jul 22, 2026 6:38pm

@arghya29 arghya29 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@Dev1822 there was a minor build error due to packagelock file out of sync, I have fixed it. LGTM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 04274925-4705-428d-8696-fb687436732a

📥 Commits

Reviewing files that changed from the base of the PR and between a37451a and 3679f66.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • app/[locale]/(dashboard)/settings/page.tsx
  • components/graph/supply-chain-graph.tsx
  • package.json
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: test (18.x)
  • GitHub Check: test (20.x)
🧰 Additional context used
🪛 React Doctor (0.7.6)
app/[locale]/(dashboard)/settings/page.tsx

[warning] 74-74: Blind users can't tell what this control does because screen readers find no label, so add visible text, aria-label, or aria-labelledby.

Give every interactive control a label screen readers can read.

(control-has-associated-label)

🔇 Additional comments (3)
package.json (1)

63-64: LGTM!

app/[locale]/(dashboard)/settings/page.tsx (1)

10-20: LGTM!

Also applies to: 67-89

components/graph/supply-chain-graph.tsx (1)

28-28: LGTM!

Also applies to: 79-82, 116-116, 120-138

Comment on lines +117 to +118
const thickness = emissions !== undefined ? Math.min(6, Math.max(1.5, 1.5 + (emissions / 2000))) : 1.5;
const speed = emissions !== undefined ? Math.max(0.5, 3 - (emissions / 4000)) : 2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep animation duration within the promised 2s–0.5s range.

At zero emissions this calculates 3s, and negative emissions produce durations above 3s; only the lower bound is clamped. Normalize non-negative emissions and clamp the result to both 0.5s and 2s.

Proposed fix
-      const speed = emissions !== undefined ? Math.max(0.5, 3 - (emissions / 4000)) : 2;
+      const speed =
+        emissions !== undefined
+          ? Math.min(2, Math.max(0.5, 2 - Math.max(0, emissions) / 4000))
+          : 2;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const thickness = emissions !== undefined ? Math.min(6, Math.max(1.5, 1.5 + (emissions / 2000))) : 1.5;
const speed = emissions !== undefined ? Math.max(0.5, 3 - (emissions / 4000)) : 2;
const thickness = emissions !== undefined ? Math.min(6, Math.max(1.5, 1.5 + (emissions / 2000))) : 1.5;
const speed =
emissions !== undefined
? Math.min(2, Math.max(0.5, 2 - Math.max(0, emissions) / 4000))
: 2;

@arghya29
arghya29 merged commit e44cd44 into arghya29:dev Jul 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add flow animations to supply-chain graph edges

2 participants