You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GS Unified Components - Library Standards & Development Guidelines
Overview
This document outlines the standards and guidelines for multi-team development of the GS Unified Components library, derived from patterns established during the VR-555 cleanup and enhancement work. The library is built on a foundation of shadcn/ui primitives with GS-specific theming and composite components.
All primitive components MUST be derived from shadcn/ui patterns and maintain compatibility with the shadcn/ui ecosystem while incorporating GS brand theming.
π¨ Primitive Component Standards
Required shadcn/ui Patterns
1. Class Variance Authority (CVA)
For components with variants, use CVA for type-safe styling:
Only use explicit forwardRef when component logic needs direct ref access:
import*asReactfrom"react";constCustomInput=React.forwardRef<HTMLInputElement,InputProps>(({ onFocus, ...props},ref)=>{// Only when you need to use the ref in component logicconsthandleFocus=()=>{if(ref&&'current'inref&&ref.current){ref.current.select();// Direct ref manipulation}onFocus?.();};return<inputref={ref}onFocus={handleFocus}{...props}/>;});
4. Radix UI Integration
When applicable, use Radix UI primitives as the foundation:
interfaceButtonPropsextendsReact.ButtonHTMLAttributes<HTMLButtonElement>,VariantProps<typeofbuttonVariants>{asChild?: boolean;// For Slot compatibility}// Export the interface for external useexport{Button,buttonVariants,typeButtonProps};
All primitives must include appropriate accessibility features:
// Development-time accessibility warningsif(process.env.NODE_ENV!=="production"){if(size==="icon"&&!hasVisibleText&&!hasAriaLabel){console.warn("Accessibility issue: Icon button is missing an aria-label. "+"Please add an aria-label attribute to describe the button purpose for screen readers.");}}
Strict typing: All components must use proper TypeScript interfaces
Export interfaces: All component props interfaces must be exported
No any types: Use proper type assertions with ESLint disable comments when necessary
// β Good - Proper interface with exportexportinterfacePricingOptionsProps{plans: PricingPlan[];columns?: 2|3|4;}// β Bad - Using anyconstIconComponent=(Iconsasany)[iconName];// β Good - Proper type assertion with ESLint disableconstIconComponent=// eslint-disable-next-line @typescript-eslint/no-explicit-any(IconsasunknownasRecord<string,React.ComponentType<LucideProps>>)[iconName]||Icons.Check;
src/styles/
βββ index.css # Main entry - includes all themes
βββ base.css # Base Tailwind + fonts, variables, utilities
βββ default.css # Default theme + base
βββ roadside.css # Roadside theme + base
βββ themes/
βββ colors.css # GS brand colors
βββ default.css # Default theme variables
βββ roadside.css # Roadside theme variables
Import Standards
/* β Recommended - All themes */@import"@goodsamenterprises/gs-unified-components/styles";
/* β Specific theme only */@import"@goodsamenterprises/gs-unified-components/styles/roadside";
API compatibility: Note any deviations from shadcn/ui
Theme usage: Document semantic token usage
Changelog maintenance: Keep CHANGELOG.md up to date with all changes
Changelog Standards
All changes must be documented in CHANGELOG.md following these guidelines:
Format
## [Version] - YYYY-MM-DD### Added- New features and components
### Changed- Changes to existing functionality
- API improvements and simplifications
### Fixed- Bug fixes and corrections
### Removed- Deprecated features and breaking changes
Change Categories
Added: New features, components, or capabilities
Changed: Modifications to existing functionality, API improvements
Fixed: Bug fixes, accessibility improvements, type corrections
Include component names: Reference specific components affected
Note breaking changes: Clearly mark any breaking changes
Provide context: Explain the benefit or reason for the change
Examples
### Changed-**PricingOptions**: Removed unnecessary `variant` prop - component now only supports card layout as per Figma design
-**Button**: Updated to use automatic ref forwarding instead of forwardRef for better React 19 compatibility
### Fixed-**Icon handling**: Fixed TypeScript errors with dynamic icon casting in composite components
-**Storybook**: Corrected minimum column values from 1 to 2 across all story controls
### Removed-**Test files**: Removed unused `*.test.tsx` files in favor of Storybook-based testing
-**ESP theme**: Consolidated ESP theme with default theme to reduce complexity
This standards document ensures consistency with modern React and the shadcn/ui ecosystem while maintaining GS brand requirements and multi-team development practices.