Skip to content

Conversation

@deboracosilveira
Copy link
Collaborator

@deboracosilveira deboracosilveira commented Nov 13, 2024

  • Remove unnecessary configurations/docs from Storybook
  • Create example for MDX documentation
  • Create an Intro Page in Storybook explaining its purpose and usage in the project.
  • Refactor component stories to include clear description of the component

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced Storybook documentation capabilities with the addition of @storybook/addon-docs.
    • Introduced comprehensive documentation for the ReactionButton component.
    • Added structured documentation pages for both the BaseApp Components and Design System Storybooks.
  • Bug Fixes

    • Streamlined Storybook configurations by removing unnecessary argTypes and tags properties across various components, improving clarity and usability.
  • Chores

    • Updated versioning for both @baseapp-frontend/components (0.0.16) and @baseapp-frontend/design-system (0.0.17) packages to reflect recent changes and improvements.
    • Updated the CHANGELOG to document recent enhancements and dependency updates.

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2024

⚠️ No Changeset found

Latest commit: dbe6d80

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

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2024

Walkthrough

The changes in this pull request primarily involve updates to the Storybook configuration across multiple components within the @baseapp-frontend packages. Key modifications include the reordering and addition of story file paths in the Storybook setup, the removal of detailed argument definitions (argTypes) for various components, and the inclusion of a new addon for documentation support. Additionally, the changelog and package version updates reflect these changes, emphasizing a cleanup of Storybook configurations and enhancements in documentation capabilities.

Changes

File Change Summary
packages/components/.storybook/main.ts Updated stories array to prioritize .mdx files and added @storybook/addon-docs.
packages/components/CHANGELOG.md Updated to version 0.0.16, documenting Storybook cleanup and dependency updates.
packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx Added documentation for the ReactionButton component.
packages/components/modules/__shared__/ReactionButton/__storybook__/stories.tsx Removed argTypes and tags properties from meta.
packages/components/modules/__shared__/SocialInput/__storybook__/stories.tsx Removed argTypes and tags properties from meta.
packages/components/modules/__shared__/SocialUpsertActions/__storybook__/stories.tsx Removed tags from meta.
packages/components/modules/__shared__/Timestamp/__storybook__/stories.tsx Removed argTypes and tags from meta.
packages/components/modules/comments/CommentCreate/__storybook__/stories.tsx Removed argTypes from meta.
packages/components/modules/comments/CommentItem/__storybook__/stories.tsx Removed argTypes and tags from meta.
packages/components/modules/comments/CommentUpdate/__storybook__/stories.tsx Removed argTypes and tags from meta.
packages/components/modules/comments/Comments/__storybook__/stories.tsx Removed several properties from argTypes in meta.
packages/components/modules/comments/CommentsList/__storybook__/stories.tsx Removed several properties from argTypes in meta.
packages/components/modules/messages/SendMessage/__storybook__/stories.tsx Removed argTypes and tags from meta.
packages/components/modules/navigations/*/__storybook__/stories.tsx Removed argTypes and tags from multiple navigation components.
packages/components/modules/notifications/*/__storybook__/stories.tsx Removed argTypes and tags from multiple notification components.
packages/components/package.json Updated version to 0.0.16 and added @storybook/addon-docs dependency.
packages/design-system/CHANGELOG.md Updated to version 0.0.17, documenting Storybook cleanup.
packages/design-system/components/*/__storybook__/stories.tsx Removed argTypes and tags from multiple components.
packages/design-system/package.json Updated version to 0.0.17.

Possibly related PRs

  • BA-1584 Add Storybook for Notifications #128: Modifies the Storybook configuration and adds support for .mdx files, while integrating Storybook for notifications components, which includes similar changes to the Storybook setup and documentation enhancements.

Poem

In the land of code, where stories unfold,
A rabbit hops by, with tales to be told.
With .mdx files added, and docs now in sight,
Our Storybook shines, oh what a delight!
So let’s celebrate changes, both big and small,
For in this code garden, we flourish for all! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/components/.storybook/main.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/components/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/components/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)

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 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: 3

🧹 Outside diff range and nitpick comments (4)
packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx (3)

9-10: Consider enhancing the Relay implementation details

While the documentation mentions Relay, it would be helpful to explicitly state the Relay dependencies and requirements for implementing this component.

Consider adding:

 - **Purpose**: The `ReactionButton` component provides an interactive button for users to react to content (e.g., like or dislike) with options to handle success and error responses. The component also displays the current reaction count and supports Relay for efficient data loading.
+- **Dependencies**: This component requires a Relay environment and expects the target prop to be a Relay fragment. The fragment should include fields for reaction counts and user reaction status.

14-15: Consider adding code examples for potential use cases

The potential usage scenarios are good, but providing concrete code examples would make it easier for developers to implement the component in these contexts.

Consider adding example snippets for posts and articles:

 - **Potential Usage**: The `ReactionButton` could also be used for other content types that support reactions, such as posts, images, or articles.
+
+Example for posts:
+```jsx
+<ReactionButton
+  target={post}
+  reactionType="LIKE"
+  handleSuccess={() => refetch()}
+>
+  {({ handleReaction, isLoading, target }) => (
+    <LikeButton
+      onClick={handleReaction}
+      loading={isLoading}
+      count={target.likeCount}
+    />
+  )}
+</ReactionButton>
+```

19-24: Enhance props documentation clarity and completeness

  1. Add a comma after "Typically" for better readability
  2. Consider indicating which props are required vs optional

Apply these improvements:

- **target** (ReactionButton_target$key): The target data for the reaction button. Typically a comment or post, providing data about the current reactions.
+ **target** (ReactionButton_target$key): The target data for the reaction button. Typically, a comment or post, providing data about the current reactions. (Required)
- **reactionType** (string): Specifies the type of reaction, such as "LIKE" or "DISLIKE".
+ **reactionType** (string): Specifies the type of reaction, such as "LIKE" or "DISLIKE". (Required)
- **children** (function): Function to render children components with reaction handlers and data.
+ **children** (function): Function to render children components with reaction handlers and data. (Required)
- **handleError** (function): Callback function to handle errors during the reaction process.
+ **handleError** (function): Callback function to handle errors during the reaction process. (Optional)
- **handleSuccess** (function): Callback function to handle success, executed after a successful reaction.
+ **handleSuccess** (function): Callback function to handle success, executed after a successful reaction. (Optional)
🧰 Tools
🪛 LanguageTool

[typographical] ~19-~19: Consider adding a comma after ‘Typically’ for more clarity.
Context: ...he target data for the reaction button. Typically a comment or post, providing data about...

(RB_LY_COMMA)

packages/design-system/CHANGELOG.md (1)

3-8: Enhance the changelog entry with more detailed documentation.

The current changelog entry could be more descriptive. Consider expanding it to better reflect all the changes mentioned in the PR objectives:

 ## 0.0.17

 ### Patch Changes

-Storybook cleanup
+- Storybook cleanup and improvements:
+  - Removed unnecessary configurations and documentation
+  - Added MDX documentation example
+  - Created Intro Page explaining Storybook's purpose and usage
+  - Refactored component stories with clear descriptions
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 54e140c and 8d16ae5815a53d6f1dc1301472836f38d529638c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (40)
  • packages/components/.storybook/main.ts (2 hunks)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx (1 hunks)
  • packages/components/modules/__shared__/ReactionButton/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/__shared__/SocialInput/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/__shared__/SocialUpsertActions/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/__shared__/Timestamp/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentCreate/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentItem/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentUpdate/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/Comments/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentsList/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/messages/SendMessage/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/Header/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavCentered/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavHorizontal/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavMini/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavVertical/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavigationLayout/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/notifications/NotificationsList/NotificationItem/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/notifications/NotificationsList/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/notifications/NotificationsPopover/__storybook__/stories.tsx (0 hunks)
  • packages/components/package.json (2 hunks)
  • packages/design-system/CHANGELOG.md (1 hunks)
  • packages/design-system/components/Logo/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/Popover/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/Scrollbar/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/avatars/AvatarWithPlaceholder/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/avatars/ClickableAvatar/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/buttons/IconButton/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/dialogs/ConfirmDialog/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/dialogs/Dialog/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/displays/LoadingState/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/drawers/SwipeableDrawer/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/inputs/SocialTextField/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/inputs/TextField/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/inputs/TextareaField/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/typographies/TypographyWithEllipsis/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/package.json (1 hunks)
💤 Files with no reviewable changes (34)
  • packages/components/modules/shared/ReactionButton/storybook/stories.tsx
  • packages/components/modules/shared/SocialInput/storybook/stories.tsx
  • packages/components/modules/shared/SocialUpsertActions/storybook/stories.tsx
  • packages/components/modules/shared/Timestamp/storybook/stories.tsx
  • packages/components/modules/comments/CommentCreate/storybook/stories.tsx
  • packages/components/modules/comments/CommentItem/storybook/stories.tsx
  • packages/components/modules/comments/CommentUpdate/storybook/stories.tsx
  • packages/components/modules/comments/Comments/storybook/stories.tsx
  • packages/components/modules/comments/CommentsList/storybook/stories.tsx
  • packages/components/modules/messages/SendMessage/storybook/stories.tsx
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/storybook/stories.tsx
  • packages/components/modules/navigations/Header/storybook/stories.tsx
  • packages/components/modules/navigations/NavCentered/storybook/stories.tsx
  • packages/components/modules/navigations/NavHorizontal/storybook/stories.tsx
  • packages/components/modules/navigations/NavMini/storybook/stories.tsx
  • packages/components/modules/navigations/NavVertical/storybook/stories.tsx
  • packages/components/modules/navigations/NavigationLayout/storybook/stories.tsx
  • packages/components/modules/notifications/NotificationsList/NotificationItem/storybook/stories.tsx
  • packages/components/modules/notifications/NotificationsList/storybook/stories.tsx
  • packages/components/modules/notifications/NotificationsPopover/storybook/stories.tsx
  • packages/design-system/components/Logo/storybook/stories.tsx
  • packages/design-system/components/Popover/storybook/stories.tsx
  • packages/design-system/components/Scrollbar/storybook/stories.tsx
  • packages/design-system/components/avatars/AvatarWithPlaceholder/storybook/stories.tsx
  • packages/design-system/components/avatars/ClickableAvatar/storybook/stories.tsx
  • packages/design-system/components/buttons/IconButton/storybook/stories.tsx
  • packages/design-system/components/dialogs/ConfirmDialog/storybook/stories.tsx
  • packages/design-system/components/dialogs/Dialog/storybook/stories.tsx
  • packages/design-system/components/displays/LoadingState/storybook/stories.tsx
  • packages/design-system/components/drawers/SwipeableDrawer/storybook/stories.tsx
  • packages/design-system/components/inputs/SocialTextField/storybook/stories.tsx
  • packages/design-system/components/inputs/TextField/storybook/stories.tsx
  • packages/design-system/components/inputs/TextareaField/storybook/stories.tsx
  • packages/design-system/components/typographies/TypographyWithEllipsis/storybook/stories.tsx
✅ Files skipped from review due to trivial changes (2)
  • packages/components/CHANGELOG.md
  • packages/design-system/package.json
🧰 Additional context used
🪛 LanguageTool
packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx

[typographical] ~19-~19: Consider adding a comma after ‘Typically’ for more clarity.
Context: ...he target data for the reaction button. Typically a comment or post, providing data about...

(RB_LY_COMMA)

🔇 Additional comments (3)
packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx (1)

1-3: LGTM! Well-structured Storybook setup

The component documentation is properly organized in the Storybook hierarchy following the established pattern.

packages/components/.storybook/main.ts (1)

29-29: LGTM! Addition of documentation addon.

The addition of @storybook/addon-docs aligns with the PR objectives to enhance documentation capabilities.

Let's verify the addon compatibility with the current Storybook setup:

#!/bin/bash
# Description: Check package.json for Storybook version compatibility
# Expected: Storybook core and addon-docs versions should match

echo "Checking Storybook dependencies versions..."
fd -t f "package.json" . -x jq -r '.dependencies + .devDependencies | with_entries(select(.key | contains("storybook"))) // empty'
packages/components/package.json (1)

4-4: LGTM: Version bump is appropriate

The version increment from 0.0.15 to 0.0.16 aligns with the scope of changes (Storybook documentation improvements).

Comment on lines +32 to +42
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 the example with TypeScript and best practices

The current example could be more comprehensive by including TypeScript types and demonstrating the children render prop pattern.

Consider updating the example:

-```javascript
+```typescript
 import ReactionButton from '../ReactionButton'
+import type { ReactionButton_target$key } from './__generated__/ReactionButton_target.graphql'
+
+interface Props {
+  target: ReactionButton_target$key
+}

-export const DefaultComments = (target) => (
+export const DefaultComments: React.FC<Props> = ({ target }) => (
   <ReactionButton
     target={target}
     reactionType="LIKE"
-    handleError={() => console.log('Error handling reaction')}
-    handleSuccess={() => console.log('Successfully handled reaction')}
+    handleError={(error) => {
+      console.error('Error handling reaction:', error)
+      // Show error toast or handle appropriately
+    }}
+    handleSuccess={() => {
+      console.log('Successfully handled reaction')
+      // Refetch data or update UI
+    }}
+  >
+    {({ handleReaction, isLoading, target }) => (
+      <button
+        onClick={handleReaction}
+        disabled={isLoading}
+      >
+        {isLoading ? 'Loading...' : `Like (${target.likeCount})`}
+      </button>
+    )}
   />
 )

Comment on lines +15 to +17
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

No MDX files found in specified directories.

Please ensure that MDX files exist in the following paths:

  • packages/components/modules/**/__storybook__
  • packages/design-system/components/**/__storybook__
🔗 Analysis chain

LGTM! Proper organization of story paths.

The story paths are well-organized with documentation files (.mdx) preceding the story files, which follows best practices for Storybook configuration.

Let's verify the existence of MDX files in the specified paths:


Shell script corrected to verify MDX file existence:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of MDX files in the specified paths
# Expected: Should find at least one MDX file in each directory

echo "Checking for MDX files in modules directory..."
fd -e mdx . "packages/components/modules/**/__storybook__"

echo "Checking for MDX files in design-system directory..."
fd -e mdx . "packages/design-system/components/**/__storybook__"

Length of output: 1803


Script:

#!/bin/bash
# Description: Verify the existence of MDX files in the specified paths
# Expected: Should find at least one MDX file in each directory

echo "Checking for MDX files in modules directory..."
fd -e mdx "packages/components/modules/**/__storybook__"

echo "Checking for MDX files in design-system directory..."
fd -e mdx "packages/design-system/components/**/__storybook__"

Length of output: 341

Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Storybook Addon Docs Configuration Missing

The @storybook/addon-docs is present in package.json and MDX documentation files are found, but it is not configured in .storybook/main.ts. Please add @storybook/addon-docs to the addons array in main.ts.

🔗 Analysis chain

Verify Storybook configuration for the new addon

The addition of @storybook/addon-docs is appropriate for MDX documentation support. Let's verify the corresponding Storybook configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Storybook configuration for the new addon

# Check if the addon is properly configured in .storybook/main.ts
echo "Checking Storybook configuration..."
rg -A 10 "addons.*=" "packages/components/.storybook/main.ts"

# Check for MDX documentation files
echo "Checking for MDX documentation files..."
fd -e mdx . packages/components/

Length of output: 353

@deboracosilveira deboracosilveira force-pushed the BA-1794-storybook-clean-up branch from 8d16ae5 to dbe6d80 Compare November 13, 2024 13:43
@sonarqubecloud
Copy link

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: 0

🧹 Outside diff range and nitpick comments (10)
packages/design-system/.storybook/preview.ts (1)

Line range hint 20-57: Consider improving the story order maintainability.

The story order array could benefit from better organization and documentation:

  1. Consider grouping stories into a separate constant object by category
  2. Add missing section comments for consistency
  3. Consider addressing the TypeScript ignore comment with proper typing

Here's a suggested refactor:

+ const STORY_ORDER = {
+   documentation: ['Introduction'],
+   avatars: ['AvatarWithPlaceholder', 'ClickableAvatar'],
+   buttons: ['IconButton'],
+   dialogs: ['BaseDialog', 'ConfirmDialog'],
+   displays: ['LoadingState'],
+   drawers: ['SwipeableDrawer'],
+   form: ['TextField', 'TextareaField', 'CommentTextField'],
+   iconography: ['Iconography'],
+   popover: ['Popover'],
+   typography: ['TypographyWithEllipsis'],
+   general: ['Logo', 'Scrollbar']
+ } as const;
+
+ // Flatten the groups into a single array
+ const order = Object.values(STORY_ORDER).flat();
-const order = [
-  'Introduction',
-  'Iconography',
-  // Avatars
-  'AvatarWithPlaceholder',
-  'ClickableAvatar',
-  // ... rest of the array
-]
packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx (2)

5-29: Documentation structure is comprehensive and well-organized.

Consider adding a comma after "Typically" in line 19 for better readability:

-Typically a comment or post, providing data about the current reactions.
+Typically, a comment or post, providing data about the current reactions.
🧰 Tools
🪛 LanguageTool

[typographical] ~19-~19: Consider adding a comma after ‘Typically’ for more clarity.
Context: ...he target data for the reaction button. Typically a comment or post, providing data about...

(RB_LY_COMMA)


23-24: Consider enhancing error handling documentation.

The error handling section could benefit from more specific examples of common error scenarios and recommended handling patterns.

Consider adding:

### Error Handling Examples

Common error scenarios:
- Network failures
- Permission issues
- Rate limiting

Example implementation:
```typescript
handleError: (error: Error) => {
  if (error.name === 'NetworkError') {
    showToast('Connection lost. Please try again.');
  } else if (error.message.includes('permission')) {
    showToast('You do not have permission to perform this action.');
  }
  // Log error for monitoring
  logError(error);
}
packages/components/.storybook/preview.ts (2)

38-38: Consider consolidating duplicate story orders

While adding 'Introduction' as the first entry in both arrays is good for documentation, there's significant duplication between designSystemStoriesOrder and componentsStoriesOrder. This could lead to maintenance challenges.

Consider extracting the common entries into a shared array:

const commonStoriesOrder = [
  'Introduction',
  'Iconography',
  // Avatars
  'AvatarWithPlaceholder',
  'ClickableAvatar',
  // ... other common entries
]

const designSystemStoriesOrder = [...commonStoriesOrder]
const componentsStoriesOrder = [
  ...commonStoriesOrder,
  // Navigation
  'NavigationLayout',
  // ... other component-specific entries
]

Also applies to: 66-66


Line range hint 31-124: Improve type safety and sorting logic

The current implementation has a few areas that could be enhanced:

  1. The @ts-ignore comment suggests underlying type issues with the storySort function
  2. The sorting logic could be more maintainable using a Map for O(1) lookups instead of indexOf

Consider refactoring the sort function to improve type safety and performance:

const storySort = (a: { title?: string }, b: { title?: string }) => {
  const storiesOrderMap = new Map(
    [...designSystemStoriesOrder, ...componentsStoriesOrder]
      .map((title, index) => [title, index])
  );

  const titleA = (a.title || '').split('/').pop() || '';
  const titleB = (b.title || '').split('/').pop() || '';

  const indexA = storiesOrderMap.get(titleA) ?? -1;
  const indexB = storiesOrderMap.get(titleB) ?? -1;

  if (indexA === -1 || indexB === -1) {
    return titleA.localeCompare(titleB, undefined, { numeric: true });
  }

  return indexA - indexB;
};
README.md (5)

174-176: Consider enhancing the introduction with expected outcomes.

The introduction clearly states the purpose but could be more impactful by mentioning the benefits of following these guidelines, such as improved maintainability and team collaboration.

 ## Documentation Guide
 
-To ensure that all pages, components, and utilities are thoroughly documented in Storybook, please follow these steps.
+To ensure that all pages, components, and utilities are thoroughly documented in Storybook, please follow these steps. Following these guidelines helps maintain consistent documentation across the project, improves component discoverability, and facilitates easier onboarding for new team members.

183-184: Add an example for MSW mock usage.

Consider adding a code example to demonstrate how to properly implement MSW mocks in stories.

 - **Use Mocks for Data**: Use MSW (Mock Service Worker) to mock any necessary API requests, ensuring stories are self-contained and reproducible.
+- **Use Mocks for Data**: Use MSW (Mock Service Worker) to mock any necessary API requests, ensuring stories are self-contained and reproducible. For example:
+  ```tsx
+  export const Default = {
+    parameters: {
+      msw: {
+        handlers: [
+          rest.get('/api/data', (req, res, ctx) => {
+            return res(ctx.json({ data: 'mocked response' }))
+          }),
+        ],
+      },
+    },
+  }
+  ```

188-189: Enhance the storySort instruction with an example.

The instruction about adding to storySort could be more helpful with a concrete example.

 **After creating the story**:
-Add the story name to `storySort` in the `preview.ts` file to ensure it appears in the correct order. If you're unsure where to add this, please ask a COP member for assistance.
+Add the story name to `storySort` in the `preview.ts` file to ensure it appears in the correct order. For example:
+```ts
+export const parameters = {
+  options: {
+    storySort: {
+      order: ['Introduction', 'Components', ['Buttons', 'Forms', 'Layout'], 'Pages'],
+    },
+  },
+}
+```
+If you're unsure where to add this, please ask a COP member for assistance.

195-199: Add an example MDX structure.

Consider adding a basic MDX file structure to help developers get started quickly.

 - **Create an MDX File**: Place the `.mdx` file in the corresponding `__storybook__` folder. The file name should match the component or page name (e.g., `Button.mdx` for the `Button` component).
+- **Create an MDX File**: Place the `.mdx` file in the corresponding `__storybook__` folder. The file name should match the component or page name (e.g., `Button.mdx` for the `Button` component). Example structure:
+  ```mdx
+  import { Meta } from '@storybook/blocks';
+  
+  <Meta title="@baseapp-frontend-template / Components/Buttons/Button" />
+  
+  # Button Component
+  
+  ## Overview
+  Description of the button component and its purpose.
+  
+  ## Props
+  | Prop | Type | Description |
+  |------|------|-------------|
+  | variant | 'primary' \| 'secondary' | The button's visual style |
+  
+  ## Usage Guidelines
+  Best practices and examples of when to use this component.
+  ```

200-200: Consider maintaining documentation links in a central location.

External documentation links like Tettra could break or change over time. Consider maintaining such links in a central configuration file.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8d16ae5815a53d6f1dc1301472836f38d529638c and dbe6d80.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (45)
  • README.md (1 hunks)
  • packages/components/.storybook/Introduction.mdx (1 hunks)
  • packages/components/.storybook/main.ts (2 hunks)
  • packages/components/.storybook/preview.ts (2 hunks)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx (1 hunks)
  • packages/components/modules/__shared__/ReactionButton/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/__shared__/SocialInput/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/__shared__/SocialUpsertActions/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/__shared__/Timestamp/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentCreate/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentItem/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentUpdate/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/Comments/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/comments/CommentsList/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/messages/SendMessage/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/Header/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavCentered/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavHorizontal/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavMini/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavVertical/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/navigations/NavigationLayout/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/notifications/NotificationsList/NotificationItem/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/notifications/NotificationsList/__storybook__/stories.tsx (0 hunks)
  • packages/components/modules/notifications/NotificationsPopover/__storybook__/stories.tsx (0 hunks)
  • packages/components/package.json (2 hunks)
  • packages/design-system/.storybook/Introduction.mdx (1 hunks)
  • packages/design-system/.storybook/preview.ts (1 hunks)
  • packages/design-system/CHANGELOG.md (1 hunks)
  • packages/design-system/components/Logo/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/Popover/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/Scrollbar/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/avatars/AvatarWithPlaceholder/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/avatars/ClickableAvatar/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/buttons/IconButton/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/dialogs/ConfirmDialog/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/dialogs/Dialog/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/displays/LoadingState/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/drawers/SwipeableDrawer/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/inputs/SocialTextField/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/inputs/TextField/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/inputs/TextareaField/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/components/typographies/TypographyWithEllipsis/__storybook__/stories.tsx (0 hunks)
  • packages/design-system/package.json (1 hunks)
💤 Files with no reviewable changes (34)
  • packages/components/modules/shared/ReactionButton/storybook/stories.tsx
  • packages/components/modules/shared/SocialInput/storybook/stories.tsx
  • packages/components/modules/shared/SocialUpsertActions/storybook/stories.tsx
  • packages/components/modules/shared/Timestamp/storybook/stories.tsx
  • packages/components/modules/comments/CommentCreate/storybook/stories.tsx
  • packages/components/modules/comments/CommentItem/storybook/stories.tsx
  • packages/components/modules/comments/CommentUpdate/storybook/stories.tsx
  • packages/components/modules/comments/Comments/storybook/stories.tsx
  • packages/components/modules/comments/CommentsList/storybook/stories.tsx
  • packages/components/modules/messages/SendMessage/storybook/stories.tsx
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/storybook/stories.tsx
  • packages/components/modules/navigations/Header/storybook/stories.tsx
  • packages/components/modules/navigations/NavCentered/storybook/stories.tsx
  • packages/components/modules/navigations/NavHorizontal/storybook/stories.tsx
  • packages/components/modules/navigations/NavMini/storybook/stories.tsx
  • packages/components/modules/navigations/NavVertical/storybook/stories.tsx
  • packages/components/modules/navigations/NavigationLayout/storybook/stories.tsx
  • packages/components/modules/notifications/NotificationsList/NotificationItem/storybook/stories.tsx
  • packages/components/modules/notifications/NotificationsList/storybook/stories.tsx
  • packages/components/modules/notifications/NotificationsPopover/storybook/stories.tsx
  • packages/design-system/components/Logo/storybook/stories.tsx
  • packages/design-system/components/Popover/storybook/stories.tsx
  • packages/design-system/components/Scrollbar/storybook/stories.tsx
  • packages/design-system/components/avatars/AvatarWithPlaceholder/storybook/stories.tsx
  • packages/design-system/components/avatars/ClickableAvatar/storybook/stories.tsx
  • packages/design-system/components/buttons/IconButton/storybook/stories.tsx
  • packages/design-system/components/dialogs/ConfirmDialog/storybook/stories.tsx
  • packages/design-system/components/dialogs/Dialog/storybook/stories.tsx
  • packages/design-system/components/displays/LoadingState/storybook/stories.tsx
  • packages/design-system/components/drawers/SwipeableDrawer/storybook/stories.tsx
  • packages/design-system/components/inputs/SocialTextField/storybook/stories.tsx
  • packages/design-system/components/inputs/TextField/storybook/stories.tsx
  • packages/design-system/components/inputs/TextareaField/storybook/stories.tsx
  • packages/design-system/components/typographies/TypographyWithEllipsis/storybook/stories.tsx
✅ Files skipped from review due to trivial changes (2)
  • packages/components/.storybook/Introduction.mdx
  • packages/design-system/.storybook/Introduction.mdx
🚧 Files skipped from review as they are similar to previous changes (5)
  • packages/components/.storybook/main.ts
  • packages/components/CHANGELOG.md
  • packages/components/package.json
  • packages/design-system/CHANGELOG.md
  • packages/design-system/package.json
🧰 Additional context used
🪛 LanguageTool
packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx

[typographical] ~19-~19: Consider adding a comma after ‘Typically’ for more clarity.
Context: ...he target data for the reaction button. Typically a comment or post, providing data about...

(RB_LY_COMMA)

🔇 Additional comments (4)
packages/design-system/.storybook/preview.ts (1)

20-20: LGTM: Introduction story placement is correct.

The addition of 'Introduction' at the start of the order array aligns with the PR objectives and ensures the intro documentation appears first in the Storybook navigation.

packages/components/modules/__shared__/ReactionButton/__storybook__/ReactionButton.mdx (2)

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

The title hierarchy follows Storybook's best practices for organization.


32-42: 🛠️ Refactor suggestion

Add accessibility attributes to the example.

While the TypeScript improvements suggested in the previous review are valuable (), the example should also demonstrate proper accessibility attributes.

Consider enhancing the example with ARIA attributes:

export const DefaultComments: React.FC<Props> = ({ target }) => (
  <ReactionButton
    target={target}
    reactionType="LIKE"
    handleError={(error) => console.error('Error handling reaction:', error)}
    handleSuccess={() => console.log('Successfully handled reaction')}
  >
    {({ handleReaction, isLoading, target }) => (
      <button
        onClick={handleReaction}
        disabled={isLoading}
        aria-pressed={target.hasReacted}
        aria-label={`Like this content. Current likes: ${target.likeCount}`}
      >
        {isLoading ? 'Loading...' : `Like (${target.likeCount})`}
      </button>
    )}
  />
)
packages/components/.storybook/preview.ts (1)

Line range hint 1-124: LGTM! Changes align well with Storybook cleanup objectives

The modifications effectively support the PR's goals by:

  1. Prioritizing Introduction pages in the story order
  2. Maintaining a clear structure for component documentation
  3. Supporting MDX documentation through the existing configuration

@deboracosilveira deboracosilveira merged commit 08bfce4 into master Nov 13, 2024
8 checks passed
@deboracosilveira deboracosilveira deleted the BA-1794-storybook-clean-up branch November 13, 2024 15:01
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