Skip to content

Refactor Opportunity: OrderStatusChip — Styling, Logic Safety, and UI Enhancements #53

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

Open
hamedaravane opened this issue May 14, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@hamedaravane
Copy link
Collaborator

📌 Summary

The OrderStatusChip is a small but important visual indicator of an order’s lifecycle stage. It currently fulfills its role, but there are several areas where improvements can be made for better visual consistency, logic safety, and maintainability.


🔎 Identified Problems

1. No Fallback for Unexpected Status

  • Issue: If a new OrderStatus is added in the backend but not in statusStyles, it will silently render with no styling.
  • Impact: Visually broken chip, poor user feedback.
  • Refactor Area: Defensive logic, future-proofing.

2. Hardcoded clsx Style Map

  • Issue: statusStyles is tightly coupled to Tailwind class strings.
  • Impact: Hard to update design system or theming centrally.
  • Refactor Area: Scalability, maintainability.

3. No Semantic Tag or a11y Enhancements

  • Issue: Rendered as a generic <span> without ARIA roles or descriptive metadata.
  • Impact: Poor accessibility and screen reader support.
  • Refactor Area: Accessibility (a11y).

4. Visual Uniformity Across Theme Modes

  • Issue: Tailwind color utilities like bg-yellow-100 may appear unreadable in dark mode if not adjusted.
  • Impact: Poor contrast in some user environments.
  • Refactor Area: Theme responsiveness, dark mode support.

5. Missing UI Tokenization

  • Issue: No visual icons or cues (e.g., checkmark for completed, x for canceled).
  • Impact: Slower visual recognition by users.
  • Refactor Area: UX enhancement, readability.

6. Redundant Text

  • Issue: status string is shown in raw form (e.g., PROCESSING, REFUNDED) via .toString().
  • Impact: Not user-friendly. Lacks spacing or formatting.
  • Refactor Area: UX, text formatting.

7. Inflexibility in Reuse

  • Issue: Hardcoded styles and layout make the chip hard to reuse in different layouts (e.g., condensed tables, dashboards).
  • Impact: Limits design flexibility.
  • Refactor Area: Component generalization, reusability.

8. No Tooltip for Complex States

  • Issue: More advanced states like REFUNDED or CANCELED may require additional context.
  • Impact: Leaves users confused about implications.
  • Refactor Area: UX clarity.

🧪 Questions to Consider in Refactor

  • Should the chip degrade gracefully with a default style if statusStyles[status] is undefined?
  • Would introducing icons or tooltips improve usability and reduce reliance on text?
  • Should this component expose a variant or size prop for flexible reuse?
  • Can status formatting be extracted into a helper function (e.g., formatOrderStatus)?

📂 File

/libs/orders/components/order-status-chip.tsx

🧠 Bonus Ideas

  • Centralize status-to-style mappings for orders, payments, and shipments in one statusStyleMap utility.
  • Internationalize status labels if localization support is planned (t('status.processing')).
  • Add snapshot or unit tests to ensure all statuses are styled correctly.
@hamedaravane hamedaravane added the enhancement New feature or request label May 14, 2025
@1amGenius
Copy link
Contributor

LOADING....

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

No branches or pull requests

2 participants