Component Guidelines
Component Guidelines¶
General Guidelines¶
- Required Fields: Look for the red asterisk (*) next to labels
- Error Messages: Red text appears below fields when something is wrong
- Disabled Elements: Grayed-out elements cannot be used right now
- Hover Effects: Elements that can be clicked change appearance when you hover
Accessibility¶
All components follow accessibility best practices:
- Focus Ring: Blue outline shows which element is selected
- Labels: Every input has a descriptive label
- Alt Text: Images have descriptions for screen readers
- Keyboard Support: All actions can be done without a mouse
Keyboard Navigation¶
- Tab - Move to next field
- Shift + Tab - Move to previous field
- Enter - Submit form or click focused button
- Escape - Close modal or cancel action
- Space - Toggle checkbox or select option
Responsive Design¶
Components adapt to different screen sizes:
- Mobile First: Optimized for mobile devices
- Tablet Support: Adjusted layouts for tablet screens
- Desktop Enhancement: Full feature set on desktop
- Touch Friendly: Adequate touch target sizes
Theming¶
Components use design tokens for consistent theming:
- Colors: Defined in Tailwind config
- Typography: Consistent font scales
- Spacing: Standard spacing units
- Shadows: Elevation system
- Border Radius: Consistent corner rounding
Color Meanings¶
Throughout the app, colors have consistent meanings:
- Blue - Primary actions, info, links
- Green - Success, Open Access, available
- Orange - Warnings, important notices
- Red - Errors, delete actions, restricted
- Gray - Disabled, secondary text, borders
- Emerald Green - Smart Search active
Performance¶
Components are optimized for performance:
- Code Splitting: Components lazy-loaded when needed
- Memoization: Prevent unnecessary re-renders
- Optimized Re-renders: React.memo for pure components
- Efficient Event Handlers: Debounced and throttled where appropriate
Common Patterns¶
Creating Something New¶
- Click the "Create" or "Add" button (usually blue)
- A modal appears with a form
- Fill in the required fields (marked with *)
- Click "Create" or "Save"
- A success toast appears
- The modal closes
- The new item appears in the list
Editing Existing Items¶
- Find the item
- Click the edit icon or open the 3-dot menu
- Select "Edit"
- A modal appears with current values filled in
- Change what you want
- Click "Save" or "Update"
- Changes appear immediately
Deleting Items¶
- Find the item
- Click delete icon or open 3-dot menu
- Select "Delete"
- A confirmation modal appears
- Read the warning
- Click "Delete" to confirm (red button)
- Item is removed from the list
Searching and Filtering¶
- Quick Search: Type in the search bar at the top
- Advanced Filters: Click "Filters" button
- Select your filter criteria (license, date, size, etc.)
- Click "Apply"
- Results update to match your filters
- Click "Clear All" to remove filters
Adding to Collections¶
- Find a dataset
- Click the "ADD" button
- Choose tab: "Add to existing" or "Create new"
- Select collection(s) or enter new collection name
- Click "Add" or "Create"
- Toast confirms success
- Dataset appears in the collection
Testing¶
Components are thoroughly tested:
- Unit Tests: Individual component behavior
- Integration Tests: Component interactions
- E2E Tests: Full user workflows with Cypress
- Visual Regression: Automated screenshot comparison
- Accessibility Tests: Automated a11y checks
Best Practices¶
Using Components¶
- Import from UI folder:
import { Button } from '@/components/ui/Button' - Use TypeScript types: Leverage type safety for props
- Follow naming conventions: Use descriptive prop names
- Compose components: Build complex UIs from simple components
- Handle edge cases: Test with empty states, errors, loading
Styling¶
- Use Tailwind classes: Leverage utility classes for consistency
- Follow design system: Use defined colors, spacing, typography
- Avoid inline styles: Prefer className composition
- Responsive utilities: Use Tailwind responsive prefixes (sm:, md:, lg:)
- Custom styles sparingly: Only when design system doesn't cover use case
State Management¶
- Local state first: Use useState for component-specific state
- Lift state up: Share state between components via props
- Context for shared state: Use React Context for wider scope
- Props over context: Prefer explicit props for clarity
- Controlled components: Let parent control component state when needed
Need Help?¶
If you encounter any issues or need assistance:
- Check this guide for component information
- Look for tooltips (hover over icons)
- Read error messages carefully (they tell you how to fix problems)
- Contact the DataGEMS Help Desk