Skip to content

Conversation

@joaosoutto
Copy link
Contributor

@joaosoutto joaosoutto commented Dec 30, 2024

Original Story:
Acceptance Criteria
Context:
The BaseApp Frontend Packages https://github.com/silverlogic/baseapp-frontend contains a number of pages and components that currently have Storybook stories but are missing corresponding MDX documentation files.

Create MDX Documentation Files: For each missing component or page listed below, create an .mdx file in the storybook folder within the component’s or page's directory.

Follow Documentation Standards: Use the MDX Documentation Template provided in our Tettra guide https://app.tettra.co/teams/TSL/pages/frontend-documentation-guide

Please check examples on:

https://bitbucket.org/silverlogic/baseapp-frontend-template/src/master/apps/web/components/design-system/inputs/PasswordField/__storybook__/PasswordField.mdx

https://bitbucket.org/silverlogic/baseapp-frontend-template/src/master/apps/web/app/(with-navigation)/__storybook__/HomePage.mdx

Missing MDX:

CommentsList

Comments

CommentUpdate

CommentCreate

CommentItem

NotificationsList

NotificationItem

NotificationsPopover

SocialInput

Timestamp

SocialUpsertActions

SendMessage

Current behavior

Expected behavior

Code Snippet

Approvd
https://app.approvd.io/projects/BA/stories/36742

Summary by CodeRabbit

  • Documentation

    • Added comprehensive Storybook documentation for multiple components:
      • Social Input
      • Social Upsert Actions
      • Timestamp
      • Comments (Create, Update, Item, List)
      • Send Message
      • Notifications (Item, List, Popover)
    • Removed Notifications module documentation
  • Chores

    • Updated Storybook documentation structure across various modules

@changeset-bot
Copy link

changeset-bot bot commented Dec 30, 2024

⚠️ No Changeset found

Latest commit: e0a3dd6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Collaborator

@deboracosilveira deboracosilveira left a comment

Choose a reason for hiding this comment

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

plase update the title of all mdx. They all include "@baseapp-frontend-template" which is wrong, since we are talking about the packages. Besides that, the idea is that document pages live close to the referring component, like on the image.
image
To do so, use the same name of the stories, eg @baseapp-frontend | designSystem/Avatars/AvatarWithPlaceholder

@coderabbitai
Copy link

coderabbitai bot commented Jan 3, 2025

Walkthrough

This pull request introduces comprehensive Storybook documentation for multiple components across different modules, including Comments, Messages, Notifications, and Shared components. The documentation provides detailed insights into each component's purpose, props, use cases, and example implementations. While the Notifications module's previous documentation was removed, new, more structured documentation has been added for individual notification-related components.

Changes

File Path Change Summary
packages/components/modules/__shared__/SocialInput/__storybook__/SocialInput.mdx New documentation for SocialInput component
packages/components/modules/__shared__/SocialUpsertActions/__storybook__/SocialUpsertActions.mdx New documentation for SocialUpsertActions component
packages/components/modules/__shared__/Timestamp/__storybook__/Timestamp.mdx New documentation for Timestamp component
packages/components/modules/comments/... New Storybook documentation for Comment-related components: CommentCreate, CommentItem, CommentUpdate, Comments, CommentsList
packages/components/modules/messages/SendMessage/__storybook__/MessagesModule.mdx New documentation for SendMessage component
packages/components/modules/notifications/... New Storybook documentation for Notification-related components: NotificationItem, NotificationsList, NotificationsPopover
packages/components/modules/notifications/__storybook__/NotificationsModule.mdx Removed previous Notifications module documentation

Possibly related PRs

Suggested reviewers

  • deboracosilveira
  • anicioalexandre
  • Ronan-Fernandes
  • pt-tsl

Poem

🐰 Hop, hop, documentation's here!
Components dancing, crystal clear
Storybook pages, neatly arrayed
Each module's secrets now displayed
Code rabbits rejoice, knowledge unfurled! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (10)
packages/components/modules/messages/__storybook__/MessagesModule.mdx (2)

23-26: Enhance props documentation with type information and validation rules.

Consider adding:

  • Type information for each prop (e.g., React.ComponentType<SocialInputProps> for the SocialInput prop)
  • Validation rules or constraints where applicable
  • Default values for optional props

38-45: Enhance example usage with error handling and realistic props.

The current example is basic. Consider expanding it to demonstrate:

  • Error handling for failed submissions
  • Loading states
  • Custom input component usage
  • Form validation
 const MyComponent = () => {
+  const [isLoading, setIsLoading] = useState(false)
+  const handleError = (error) => {
+    console.error('Failed to send message:', error)
+  }
   return (
-    <SendMessage roomId="123" />
+    <SendMessage
+      roomId="123"
+      isLoading={isLoading}
+      onError={handleError}
+      SocialInputProps={{
+        placeholder: "Type your message...",
+        autoFocusInput: true
+      }}
+    />
   )
 }
packages/components/modules/__shared__/__storybook__/SharedModule.mdx (3)

47-74: Enhance SocialInput example with proper form handling.

The current example uses a simplified form implementation. Consider showing a more realistic example with proper form handling:

 const MyComponent = () => {
-  const useForm = () => ({
-    register: () => ({}),
-    handleSubmit: () => ({}),
-    formState: { errors: {} },
-  })
+  const {
+    register,
+    handleSubmit,
+    formState: { errors }
+  } = useForm({
+    defaultValues: {
+      message: ''
+    },
+    mode: 'onChange'
+  })
+
+  const onSubmit = async (data) => {
+    try {
+      await submitMessage(data)
+    } catch (error) {
+      console.error('Failed to submit:', error)
+    }
+  }

   return (
     <SocialInput
       isLoading={false}
-      isReply={false}
+      isReply={true}
+      replyTargetName="John Doe"
       placeholder={'Message...'}
       autoFocusInput={false}
-      SocialTextFieldProps={{}}
+      SocialTextFieldProps={{
+        maxLength: 1000,
+        multiline: true
+      }}
       SubmitActionsProps={{}}
       formId={'text-field-form'}
-      submit={() => {}}
+      submit={handleSubmit(onSubmit)}
       onCancelReply={() => {}}
-      form={useForm()}
+      form={{ register, handleSubmit, formState: { errors } }}
     />
   )
 }

80-91: Add timezone handling information to Timestamp documentation.

The documentation should mention:

  • How the component handles different timezones
  • Available date format options
  • Localization support

113-128: Clarify current limitations of SocialUpsertActions.

Currently, the documentation lists future props that aren't implemented. Consider:

  • Clearly marking which features are currently available vs. planned
  • Adding a "Limitations" section
  • Removing or clearly marking unimplemented props as "Future Implementation"
🧰 Tools
🪛 LanguageTool

[uncategorized] ~114-~114: A comma may be missing after the conjunctive/linking adverb ‘Currently’.
Context: ...n buttons for different social actions. Currently displays disabled attachment and mentio...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)


[uncategorized] ~123-~123: Possible missing comma found.
Context: ...tly, this component does not accept any props as it renders a fixed set of disabled b...

(AI_HYDRA_LEO_MISSING_COMMA)

packages/components/modules/comments/__storybook__/CommentsModule.mdx (2)

70-72: Add pagination and performance considerations.

The CommentsList documentation should include information about:

  • How pagination is implemented
  • Performance considerations for large lists
  • Caching strategies
  • Optimistic updates

157-192: Enhance example with TypeScript types.

The example code could benefit from proper TypeScript types for better type safety and documentation:

 import { CommentItem } from '@baseapp-frontend/design-system'
+
+interface Comment {
+  id: string
+  body: string
+}
+
+interface Target {
+  id: string
+  name: string
+}
+
+interface ActionOverlayProps {
+  onDelete: () => void
+}
+
+interface CommentUpdateProps {
+  onCancel: () => void
+}

 const MyComponent = () => {
-  const comment = {
+  const comment: Comment = {
     id: '123',
     body: 'This is a comment',
   }
-  const target = {
+  const target: Target = {
     id: '456',
     name: 'Target Object',
   }
packages/components/modules/notifications/__storybook__/NotificationsModule.mdx (3)

94-99: Enhance prop type documentation

The props documentation would be more helpful with specific type information and default values.

Consider updating the props documentation to include more specific types:

- **setIsDrawerOpened** (function): Callback to control the drawer's open state
+ **setIsDrawerOpened** ((isOpen: boolean) => void): Callback to control the drawer's open state
- **EmptyState** (component): Custom component to show when there are no notifications
+ **EmptyState** (React.ComponentType): Custom component to show when there are no notifications
- **LoadingState** (component): Custom loading component
+ **LoadingState** (React.ComponentType): Custom loading component
- **NotificationItem** (component): Custom notification item component
+ **NotificationItem** (React.ComponentType<NotificationItemProps>): Custom notification item component

164-169: Improve example notification object structure

The example notification object should better reflect the actual NotificationItemFragment type structure.

Consider updating the example to show a more realistic notification structure:

   const notification = {
     id: '123',
-    title: 'Notification Title',
-    body: 'Notification Body',
+    verb: 'COMMENT_CREATED',
+    actor: {
+      id: '456',
+      fullName: 'John Doe',
+      avatar: {
+        url: 'https://example.com/avatar.jpg'
+      }
+    },
+    target: {
+      id: '789',
+      type: 'POST'
+    },
     read: false,
+    createdAt: '2025-01-15T12:00:00Z'
   }

Line range hint 250-268: Consider adding TypeScript types

The example would be more robust with proper TypeScript type definitions.

Consider updating the example to include TypeScript types:

   import Notification from './Notification'
+  import { NotificationProps } from './types'

-  const NewNotificationVerb = ({ notification }) => (
+  const NewNotificationVerb: React.FC<{ notification: NotificationProps }> = ({ notification }) => (
     <Notification.Root>
       <Notification.Avatar
         actorAvatar={notification.actor?.avatar?.url}
         actorName={notification.actor?.fullName}
       />
       <Notification.Content>
         <Notification.Content.Header
           message={`New custom message: ${notification.customField}`}
           timestamp={notification.timestamp}
           actorName={notification.actor?.fullName}
           unread={notification.unread}
         />
         <Notification.Content.Body content={notification.customBody} />
       </Notification.Content>
     </Notification.Root>
   )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c8666c and 08db095669609e9e0691527a451b8642709e3f9b.

📒 Files selected for processing (4)
  • packages/components/modules/__shared__/__storybook__/SharedModule.mdx (1 hunks)
  • packages/components/modules/comments/__storybook__/CommentsModule.mdx (1 hunks)
  • packages/components/modules/messages/__storybook__/MessagesModule.mdx (1 hunks)
  • packages/components/modules/notifications/__storybook__/NotificationsModule.mdx (4 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/components/modules/__shared__/__storybook__/SharedModule.mdx

[uncategorized] ~114-~114: A comma may be missing after the conjunctive/linking adverb ‘Currently’.
Context: ...n buttons for different social actions. Currently displays disabled attachment and mentio...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)


[uncategorized] ~123-~123: Possible missing comma found.
Context: ...tly, this component does not accept any props as it renders a fixed set of disabled b...

(AI_HYDRA_LEO_MISSING_COMMA)

Comment on lines 134 to 143
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove duplicate prop definition.

The CommentUpdate prop is defined twice in the CommentItem props list (lines 134 and 142). Remove the duplicate entry.

- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
  **CommentUpdateProps** (object): Props passed to the CommentUpdate component.
  **CommentRepliesProps** (object): Props passed to the CommentsReplies component.
  **CommentReactionButton** (component): Custom reaction button component. Defaults to DefaultCommentReactionButton.
  **CommentReplyButton** (component): Custom reply button component. Defaults to DefaultCommentReplyButton.
  **CommentPinnedBadge** (component): Custom pinned badge component. Defaults to DefaultCommentPinnedBadge.
  **Timestamp** (component): Custom timestamp component. Defaults to DefaultTimestamp.
  **CommentsRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
📝 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
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
- **CommentUpdateProps** (object): Props passed to the CommentUpdate component.
- **CommentRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentReactionButton** (component): Custom reaction button component. Defaults to DefaultCommentReactionButton.
- **CommentReplyButton** (component): Custom reply button component. Defaults to DefaultCommentReplyButton.
- **CommentPinnedBadge** (component): Custom pinned badge component. Defaults to DefaultCommentPinnedBadge.
- **Timestamp** (component): Custom timestamp component. Defaults to DefaultTimestamp.
- **CommentsRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
**CommentUpdateProps** (object): Props passed to the CommentUpdate component.
**CommentRepliesProps** (object): Props passed to the CommentsReplies component.
**CommentReactionButton** (component): Custom reaction button component. Defaults to DefaultCommentReactionButton.
**CommentReplyButton** (component): Custom reply button component. Defaults to DefaultCommentReplyButton.
**CommentPinnedBadge** (component): Custom pinned badge component. Defaults to DefaultCommentPinnedBadge.
**Timestamp** (component): Custom timestamp component. Defaults to DefaultTimestamp.
**CommentsRepliesProps** (object): Props passed to the CommentsReplies component.

Comment on lines 48 to 64
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect implementation in the example code

The example code contains several issues that need to be addressed:

  1. The custom component implementations are incorrect (they should be actual component definitions)
  2. There's a conflict with NotificationBellIcon import and implementation
  3. NotificationsList is passed as an object instead of a component

Here's the corrected implementation:

-import { Badge, Drawer, NotificationBellIcon, NotificationsList } from '@mui/material'
+import { Badge, Drawer } from '@mui/material'
+import NotificationBellIcon from './NotificationBellIcon'
+import CustomNotificationsList from './CustomNotificationsList'

 const MyComponent = () => {
-  const Drawer = () => <div>Drawer</div>
-  const Badge = () => <div>Badge</div>
-  const NotificationBellIcon = () => <NotificationBellIcon />
+  const CustomDrawer = ({ children, ...props }) => (
+    <div {...props}>{children}</div>
+  )
+  const CustomBadge = ({ children, ...props }) => (
+    <div {...props}>{children}</div>
+  )
   return (
     <NotificationsPopover
-      Drawer={Drawer}
-      Badge={Badge}
+      Drawer={CustomDrawer}
+      Badge={CustomBadge}
       DrawerProps={{}}
       BadgeProps={{}}
       NotificationBellIcon={NotificationBellIcon}
       NotificationBellIconProps={{}}
-      NotificationsList={{}}
+      NotificationsList={CustomNotificationsList}
       NotificationsListProps={{}}
     />
   )

Committable suggestion skipped: line range outside the PR's diff.

@joaosoutto joaosoutto requested a review from sundayguru January 7, 2025 13:49
@joaosoutto joaosoutto force-pushed the BA-2021-missing-MDX-group3 branch from a3cce60 to 1ce3702 Compare January 8, 2025 15:30
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 8, 2025

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (21)
packages/components/modules/notifications/NotificationsPopover/__storybook__/NotificationsPopover.mdx (4)

9-10: Enhance component overview with accessibility and mobile details.

The purpose and behavior descriptions are clear, but consider adding:

  • Accessibility features (e.g., ARIA labels, keyboard navigation)
  • Detailed mobile behavior (e.g., touch interactions, swipe gestures)

30-33: Enhance related components section with links and interactions.

Consider enhancing the related components section with:

  • Links to the documentation of each related component
  • Brief description of how these components interact with NotificationsPopover

35-37: Remove duplicate "Example" headings.

There are duplicate headings:

  • Line 35: "Example Usage"
  • Line 37: "Usage Examples"

Consider removing one of them for better documentation structure.


41-139: Enhance code examples with TypeScript and error handling.

Consider adding:

  • TypeScript examples with proper type definitions
  • Error handling examples (e.g., network errors, empty states)
  • Real-world data examples with realistic notification content

Example TypeScript enhancement:

interface NotificationProps {
  notification: {
    actor?: {
      avatar?: {
        url: string;
      };
      fullName: string;
    };
    timestamp: string;
    unread: boolean;
    customField?: string;
    customBody?: string;
  }
}

const NewNotificationVerb: React.FC<NotificationProps> = ({ notification }) => (
  // ... existing implementation
);
packages/components/modules/__shared__/SocialUpsertActions/__storybook__/SocialUpsertActions.mdx (5)

9-10: Minor grammar improvement needed.

Add a comma after "Currently" for better readability.

-- **Expected Behavior**: Renders a horizontal grid of icon buttons for different social actions. Currently displays disabled attachment and mention buttons.
++ **Expected Behavior**: Renders a horizontal grid of icon buttons for different social actions. Currently, displays disabled attachment and mention buttons.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~10-~10: A comma may be missing after the conjunctive/linking adverb ‘Currently’.
Context: ...n buttons for different social actions. Currently displays disabled attachment and mentio...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)


14-15: Consider enhancing use case examples.

While the current and potential use cases are good, consider adding specific examples of where and how the component is currently being used in the application. This would help developers better understand the component's real-world applications.


19-23: Enhance props documentation with TypeScript types.

Consider adding TypeScript type definitions for the future props and structuring them in a table format for better readability.

Example structure:

### Future Props

| Prop | Type | Description |
|------|------|-------------|
| onAttachmentClick | () => void | Handler for attachment button clicks |
| onMentionClick | () => void | Handler for mention button clicks |
| disabled | boolean | Controls the disabled state of buttons |

27-31: Add implementation details and dependencies.

Consider enhancing the Notes section with:

  • Required package dependencies and versions
  • Implementation considerations or gotchas
  • Links to the documentation of related components

35-41: Enhance example with realistic usage patterns.

Consider expanding the example to demonstrate:

  • Integration with SocialInput
  • Event handler implementation
  • Disabled state usage
 ```javascript
 import { SocialUpsertActions } from '@baseapp-frontend/design-system'
 
 const MyComponent = () => {
+  const handleAttachmentClick = () => {
+    // Implementation
+  }
+
+  const handleMentionClick = () => {
+    // Implementation
+  }
+
   return (
-    <SocialUpsertActions />
+    <SocialUpsertActions
+      onAttachmentClick={handleAttachmentClick}
+      onMentionClick={handleMentionClick}
+      disabled={false}
+    />
   )
 }
packages/components/modules/__shared__/Timestamp/__storybook__/Timestamp.mdx (5)

1-3: Add component parameter to Meta for automatic props documentation.

Consider enhancing the Meta configuration to enable automatic props table generation:

import { Meta } from '@storybook/addon-docs'
+import { Timestamp } from '@baseapp-frontend/design-system'

-<Meta title="@baseapp-frontend | components/Shared/Timestamp" />
+<Meta 
+  title="@baseapp-frontend | components/Shared/Timestamp"
+  component={Timestamp}
+/>

17-20: Enhance props documentation with additional details.

Consider adding more comprehensive prop documentation:

## Props

-**date** (string): An ISO format date string that will be converted and displayed. Example: "2024-07-17T11:42:55.508653+00:00"
+### date
+- **Type**: `string`
+- **Required**: `true`
+- **Description**: An ISO format date string that will be converted and displayed
+- **Example**: `"2024-07-17T11:42:55.508653+00:00"`
+- **Validation**: Must be a valid ISO 8601 date string

28-37: Add more comprehensive usage examples.

Consider adding examples that demonstrate:

  • Error handling for invalid dates
  • Different date formats
  • Real-world integration scenarios
## Example Usage

```javascript
import { Timestamp } from '@baseapp-frontend/design-system'

const MyComponent = () => {
  return <Timestamp date="2024-07-17T11:42:55.508653+00:00" />
}
export default MyComponent

+### Error Handling Example
+```javascript
+const MyComponentWithErrorHandling = () => {

  • try {
  • return
  • } catch (error) {
  • return Invalid date format
  • }
    +}
    +```

+### Common Use Cases
+```javascript
+// In a message list
+const MessageItem = ({ message }) => (

  • {message.content}

+)
+
+// In a notification
+const NotificationItem = ({ notification }) => (

  • {notification.message}

+)
+```


---

`21-27`: **Expand notes section with additional details and links.**

Consider enhancing the notes section with:
- Links to related component documentation
- Details about available time format options
- Information about timezone handling

```diff
## Notes

- **Related Components**:
-  - Typography - Used for consistent text styling
-  - Uses luxon's DateTime for date parsing and formatting
-  - Integrates with the application's TIME_FORMAT constants for consistent time display
+- **Related Components**:
+  - [Typography](/docs/components-shared-typography--docs) - Used for consistent text styling
+  - [DateTime](https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html) - Luxon's DateTime for date parsing
+
+- **Time Format Options**:
+  - Default format: Defined in `TIME_FORMAT.DEFAULT`
+  - Available formats:
+    - `TIME_FORMAT.SHORT`: "HH:mm"
+    - `TIME_FORMAT.LONG`: "HH:mm:ss"
+    - `TIME_FORMAT.WITH_DATE`: "MMM dd, yyyy HH:mm"
+
+- **Timezone Handling**:
+  - Displays time in user's local timezone
+  - Handles UTC conversion automatically

1-37: Consider adding sections for accessibility, testing, and limitations.

The documentation provides a good foundation but could be enhanced with additional sections:

  1. Accessibility

    • ARIA attributes usage
    • Screen reader behavior
    • Keyboard navigation
  2. Testing Guidelines

    • Unit test examples
    • Integration test scenarios
    • Common test cases
  3. Known Limitations

    • Browser compatibility notes
    • Performance considerations
    • Edge cases

Would you like me to provide example content for these sections?

packages/components/modules/comments/CommentsList/__storybook__/CommentsList.mdx (2)

25-30: Enhance props documentation with specific types and default values

The props section would benefit from more detailed type information and default values. For example:

  • What type of "Reference" is expected for target?
  • What properties are available in CommentItemProps and VirtuosoProps?

41-52: Add TypeScript types to the example code

The example would be more helpful with proper TypeScript type annotations, especially for the targetRef and callback parameters.

-const MyComponent = () => {
+const MyComponent: React.FC = () => {
-  const targetRef = useRef(null)
+  const targetRef = useRef<HTMLDivElement>(null)
   const handleReplyClick = (commentId: string) => {
     console.log('Reply clicked for comment:', commentId)
   }
packages/components/modules/comments/Comments/__storybook__/Comments.mdx (2)

23-29: Clarify required vs optional props and remove duplicate entry

The props section needs improvement:

  • Mark which props are required vs optional
  • CommentCreate and CommentCreateProps appear to be duplicates of props mentioned in the example

41-58: Enhance example with error handling and types

The example could be improved with:

  • Error handling for the callback
  • TypeScript type annotations
  • Documentation of the expected shape of targetRef
-const MyComponent = () => {
+const MyComponent: React.FC = () => {
-  const targetRef = useRef(null)
+  const targetRef = useRef<HTMLDivElement>(null)
-  const handleCommentCreateFocus = () => {
+  const handleCommentCreateFocus = (): void => {
     console.log('Comment create focused')
+    // Add error handling here
   }
packages/components/modules/notifications/NotificationsList/NotificationItem/__storybook__/NotificationItem.mdx (3)

9-10: Add implementation details for the read/unread mutation

The documentation mentions a mutation for marking notifications as read but doesn't provide implementation details. Consider adding:

  • The mutation name/import
  • Example mutation code
  • Any configuration required

14-15: Enhance use cases with specific examples

Consider adding more specific examples of where this component could be used, such as:

  • In a social media feed for interaction notifications
  • In an e-commerce app for order status updates
  • In a chat application for message notifications

24-27: Add component hierarchy visualization

Consider adding a component hierarchy diagram to better illustrate the relationships between:

  • NotificationsList
  • NotificationItem
  • NotificationItemRenderer
  • NotificationsPopover

This would help developers understand the component composition better.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08db095669609e9e0691527a451b8642709e3f9b and e0a3dd6.

📒 Files selected for processing (13)
  • packages/components/modules/__shared__/SocialInput/__storybook__/SocialInput.mdx (1 hunks)
  • packages/components/modules/__shared__/SocialUpsertActions/__storybook__/SocialUpsertActions.mdx (1 hunks)
  • packages/components/modules/__shared__/Timestamp/__storybook__/Timestamp.mdx (1 hunks)
  • packages/components/modules/comments/CommentCreate/__storybook__/CommentCreate.mdx (1 hunks)
  • packages/components/modules/comments/CommentItem/__storybook__/CommentItem.mdx (1 hunks)
  • packages/components/modules/comments/CommentUpdate/__storybook__/CommentUpdate.mdx (1 hunks)
  • packages/components/modules/comments/Comments/__storybook__/Comments.mdx (1 hunks)
  • packages/components/modules/comments/CommentsList/__storybook__/CommentsList.mdx (1 hunks)
  • packages/components/modules/messages/SendMessage/__storybook__/MessagesModule.mdx (1 hunks)
  • packages/components/modules/notifications/NotificationsList/NotificationItem/__storybook__/NotificationItem.mdx (1 hunks)
  • packages/components/modules/notifications/NotificationsList/__storybook__/NotificationsList.mdx (1 hunks)
  • packages/components/modules/notifications/NotificationsPopover/__storybook__/NotificationsPopover.mdx (1 hunks)
  • packages/components/modules/notifications/__storybook__/NotificationsModule.mdx (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/components/modules/notifications/storybook/NotificationsModule.mdx
✅ Files skipped from review due to trivial changes (5)
  • packages/components/modules/messages/SendMessage/storybook/MessagesModule.mdx
  • packages/components/modules/notifications/NotificationsList/storybook/NotificationsList.mdx
  • packages/components/modules/shared/SocialInput/storybook/SocialInput.mdx
  • packages/components/modules/comments/CommentCreate/storybook/CommentCreate.mdx
  • packages/components/modules/comments/CommentUpdate/storybook/CommentUpdate.mdx
🧰 Additional context used
🪛 LanguageTool
packages/components/modules/__shared__/SocialUpsertActions/__storybook__/SocialUpsertActions.mdx

[uncategorized] ~10-~10: A comma may be missing after the conjunctive/linking adverb ‘Currently’.
Context: ...n buttons for different social actions. Currently displays disabled attachment and mentio...

(SENT_START_CONJUNCTIVE_LINKING_ADVERB_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Lint
  • GitHub Check: Component Test Applications and Packages
🔇 Additional comments (3)
packages/components/modules/__shared__/SocialUpsertActions/__storybook__/SocialUpsertActions.mdx (1)

1-3: LGTM! Meta configuration is properly structured.

The Meta tag is correctly imported and the title follows the established naming convention.

packages/components/modules/notifications/NotificationsList/NotificationItem/__storybook__/NotificationItem.mdx (2)

1-3: Verify title structure consistency with other MDX files

The title structure looks appropriate, but let's ensure it follows the same pattern as other MDX files in the codebase.

✅ Verification successful

Title structure follows codebase conventions

The title structure "@baseapp-frontend | components/Notifications/NotificationItem" follows the consistent pattern used across the codebase. There's only one file using a different format with forward slashes, but your implementation follows the majority convention.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check title structure consistency across MDX files
# Expected: All titles should follow similar pattern

# Search for Meta title patterns in MDX files
rg -U 'title="[^"]*"' --type mdx

Length of output: 62


Script:

#!/bin/bash
# Find all MDX files and search for title patterns
fd -e mdx -e stories.mdx -x rg -U 'title="[^"]*"' {}

Length of output: 1266


1-50: Verify documentation against Tettra guide standards

Please ensure this documentation follows all standards outlined in the Tettra guide mentioned in the PR objectives.

Comment on lines +19 to +27
- **Drawer** (Component, optional): Custom drawer component. Defaults to MUI Drawer.
- **DrawerProps** (object, optional): Props passed to the Drawer component.
- **Badge** (Component, optional): Custom badge component. Defaults to MUI Badge.
- **BadgeProps** (object, optional): Props passed to the Badge component.
- **NotificationBellIcon** (Component, optional): Custom notification bell icon component.
- **NotificationBellIconProps** (object, optional): Props passed to the NotificationBellIcon component.
- **NotificationsList** (Component, optional): Custom notifications list component.
- **NotificationsListProps** (object, optional): Props passed to the NotificationsList component.

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance props documentation with additional details.

Please enhance the props documentation with:

  • Required/optional status for all props
  • Detailed type information for object props (e.g., shape of DrawerProps, BadgeProps)
  • Default values for optional props

Example format:

- **DrawerProps** (object, optional):
  - Type: {
    anchor?: 'left' | 'right' | 'top' | 'bottom';
    open?: boolean;
    // ... other properties
  }
  - Default: { anchor: 'right' }
  - Description: Props passed to the Drawer component

Comment on lines +49 to +84
```javascript
import { CommentItem } from '@baseapp-frontend/design-system'

const MyComponent = () => {
const comment = {
id: '123',
body: 'This is a comment',
}
const target = {
id: '456',
name: 'Target Object',
}
return (
<CommentItem
comment={comment}
target={target}
currentThreadDepth={0}
subscriptionsEnabled={true}
onReplyClick={() => {}}
enableDelete={false}
ActionOverlayProps={{
onDelete: () => {
console.log('Delete clicked')
},
}}
CommentUpdate={CommentUpdate}
CommentUpdateProps={{
onCancel: () => {
console.log('Cancel clicked')
},
}}
/>
)
}
export default MyComponent
``` No newline at end of file
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update example to match Relay implementation

The example code doesn't match the actual implementation which uses Relay. The comment and target objects should be Relay fragment references.

-  const comment = {
-    id: '123',
-    body: 'This is a comment',
-  }
-  const target = {
-    id: '456',
-    name: 'Target Object',
-  }
+  // The comment prop should be a Relay fragment reference
+  const comment = useFragment(
+    graphql`
+      fragment CommentItem_comment on Comment {
+        id
+        body
+      }
+    `,
+    commentRef
+  )

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +19 to +35
- **comment** (CommentItem_comment$key): Relay fragment reference for the comment data.
- **target** (Object): The target object for the comment.
- **currentThreadDepth** (number): Current nesting level of the comment thread.
- **subscriptionsEnabled** (boolean): Enables real-time updates for the comment thread.
- **onReplyClick** (function): Callback triggered when reply button is clicked.
- **enableDelete** (boolean): Enables delete functionality. Defaults to false.
- **ActionOverlayProps** (object): Props for customizing the actions overlay.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
- **CommentUpdateProps** (object): Props passed to the CommentUpdate component.
- **CommentRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentReactionButton** (component): Custom reaction button component. Defaults to DefaultCommentReactionButton.
- **CommentReplyButton** (component): Custom reply button component. Defaults to DefaultCommentReplyButton.
- **CommentPinnedBadge** (component): Custom pinned badge component. Defaults to DefaultCommentPinnedBadge.
- **Timestamp** (component): Custom timestamp component. Defaults to DefaultTimestamp.
- **CommentsRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix duplicate props and clarify Relay usage

There are several issues in the props section:

  • CommentUpdate and CommentsRepliesProps are listed twice
  • The comment prop uses Relay types (CommentItem_comment$key) but this isn't explained

Remove the duplicate entries and add explanation for Relay types:

- **CommentsRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
+ **comment** (CommentItem_comment$key): Relay fragment reference for the comment data. This type comes from the Relay compiler and represents a reference to the comment's data in the Relay store.
📝 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
- **comment** (CommentItem_comment$key): Relay fragment reference for the comment data.
- **target** (Object): The target object for the comment.
- **currentThreadDepth** (number): Current nesting level of the comment thread.
- **subscriptionsEnabled** (boolean): Enables real-time updates for the comment thread.
- **onReplyClick** (function): Callback triggered when reply button is clicked.
- **enableDelete** (boolean): Enables delete functionality. Defaults to false.
- **ActionOverlayProps** (object): Props for customizing the actions overlay.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
- **CommentUpdateProps** (object): Props passed to the CommentUpdate component.
- **CommentRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentReactionButton** (component): Custom reaction button component. Defaults to DefaultCommentReactionButton.
- **CommentReplyButton** (component): Custom reply button component. Defaults to DefaultCommentReplyButton.
- **CommentPinnedBadge** (component): Custom pinned badge component. Defaults to DefaultCommentPinnedBadge.
- **Timestamp** (component): Custom timestamp component. Defaults to DefaultTimestamp.
- **CommentsRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
- **comment** (CommentItem_comment$key): Relay fragment reference for the comment data. This type comes from the Relay compiler and represents a reference to the comment's data in the Relay store.
- **target** (Object): The target object for the comment.
- **currentThreadDepth** (number): Current nesting level of the comment thread.
- **subscriptionsEnabled** (boolean): Enables real-time updates for the comment thread.
- **onReplyClick** (function): Callback triggered when reply button is clicked.
- **enableDelete** (boolean): Enables delete functionality. Defaults to false.
- **ActionOverlayProps** (object): Props for customizing the actions overlay.
- **CommentUpdate** (component): Custom comment update component. Defaults to DefaultCommentUpdate.
- **CommentUpdateProps** (object): Props passed to the CommentUpdate component.
- **CommentRepliesProps** (object): Props passed to the CommentsReplies component.
- **CommentReactionButton** (component): Custom reaction button component. Defaults to DefaultCommentReactionButton.
- **CommentReplyButton** (component): Custom reply button component. Defaults to DefaultCommentReplyButton.
- **CommentPinnedBadge** (component): Custom pinned badge component. Defaults to DefaultCommentPinnedBadge.
- **Timestamp** (component): Custom timestamp component. Defaults to DefaultTimestamp.

Comment on lines +19 to +20
- **notification** (NotificationItemFragment): The notification data reference to be rendered. Contains notification content and metadata.
- **NotificationItemRenderer** (FC, optional): Custom renderer component for notification content. Defaults to DefaultNotificationItemRenderer.
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance props documentation with type definitions

Please enhance the props documentation with:

  • Complete type definition for NotificationItemFragment
  • Required/optional status for the notification prop
  • Default values where applicable
  • Prop validation requirements

Comment on lines +31 to +50
```javascript
import { NotificationItem } from '@baseapp-frontend/design-system'

const MyComponent = () => {
const notification = {
id: '123',
title: 'Notification Title',
body: 'Notification Body',
read: false,
}
const NotificationItemRenderer = () => <div>Notification Item Renderer</div>
return (
<NotificationItem
notification={notification}
NotificationItemRenderer={NotificationItemRenderer}
/>
)
}
export default MyComponent
``` No newline at end of file
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance example with real-world usage patterns

The current example is basic. Consider enhancing it with:

  • Complete notification object structure matching NotificationItemFragment
  • Error handling
  • Loading states
  • Custom renderer with actual notification content formatting
  • Handling of read/unread state changes

Example enhancement:

 const MyComponent = () => {
   const notification = {
     id: '123',
     title: 'Notification Title',
     body: 'Notification Body',
     read: false,
+    createdAt: '2024-01-20T10:00:00Z',
+    type: 'COMMENT',
+    metadata: {
+      postId: '456',
+      commentId: '789'
+    }
   }
-  const NotificationItemRenderer = () => <div>Notification Item Renderer</div>
+  const NotificationItemRenderer = ({ notification, onRead }) => {
+    const handleClick = async () => {
+      try {
+        await onRead(notification.id);
+      } catch (error) {
+        console.error('Failed to mark notification as read:', error);
+      }
+    };
+    
+    return (
+      <div onClick={handleClick}>
+        <h3>{notification.title}</h3>
+        <p>{notification.body}</p>
+        <span>{new Date(notification.createdAt).toLocaleString()}</span>
+      </div>
+    );
+  };
   return (
     <NotificationItem
       notification={notification}
       NotificationItemRenderer={NotificationItemRenderer}
     />
   )
 }
📝 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
```javascript
import { NotificationItem } from '@baseapp-frontend/design-system'
const MyComponent = () => {
const notification = {
id: '123',
title: 'Notification Title',
body: 'Notification Body',
read: false,
}
const NotificationItemRenderer = () => <div>Notification Item Renderer</div>
return (
<NotificationItem
notification={notification}
NotificationItemRenderer={NotificationItemRenderer}
/>
)
}
export default MyComponent
```
import { NotificationItem } from '@baseapp-frontend/design-system'
const MyComponent = () => {
const notification = {
id: '123',
title: 'Notification Title',
body: 'Notification Body',
read: false,
createdAt: '2024-01-20T10:00:00Z',
type: 'COMMENT',
metadata: {
postId: '456',
commentId: '789'
}
}
const NotificationItemRenderer = ({ notification, onRead }) => {
const handleClick = async () => {
try {
await onRead(notification.id);
} catch (error) {
console.error('Failed to mark notification as read:', error);
}
};
return (
<div onClick={handleClick}>
<h3>{notification.title}</h3>
<p>{notification.body}</p>
<span>{new Date(notification.createdAt).toLocaleString()}</span>
</div>
);
};
return (
<NotificationItem
notification={notification}
NotificationItemRenderer={NotificationItemRenderer}
/>
)
}
export default MyComponent

@joaosoutto joaosoutto merged commit f132b57 into master Jan 8, 2025
9 checks passed
@nossila nossila deleted the BA-2021-missing-MDX-group3 branch May 26, 2025 21:19
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.

3 participants