Skip to content

Conversation

@raaymax
Copy link
Owner

@raaymax raaymax commented Jan 31, 2026

Summary

Refactors atom components to follow the presentational component pattern. Atoms now receive all data via props instead of accessing global state or API clients directly, improving testability and separation of concerns.

Changes

Atoms (now pure presentational)

  • Image: Remove MobX observer and client dependency; receive src, downloadUrl, size via props
  • File: Remove observer wrapper; receive file data via props
  • ProfilePic: Remove observer and useApp hook; receive avatarUrl and status via props
  • ThemeButton: Simplify to receive theme and onToggle via props

Moved to Molecules

  • LoggedUser: Moved from atoms to molecules since it requires app context for user data
  • ThemeButtonConnected: New molecule that wraps ThemeButton with theme context

Updated Parent Components

  • Files: Now resolves file URLs before passing to Image/File atoms
  • Message: Passes resolved avatar URLs to ProfilePic
  • NavUsers: Passes user data props to ProfilePic
  • ReadReceipt: Passes avatar URLs to ProfilePic
  • ThreadInfo: Passes resolved props to child atoms
  • DiscussionHeader: Updated to use new component APIs
  • Sidebar: Uses ThemeButtonConnected instead of ThemeButton

Testing

  • Storybook stories updated for all changed atoms
  • Stories now provide mock data directly instead of relying on global state

Notes

This follows atomic design principles where atoms should be stateless and receive all data via props, making them easier to test and reuse.

- Remove MobX observer wrappers from atom components
- Remove direct client/API dependencies from atoms
- Pass data via props instead of accessing global state
- Move LoggedUser from atoms to molecules (it uses app context)
- Create ThemeButtonConnected molecule for stateful theme toggle
- Update parent components to pass required props
- Simplify Image, File, ProfilePic to be pure presentational components
@raaymax raaymax merged commit c9438cd into dev Jan 31, 2026
1 check passed
@raaymax raaymax deleted the refactor/atoms-presentational-components branch January 31, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants