Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BA-1851: Add Missing MDX Doc Files for BaseApp Frontend Packages - Group 2 #168

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

joaosoutto
Copy link
Contributor

@joaosoutto joaosoutto commented Dec 27, 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:

BaseDialog

Scrollbar

LoadingState

Header

AccountPopover

NavMini

NavigationLayout

NavCentered

NavVertical

NavHorizontal

Current behavior

Expected behavior

Code Snippet

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

Summary by CodeRabbit

  • Documentation

    • Added comprehensive Storybook documentation for multiple navigation and UI components, including:
      • Scrollbar
      • AccountPopover
      • Header
      • NavCentered
      • NavHorizontal
      • NavMini
      • NavVertical
      • NavigationLayout
      • BaseDialog
      • LoadingState
  • New Features

    • Introduced detailed component documentation with use cases, props, and example implementations.

Copy link

changeset-bot bot commented Dec 27, 2024

⚠️ No Changeset found

Latest commit: f754a0b

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

coderabbitai bot commented Dec 27, 2024

Walkthrough

This pull request introduces comprehensive Storybook documentation for multiple components across the design system and navigation modules. The documentation provides detailed insights into the purpose, behavior, props, and usage of components such as Scrollbar, AccountPopover, Header, NavCentered, NavHorizontal, NavMini, NavVertical, NavigationLayout, BaseDialog, and LoadingState. Each documentation file follows a consistent structure, including meta information, component description, use cases, prop details, and example implementations.

Changes

File Path Change Summary
packages/design-system/components/Scrollbar/__storybook__/Scrollbar.mdx Added comprehensive Storybook documentation for Scrollbar component
packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/AccountPopover.mdx New Storybook documentation for AccountPopover component
packages/components/modules/navigations/Header/__storybook__/Header.mdx New Storybook documentation for Header component
packages/components/modules/navigations/NavCentered/__storybook__/NavCentered.mdx Added Storybook documentation for NavCentered component
packages/components/modules/navigations/NavHorizontal/__storybook__/NavHorizontal.mdx New Storybook documentation for NavHorizontal component
packages/components/modules/navigations/NavMini/__storybook__/NavMini.mdx Added Storybook documentation for NavMini component
packages/components/modules/navigations/NavVertical/__storybook__/NavVertical.mdx New Storybook documentation for NavVertical component
packages/components/modules/navigations/NavigationLayout/__storybook__/NavigationLayout.mdx Added Storybook documentation for NavigationLayout component
packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx New Storybook documentation for BaseDialog component
packages/design-system/components/displays/LoadingState/__storybook__/LoadingState.mdx Added Storybook documentation for LoadingState component

Possibly Related PRs

Suggested Reviewers

  • deboracosilveira
  • anicioalexandre
  • priscilladeroode

Poem

🐰 Hop, hop, documentation's here!
Storybook pages, crystal clear
Components dancing, props in sight
Navigation flows, oh so bright
Code's now readable, rabbit's delight! 📘✨


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

🧹 Nitpick comments (17)
packages/design-system/components/displays/LoadingState/__storybook__/LoadingState.mdx (2)

24-24: Enhance props documentation with specific CircularProgressProps details

The props section could be more helpful by detailing the commonly used CircularProgressProps options such as size, color, and thickness. This would save developers from having to look up the MUI documentation.

Add details like:

- **CircularProgressProps** (MUI CircularProgress Props): Optional props passed directly to the underlying MUI CircularProgress component.
+ **CircularProgressProps** (MUI CircularProgress Props): Optional props passed directly to the underlying MUI CircularProgress component.
+   - size (number): The size of the circle (default: 40)
+   - color ('primary' | 'secondary' | string): The color of the component
+   - thickness (number): The thickness of the circle (default: 3.6)
+   - variant ('determinate' | 'indeterminate'): The variant to use (default: 'indeterminate')

35-43: Expand example usage with common scenarios

While the current example is good, it would be helpful to show more real-world usage scenarios.

Add examples like:

 ```javascript
 import { LoadingState } from '@baseapp-frontend/design-system'
 
 const MyComponent = () => {
-  return <LoadingState CircularProgressProps={{ size: 40 }} />
+  // Example 1: Basic usage
+  return <LoadingState />
+
+  // Example 2: Custom size and color
+  return <LoadingState CircularProgressProps={{ 
+    size: 60,
+    color: 'secondary',
+    thickness: 4
+  }} />
+
+  // Example 3: Usage within a container
+  return (
+    <div style={{ height: '100vh', display: 'flex' }}>
+      <LoadingState CircularProgressProps={{ size: 40 }} />
+    </div>
+  )
 }
 
 export default MyComponent

</blockquote></details>
<details>
<summary>packages/design-system/components/dialogs/Dialog/__storybook__/Dialog.mdx (3)</summary><blockquote>

`10-10`: **Improve sentence structure in expected behavior**

The sentence structure could be improved for clarity.

```diff
- **Expected Behavior**: Opens as a modal overlay centered on the screen. Can be closed via a close button, clicking outside (if enabled), or pressing ESC key (if enabled). Should trap focus within the dialog when open for accessibility.
+ **Expected Behavior**: The dialog opens as a modal overlay centered on the screen. It can be closed via a close button, clicking outside (if enabled), or pressing the ESC key (if enabled). Focus is trapped within the dialog when open for accessibility.
🧰 Tools
🪛 LanguageTool

[style] ~10-~10: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)


[uncategorized] ~10-~10: You might be missing the article “the” here.
Context: ...cking outside (if enabled), or pressing ESC key (if enabled). Should trap focus wit...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


23-25: Expand props documentation with common Dialog props

The props section should include more commonly used MUI Dialog props to provide a complete reference.

 - **children** (ReactNode): The content to be displayed inside the dialog.
 - **open** (boolean): Controls whether the dialog is visible.
 - **onClose** ((event: {}, reason: "backdropClick" | "escapeKeyDown") => void): Callback fired when the dialog requests to be closed.
+ - **maxWidth** ('xs' | 'sm' | 'md' | 'lg' | 'xl' | false): Determine the max-width of the dialog. The dialog width grows with the size of the screen.
+ - **fullWidth** (boolean): If true, the dialog stretches to maxWidth.
+ - **disableEscapeKeyDown** (boolean): If true, hitting escape will not fire the onClose callback.
+ - **disableBackdropClick** (boolean): If true, clicking the backdrop will not fire the onClose callback.

36-49: Enhance example with common Dialog patterns

The example could demonstrate more common Dialog usage patterns.

 ```javascript
 import { Dialog } from '@baseapp-frontend/design-system'
 
 const MyComponent = () => {
   const [open, setOpen] = useState(false)
 
+  const handleClose = (event, reason) => {
+    if (reason !== 'backdropClick') {
+      setOpen(false)
+    }
+  }
+
   return (
-    <Dialog open={open} onClose={() => setOpen(false)}>
-      <div>Dialog content</div>
-    </Dialog>
+    <>
+      <button onClick={() => setOpen(true)}>Open Dialog</button>
+      
+      <Dialog 
+        open={open} 
+        onClose={handleClose}
+        maxWidth="sm"
+        fullWidth
+        disableBackdropClick
+      >
+        <DialogTitle>Dialog Title</DialogTitle>
+        <DialogContent>
+          <DialogContentText>
+            Dialog content with text and other components.
+          </DialogContentText>
+        </DialogContent>
+        <DialogActions>
+          <Button onClick={() => setOpen(false)}>Cancel</Button>
+          <Button onClick={() => setOpen(false)} color="primary">
+            Confirm
+          </Button>
+        </DialogActions>
+      </Dialog>
+    </>
   )
 }
 export default MyComponent

</blockquote></details>
<details>
<summary>packages/components/modules/navigations/NavCentered/__storybook__/NavCentered.mdx (3)</summary><blockquote>

`20-20`: **Fix grammar in use cases section**

Add the missing article "a" for better readability.

```diff
- Content-focused websites where navigation clarity is priority
+ Content-focused websites where navigation clarity is a priority
🧰 Tools
🪛 LanguageTool

[uncategorized] ~20-~20: You might be missing the article “a” here.
Context: ...ed websites where navigation clarity is priority ## Props - navData (array): Navig...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


24-26: Enhance props documentation with detailed type information

The props section should provide more detailed type information and include additional customization props.

- **navData** (array): Navigation items data containing routes, icons, and labels
+ **navData** (Array<{
+   title: string,
+   path?: string,
+   icon?: ReactNode,
+   info?: ReactNode,
+   children?: Array<{
+     title: string,
+     path: string
+   }>
+ }>): Navigation items data containing routes, icons, and labels
 - **openNav** (boolean): Whether the navigation is open or closed
 - **onCloseNav** (function): Callback function to close the navigation
+ - **logo** (ReactNode): Custom logo component to display
+ - **actions** (ReactNode): Additional actions to display in the navigation bar
+ - **disableAccount** (boolean): Whether to hide the account menu

38-57: Improve example with proper imports and realistic configuration

The example should include proper imports and show a more realistic navigation configuration.

 ```javascript
-import { NavCentered } from '@baseapp-frontend/design-system'
+import { NavCentered } from '@baseapp-frontend/design-system'
+import HomeIcon from '@mui/icons-material/Home'
+import InfoIcon from '@mui/icons-material/Info'
+import ContactIcon from '@mui/icons-material/ContactMail'
+import { Logo } from '../components/Logo'
 
 const MyComponent = () => {
   const [openNav, setOpenNav] = useState(false)
+
+  const navConfig = [
+    { 
+      title: 'Home',
+      path: '/',
+      icon: <HomeIcon />,
+    },
+    {
+      title: 'About',
+      path: '/about',
+      icon: <InfoIcon />,
+      children: [
+        { title: 'Team', path: '/about/team' },
+        { title: 'Career', path: '/about/career' },
+      ]
+    },
+    {
+      title: 'Contact',
+      path: '/contact',
+      icon: <ContactIcon />
+    }
+  ]
+
   return (
     <NavCentered
-      navData={[
-        { title: 'Home', icon: <MenuIcon /> },
-        { title: 'About', icon: <InfoIcon /> },
-        { title: 'Contact', icon: <ContactIcon /> },
-      ]}
+      logo={<Logo />}
+      navData={navConfig}
       openNav={openNav}
       onCloseNav={() => setOpenNav(false)}
+      disableAccount={false}
     />
   )
 }
packages/components/modules/navigations/Header/__storybook__/Header.mdx (1)

42-56: Improve example code completeness and imports

The example code could be enhanced in several ways:

  1. Use more specific imports instead of importing everything from design-system
  2. Include essential props mentioned in the props section
  3. Add comments explaining the purpose of each prop
-import { Header } from '@baseapp-frontend/design-system'
-import { LogoIcon } from '@baseapp-frontend/design-system'
-import { AccountMenu } from '@baseapp-frontend/design-system'
+import { Header } from '@baseapp-frontend/design-system/components/Header'
+import { LogoIcon } from '@baseapp-frontend/design-system/components/Logo'
+import { AccountMenu } from '@baseapp-frontend/design-system/components/AccountMenu'

 const MyComponent = () => {
+  // Handle navigation menu toggle
+  const handleOpenNav = () => {
+    // Implementation
+  }
+
   return (
     <Header 
       settings={{ themeLayout: 'horizontal' }}
+      onOpenNav={handleOpenNav}
+      ToolbarProps={{
+        sx: { height: 64 }
+      }}
     >
       <LogoIcon />
       <AccountMenu />
     </Header>
   )
 }
packages/components/modules/navigations/NavVertical/__storybook__/NavVertical.mdx (1)

41-62: Enhance example code with proper imports and state management

The example code needs improvements:

  1. Missing imports for icons
  2. State management could follow better practices
  3. Lacks error handling
+import { HomeIcon, InfoIcon, ContactIcon } from '@baseapp-frontend/design-system/icons'
 import { NavVertical } from '@baseapp-frontend/design-system'
-import { BaseAppLogoCondensed } from '@baseapp-frontend/design-system'

 const MyComponent = () => {
-  const [openNav, setOpenNav] = useState(false)
+  // Use callback to prevent unnecessary re-renders
+  const [openNav, setOpenNav] = useState(false)
+  const handleCloseNav = useCallback(() => {
+    setOpenNav(false)
+  }, [])

   return (
     <NavVertical
       navData={[
-        { title: 'Home', icon: <MenuIcon /> },
-        { title: 'About', icon: <InfoIcon /> },
-        { title: 'Contact', icon: <ContactIcon /> },
+        { title: 'Home', path: '/', icon: <HomeIcon /> },
+        { title: 'About', path: '/about', icon: <InfoIcon /> },
+        { title: 'Contact', path: '/contact', icon: <ContactIcon /> }
       ]}
       openNav={openNav}
-      onCloseNav={() => setOpenNav(false)}
+      onCloseNav={handleCloseNav}
       hideToggleButton={true}
     />
   )
 }
packages/components/modules/navigations/NavigationLayout/__storybook__/NavigationLayout.mdx (2)

42-71: Improve example code with proper theme handling and settings management

The example needs several improvements:

  1. Proper theme import and usage
  2. Meaningful settings management
  3. Better type safety
 import { NavigationLayout } from '@baseapp-frontend/design-system'
 import { BaseAppLogoCondensed } from '@baseapp-frontend/design-system'
+import { defaultTheme } from '@baseapp-frontend/design-system/theme'
+import { useState } from 'react'

 const MyComponent = () => {
+  const [settings, setSettings] = useState(defaultTheme.settings)
+
+  const handleSettingsChange = useCallback((newSettings) => {
+    setSettings(prev => ({
+      ...prev,
+      ...newSettings
+    }))
+  }, [])

   return (
     <NavigationLayout
       navData={[
         {
           subheader: 'BASEAPP',
           items: [{ title: 'Home', path: '/', icon: <HomeIcon /> }],
         },
         // ... other items
       ]}
-      settings={defaultTheme.settings}
-      setSettings={() => {}}
+      settings={settings}
+      setSettings={handleSettingsChange}
       LogoIcon={BaseAppLogoCondensed}
     />
   )
 }

1-1: Maintain consistency across documentation files

While the documentation provides good coverage, consider maintaining consistency across all MDX files by:

  1. Using the same format for type definitions
  2. Following the same pattern for examples (imports, state management, etc.)
  3. Providing similar levels of detail for common props (e.g., settings, LogoIcon)
packages/components/modules/navigations/NavMini/__storybook__/NavMini.mdx (3)

9-10: Consider adding responsive breakpoint details.

The documentation would be more helpful if it specified the breakpoints at which the component switches between desktop and mobile views.


24-29: Enhance props documentation with types and required status.

Consider enhancing the props documentation by:

  • Adding TypeScript types for each prop
  • Indicating which props are required vs optional
  • Including default values where applicable

Example format:

- **navData** (array, required): Navigation items data containing routes, icons, and labels
  - Type: `Array<{ subheader: string, items: Array<{ title: string, icon: ReactNode }> }>`

41-73: Consider adding TypeScript example.

The example is comprehensive but could be more helpful with TypeScript types. Consider adding a TypeScript version of the example to demonstrate proper typing.

packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/AccountPopover.mdx (2)

9-10: Add accessibility considerations.

Consider documenting accessibility features such as:

  • Keyboard navigation support
  • ARIA attributes
  • Screen reader behavior

45-77: Enhance example with realistic scenarios.

Consider improving the example by:

  1. Adding a more realistic user profile object
  2. Demonstrating error handling
  3. Showing integration with authentication
  4. Including examples of custom styling
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed2bb1 and ceca0b2.

📒 Files selected for processing (10)
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/AccountPopover.mdx (1 hunks)
  • packages/components/modules/navigations/Header/__storybook__/Header.mdx (1 hunks)
  • packages/components/modules/navigations/NavCentered/__storybook__/NavCentered.mdx (1 hunks)
  • packages/components/modules/navigations/NavHorizontal/__storybook__/NavHorizontal.mdx (1 hunks)
  • packages/components/modules/navigations/NavMini/__storybook__/NavMini.mdx (1 hunks)
  • packages/components/modules/navigations/NavVertical/__storybook__/NavVertical.mdx (1 hunks)
  • packages/components/modules/navigations/NavigationLayout/__storybook__/NavigationLayout.mdx (1 hunks)
  • packages/design-system/components/Scrollbar/__storybook__/Scrollbar.mdx (1 hunks)
  • packages/design-system/components/dialogs/Dialog/__storybook__/Dialog.mdx (1 hunks)
  • packages/design-system/components/displays/LoadingState/__storybook__/LoadingState.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/design-system/components/Scrollbar/storybook/Scrollbar.mdx
  • packages/components/modules/navigations/NavHorizontal/storybook/NavHorizontal.mdx
🧰 Additional context used
🪛 LanguageTool
packages/design-system/components/dialogs/Dialog/__storybook__/Dialog.mdx

[style] ~10-~10: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)


[uncategorized] ~10-~10: You might be missing the article “the” here.
Context: ...cking outside (if enabled), or pressing ESC key (if enabled). Should trap focus wit...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

packages/components/modules/navigations/NavCentered/__storybook__/NavCentered.mdx

[uncategorized] ~20-~20: You might be missing the article “a” here.
Context: ...ed websites where navigation clarity is priority ## Props - navData (array): Navig...

(AI_EN_LECTOR_MISSING_DETERMINER_A)

🔇 Additional comments (1)
packages/components/modules/navigations/NavMini/__storybook__/NavMini.mdx (1)

1-3: LGTM! Title follows Storybook naming conventions.

Comment on lines +23 to +30
- **settings** (object): Configuration object for theme and layout settings
- **themeLayout**: Determines the header layout ('horizontal' | 'centered' | 'vertical')
- **children** (ReactNode): Optional content to render within the header
- **onOpenNav** (function): Callback function for handling navigation menu toggle
- **LogoIcon** (component): Custom logo component to display in the header
- **AccountMenu** (component): Custom account menu component, defaults to DefaultAccountMenu
- **AccountMenuProps** (object): Props passed to the AccountMenu component
- **ToolbarProps** (object): Props passed to the underlying MUI Toolbar 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 type information and required/optional status

The props section should clearly indicate:

  • Type information for each prop (e.g., themeLayout is shown but others aren't)
  • Which props are required vs optional
  • Default values where applicable

Example format:

- **settings** (object, required): Configuration object for theme and layout settings
  - **themeLayout** ('horizontal' | 'centered' | 'vertical'): Determines the header layout
  - Default: { themeLayout: 'horizontal' }

Comment on lines 24 to 29
- **navData** (NavigationData): Navigation configuration data containing routes, icons, and menu structure
- **settings** (UISettings): UI configuration settings for the navigation component
- **LogoIcon** (React.FC): Optional custom logo component to display at the top
- **openNav** (boolean): Controls the open/closed state of the navigation drawer
- **onCloseNav** (function): Callback function when navigation drawer is closed
- **hideToggleButton** (boolean): Whether to hide the toggle button for the navigation drawer
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Document complex type definitions

The props section references complex types (NavigationData, UISettings) without explaining their structure. Consider adding:

  1. Type definitions with examples
  2. Links to relevant type documentation

Example addition:

- **navData** (NavigationData): Navigation configuration data containing routes, icons, and menu structure
  ```typescript
  type NavigationData = {
    title: string;
    path?: string;
    icon?: React.ReactNode;
    info?: React.ReactNode;
    children?: NavigationData[];
    // ... other properties
  }

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines +24 to +31
- **navData** (NavigationData): Navigation configuration data containing routes, icons, and menu structure
- **settings** (UISettings): UI configuration settings for the navigation components
- **setSettings** (function): Callback to update UI settings
- **LogoIcon** (React.FC): Optional custom logo component
- **AccountMenu** (React.FC): Optional custom account menu component
- **AccountMenuProps** (object): Optional props for the account menu component
- **ToolbarProps** (MuiToolbarProps): Optional props for the Material-UI Toolbar 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

Document settings structure and callback usage

The props documentation needs enhancement:

  1. Add structure of UISettings type
  2. Explain proper usage of setSettings callback
  3. Document ToolbarProps interface

Example addition:

- **settings** (UISettings): UI configuration settings
  ```typescript
  interface UISettings {
    themeMode: 'light' | 'dark';
    themeLayout: 'vertical' | 'horizontal' | 'mini';
    // ... other properties
  }
  • setSettings (function): Callback to update UI settings
    (settings: Partial<UISettings>) => void

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines +24 to +34
- **MenuItems** (MenuItem[]): Array of menu items containing label and onClick handlers for each action
- **PopoverStyles** (object): Styles for the popover component
- **CurrentUser** (object): The current user object containing profile information
- **SwitchProfileMenu** (object): The switch profile menu object containing label and onClick handlers for each action
- **SwitchProfileMenuProps** (object): The switch profile menu props object containing label and onClick handlers for each action
- **ProfilesList** (object): The profiles list object containing label and onClick handlers for each action
- **ProfilesListProps** (object): The profiles list props object containing label and onClick handlers for each action
- **AddProfileMenuItem** (object): The add profile menu item object containing label and onClick handlers for each action
- **AddProfileMenuItemProps** (object): The add profile menu item props object containing label and onClick handlers for each action
- **LogoutItemProps** (object): The logout menu item props object containing label and onClick handlers for each action

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify props structure to reduce duplication.

The current props structure has several overlapping props with similar purposes (e.g., SwitchProfileMenu/SwitchProfileMenuProps, ProfilesList/ProfilesListProps). Consider simplifying by:

  1. Consolidating duplicate props
  2. Using consistent naming (remove redundant "Props" suffix)
  3. Organizing related props into logical groups

Example structure:

interface AccountPopoverProps {
  menuItems: MenuItem[];
  switchProfile: {
    label: string;
    onClick: () => void;
  };
  profiles: {
    list: Profile[];
    onAdd: () => void;
  };
  onLogout: () => void;
  styles?: PopoverStyles;
}

@deboracosilveira
Copy link
Collaborator

please review your use cases, specially the Current Usage, to have a simple and direct info about the usage inside our package

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


## Use Cases

- **Current Usage**: Used as the main navigation header in applications requiring a centered, horizontal navigation layout.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this definition is a bit weird, just keep it simple and explain that is one option of navigation, etc


## Use Cases

- **Current Usage**: Used as the main navigation header in applications requiring a horizontal navigation layout.
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think you can remove this 'header' and also does not mention in applications requiring from the defs, bec this layout can also be one option so the same app can offer multiple nav options

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 (9)
packages/design-system/components/displays/__storybook__/Displays.mdx (2)

26-26: Enhance props documentation with common CircularProgress options.

The props section could be more helpful by listing commonly used CircularProgress props with their types and default values (e.g., size, thickness, color).

Consider expanding the props documentation like this:

- **CircularProgressProps** (MUI CircularProgress Props): Optional props passed directly to the underlying MUI CircularProgress component.
+ **CircularProgressProps** (MUI CircularProgress Props): Optional props passed directly to the underlying MUI CircularProgress component:
+   - `size` (number, default: 40): The size of the circle in pixels
+   - `thickness` (number, default: 3.6): The thickness of the circle
+   - `color` ('primary' | 'secondary' | 'inherit', default: 'primary'): The color of the component

37-45: Add a real-world usage example.

While the current example is good for basic usage, consider adding a more practical example showing integration with data loading.

Consider adding this example:

const DataList = () => {
  const [isLoading, setIsLoading] = useState(true)
  const [data, setData] = useState([])

  useEffect(() => {
    fetchData()
      .then(response => setData(response))
      .finally(() => setIsLoading(false))
  }, [])

  if (isLoading) {
    return <LoadingState CircularProgressProps={{ size: 40, color: 'primary' }} />
  }

  return <List items={data} />
}
packages/design-system/components/Scrollbar/__storybook__/Scrollbar.mdx (1)

26-28: Document additional Scrollbar customization props.

The props section should include all available customization options and event handlers.

Consider expanding the props documentation:

- **children** (ReactNode): The content to be wrapped with the custom scrollbar.
- **sx** (SxProps): Optional Material-UI system props for additional styling.
+ **children** (ReactNode): The content to be wrapped with the custom scrollbar.
+ **sx** (SxProps): Optional Material-UI system props for additional styling.
+ **ref** (Ref): Forward ref to access the scrollbar container.
+ **onScroll** (function): Callback fired when scrolling occurs.
+ **autoHide** (boolean, default: true): Whether to hide scrollbar when not scrolling.
+ **timeout** (number, default: 1000): Delay before hiding scrollbar.
packages/design-system/components/dialogs/__storybook__/Dialogs.mdx (3)

14-14: Improve sentence structure in Expected Behavior.

The sentence is grammatically incomplete.

- Opens as a modal overlay centered on the screen. Can be closed via a close button, clicking outside (if enabled), or pressing ESC key (if enabled).
+ The dialog opens as a modal overlay centered on the screen. It can be closed via a close button, clicking outside (if enabled), or pressing ESC key (if enabled).
🧰 Tools
🪛 LanguageTool

[style] ~14-~14: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)


27-29: Document additional Dialog props.

The props section should include more commonly used MUI Dialog props.

Consider expanding the props documentation:

- **children** (ReactNode): The content to be displayed inside the dialog.
- **open** (boolean): Controls whether the dialog is visible.
- **onClose** ((event: {}, reason: "backdropClick" | "escapeKeyDown") => void): Callback fired when the dialog requests to be closed.
+ **children** (ReactNode): The content to be displayed inside the dialog.
+ **open** (boolean): Controls whether the dialog is visible.
+ **onClose** ((event: {}, reason: "backdropClick" | "escapeKeyDown") => void): Callback fired when the dialog requests to be closed.
+ **maxWidth** ('xs' | 'sm' | 'md' | 'lg' | 'xl'): Determine the max-width of the dialog.
+ **fullWidth** (boolean): If true, the dialog stretches to maxWidth.
+ **disableEscapeKeyDown** (boolean): If true, hitting escape will not fire the onClose callback.
+ **disableBackdropClick** (boolean): If true, clicking the backdrop will not fire the onClose callback.

77-83: Add type information to ConfirmDialog props.

The props section should include type information for better clarity.

- **open** (boolean): Controls the visibility of the dialog
- **title** (string): The heading text displayed at the top of the dialog
- **content** (ReactNode): The main message or content displayed in the dialog body
- **cancelText** (string): Custom text for the cancel button (optional, defaults to "Cancel")
- **onClose** (function): Callback function executed when the cancel button is clicked
- **action** (ReactNode): The action button to be displayed in the dialog
+ **open** (boolean, required): Controls the visibility of the dialog
+ **title** (string, required): The heading text displayed at the top of the dialog
+ **content** (ReactNode, required): The main message or content displayed in the dialog body
+ **cancelText** (string, optional, default: "Cancel"): Custom text for the cancel button
+ **onClose** (() => void, required): Callback function executed when the cancel button is clicked
+ **action** (ReactNode, required): The action button to be displayed in the dialog
packages/components/modules/navigations/__storybook__/NavigationsModule.mdx (3)

32-39: Enhance props documentation with required/optional indicators.

The props documentation would be more helpful if it indicated which props are required and which are optional. Consider using TypeScript-style notation (e.g., navData?: NavigationData).


50-79: Add error handling to the example code.

The example code should demonstrate proper error handling for the setSettings callback.

 const MyComponent = () => {
+  const handleSettingsChange = (newSettings) => {
+    try {
+      // Apply new settings
+      setSettings(newSettings);
+    } catch (error) {
+      console.error('Failed to update settings:', error);
+    }
+  };
+
   return (
     <NavigationLayout
       navData={[/* ... */]}
       settings={defaultTheme.settings}
-      setSettings={() => {}}
+      setSettings={handleSettingsChange}
       LogoIcon={BaseAppLogoCondensed}
     />
   )
 }

246-277: Enhance example code to be more production-ready.

The example code sections could be improved in several ways:

  1. Add missing icon imports
  2. Show proper state management
  3. Include TypeScript types

Here's an improved example for NavMini (similar improvements apply to other components):

 import { NavMini } from '@baseapp-frontend/design-system'
-import { FavoriteIcon, MentionIcon, MenuIcon, PenEditIcon } from '@baseapp-frontend/design-system'
+import {
+  FavoriteIcon,
+  MentionIcon,
+  MenuIcon,
+  PenEditIcon,
+  type NavItem,
+  type NavSettings
+} from '@baseapp-frontend/design-system'
 import { BaseAppLogoCondensed } from '@baseapp-frontend/design-system'
+import { useState } from 'react'

-const MyComponent = () => {
+const MyComponent: React.FC = () => {
+  const [isOpen, setIsOpen] = useState(false)
+
+  const handleClose = () => {
+    setIsOpen(false)
+    console.log('NavMini closed')
+  }

   return (
     <NavMini
       navData={[/* ... */]}
       settings={defaultTheme.settings}
       LogoIcon={BaseAppLogoCondensed}
-      openNav={false}
+      openNav={isOpen}
       hideToggleButton={true}
-      onCloseNav={() => console.log('NavMini closed')}
+      onCloseNav={handleClose}
     />
   )
 }

Also applies to: 312-331, 369-390, 425-444

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ceca0b2 and 5a9bfa1.

📒 Files selected for processing (4)
  • packages/components/modules/navigations/__storybook__/NavigationsModule.mdx (1 hunks)
  • packages/design-system/components/Scrollbar/__storybook__/Scrollbar.mdx (1 hunks)
  • packages/design-system/components/dialogs/__storybook__/Dialogs.mdx (1 hunks)
  • packages/design-system/components/displays/__storybook__/Displays.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/design-system/components/dialogs/__storybook__/Dialogs.mdx

[style] ~14-~14: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)

🔇 Additional comments (3)
packages/components/modules/navigations/__storybook__/NavigationsModule.mdx (3)

1-3: LGTM! Well-structured MDX documentation.

The file follows Storybook's MDX documentation standards with proper imports and title structure.


1-444: LGTM! Well-maintained documentation consistency.

The documentation follows a consistent structure across all components, making it easy to navigate and understand. Each section (Purpose, Expected Behavior, Use Cases, Props, Notes, Example Usage) is consistently formatted and provides valuable information.


1-444: Documentation successfully meets PR objectives.

The MDX documentation is comprehensive, follows the provided template, and effectively documents all the required components (NavigationLayout, Header, AccountPopover, NavMini, NavCentered, NavVertical, NavHorizontal). This satisfies the PR objective of adding missing MDX documentation files.

Comment on lines 13 to 14
## Components

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add accessibility guidelines section.

Consider adding an Accessibility section to the documentation that covers:

  • ARIA attributes
  • Keyboard navigation
  • Screen reader compatibility
  • Color contrast requirements

Comment on lines 154 to 164
- **MenuItems** (MenuItem[]): Array of menu items containing label and onClick handlers for each action
- **PopoverStyles** (object): Styles for the popover component
- **CurrentUser** (object): The current user object containing profile information
- **SwitchProfileMenu** (object): The switch profile menu object containing label and onClick handlers for each action
- **SwitchProfileMenuProps** (object): The switch profile menu props object containing label and onClick handlers for each action
- **ProfilesList** (object): The profiles list object containing label and onClick handlers for each action
- **ProfilesListProps** (object): The profiles list props object containing label and onClick handlers for each action
- **AddProfileMenuItem** (object): The add profile menu item object containing label and onClick handlers for each action
- **AddProfileMenuItemProps** (object): The add profile menu item props object containing label and onClick handlers for each action
- **LogoutItemProps** (object): The logout menu item props object containing label and onClick handlers for each action

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify props documentation by removing redundancy.

Several props have redundant entries with "Props" suffix. Consider consolidating them and adding type information:

- **MenuItems** (MenuItem[]): Array of menu items containing label and onClick handlers for each action
- **PopoverStyles** (object): Styles for the popover component
- **CurrentUser** (object): The current user object containing profile information
- **SwitchProfileMenu** (object): The switch profile menu object containing label and onClick handlers for each action
- **SwitchProfileMenuProps** (object): The switch profile menu props object containing label and onClick handlers for each action
+ **menuItems** (MenuItem[]): Array of menu items containing label and onClick handlers for each action
+ **popoverStyles** (MUIPopoverProps): Material-UI Popover component props
+ **currentUser** (User): Current user profile information
+ **switchProfileMenu** ({
+   label: string;
+   onClick: () => void;
+ }): Configuration for the profile switching menu

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

@joaosoutto joaosoutto requested a review from sundayguru January 7, 2025 13:50
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: 4

♻️ Duplicate comments (1)
packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/AccountPopover.mdx (1)

24-34: 🛠️ Refactor suggestion

Simplify props structure to reduce duplication.

The props section contains several overlapping props with similar purposes.

As mentioned in the previous review, consider simplifying the props structure:

- **MenuItems** (MenuItem[]): Array of menu items containing label and onClick handlers for each action
- **PopoverStyles** (object): Styles for the popover component
- **CurrentUser** (object): The current user object containing profile information
- **SwitchProfileMenu** (object): The switch profile menu object containing label and onClick handlers for each action
- **SwitchProfileMenuProps** (object): The switch profile menu props object containing label and onClick handlers for each action
- **ProfilesList** (object): The profiles list object containing label and onClick handlers for each action
- **ProfilesListProps** (object): The profiles list props object containing label and onClick handlers for each action
- **AddProfileMenuItem** (object): The add profile menu item object containing label and onClick handlers for each action
- **AddProfileMenuItemProps** (object): The add profile menu item props object containing label and onClick handlers for each action
- **LogoutItemProps** (object): The logout menu item props object containing label and onClick handlers for each action

+ **menuItems** (MenuItem[]): Array of menu items containing label and onClick handlers for each action
+ **styles** (PopoverStyles): Optional styles for customizing the popover appearance
+ **currentUser** (User): The current user object containing profile information
+ **switchProfile** ({
+   label: string;
+   onClick: () => void;
+ }): Configuration for the profile switching functionality
+ **profiles** ({
+   list: Profile[];
+   onAdd: () => void;
+ }): Profile list configuration and add profile handler
+ **onLogout** (() => void): Handler for logout action
🧹 Nitpick comments (8)
packages/components/modules/navigations/NavCentered/__storybook__/NavCentered.mdx (1)

14-14: Simplify the current usage description

The current usage description is too technical. Keep it simple and focus on the component's role.

-  - **Current Usage**: Used as a centered horizontal navigation component with responsive mobile drawer.
+  - **Current Usage**: Provides a centered navigation menu that adapts to both desktop and mobile views.
packages/components/modules/navigations/Header/__storybook__/Header.mdx (1)

47-54: Add error handling to example usage

The example should demonstrate proper error handling for the onOpenNav callback.

 const MyComponent = () => {
+  const handleOpenNav = React.useCallback((event: React.MouseEvent) => {
+    try {
+      // Add your navigation logic here
+    } catch (error) {
+      console.error('Failed to open navigation:', error);
+    }
+  }, []);
+
   return (
     <Header settings={{ themeLayout: 'horizontal' }}>
       <LogoIcon />
       <AccountMenu />
+      onOpenNav={handleOpenNav}
     </Header>
   )
 }
packages/components/modules/navigations/NavigationLayout/__storybook__/NavigationLayout.mdx (1)

64-64: Improve setSettings example implementation

The current example shows an empty callback. Demonstrate proper settings management.

-      setSettings={() => {}}
+      setSettings={(newSettings) => {
+        // Example: Update settings in state/context
+        console.log('Updating settings:', newSettings);
+        // updateSettings(newSettings);
+      }}
packages/components/modules/navigations/NavMini/__storybook__/NavMini.mdx (2)

24-30: Enhance props documentation with type information and default values.

The props section should include more detailed type information and default values for better developer understanding.

Consider enhancing the props documentation like this:

- **navData** (array): Navigation items data containing routes and content
+ **navData** (NavigationItem[]): Navigation items data containing routes and content. Each item should conform to the NavigationItem interface with subheader and items properties.
  
- **settings** (object): Configuration settings for the navigation component
+ **settings** (NavigationSettings): Configuration settings for the navigation component. Controls theme, behavior, and display options.

- **setSettings** (function): Callback to update navigation settings
+ **setSettings** ((settings: NavigationSettings) => void): Callback to update navigation settings.

- **LogoIcon** (component): Optional custom logo component to display at top
+ **LogoIcon** (React.ComponentType): Optional custom logo component to display at top. Defaults to undefined.

- **openNav** (boolean): Controls visibility of mobile navigation drawer
+ **openNav** (boolean): Controls visibility of mobile navigation drawer. Defaults to false.

- **onCloseNav** (function): Callback when mobile navigation drawer closes
+ **onCloseNav** (() => void): Callback when mobile navigation drawer closes.

- **hideToggleButton** (boolean): Optional flag to hide the navigation toggle button, defaults to false
+ **hideToggleButton** (boolean): Optional flag to hide the navigation toggle button. Defaults to false.

44-76: Add TypeScript interfaces to example code.

The example usage would be more helpful with TypeScript interfaces and proper type annotations.

Consider enhancing the example like this:

 import { NavMini } from '@baseapp-frontend/design-system'
 import { FavoriteIcon, MentionIcon, MenuIcon, PenEditIcon } from '@baseapp-frontend/design-system'
 import { BaseAppLogoCondensed } from '@baseapp-frontend/design-system'
+
+interface NavigationItem {
+  subheader: string;
+  items: Array<{
+    title: string;
+    icon: React.ReactNode;
+  }>;
+}
 
 const MyComponent = () => {
+  const navData: NavigationItem[] = [
-  return (
-    <NavMini
-      navData={[
packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx (3)

10-10: Improve grammar in Expected Behavior section.

The sentence structure needs improvement for better clarity.

Consider revising the text:

- Opens as a modal overlay centered on the screen. Can be closed via a close button, clicking outside (if enabled), or pressing ESC key (if enabled).
+ The dialog opens as a modal overlay centered on the screen. It can be closed via a close button, clicking outside (if enabled), or pressing the ESC key (if enabled).
🧰 Tools
🪛 LanguageTool

[style] ~10-~10: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)


23-25: Enhance props documentation with additional properties.

The props section is missing some commonly used properties of the Dialog component.

Consider adding these additional props:

 - **children** (ReactNode): The content to be displayed inside the dialog.
 - **open** (boolean): Controls whether the dialog is visible.
 - **onClose** ((event: {}, reason: "backdropClick" | "escapeKeyDown") => void): Callback fired when the dialog requests to be closed.
+- **maxWidth** ("xs" | "sm" | "md" | "lg" | "xl"): Determine the max-width of the dialog. Defaults to "sm".
+- **fullWidth** (boolean): If true, the dialog stretches to maxWidth. Defaults to false.
+- **fullScreen** (boolean): If true, the dialog will be displayed in full screen. Defaults to false.
+- **disableEscapeKeyDown** (boolean): If true, hitting escape will not fire the onClose callback. Defaults to false.
+- **disableBackdropClick** (boolean): If true, clicking the backdrop will not fire the onClose callback. Defaults to false.

36-49: Enhance example usage with additional features.

The example usage could demonstrate more features of the Dialog component.

Consider enhancing the example:

 import { Dialog } from '@baseapp-frontend/design-system'
 
 const MyComponent = () => {
   const [open, setOpen] = useState(false)
 
   return (
-    <Dialog open={open} onClose={() => setOpen(false)}>
-      <div>Dialog content</div>
+    <Dialog
+      open={open}
+      onClose={() => setOpen(false)}
+      maxWidth="md"
+      fullWidth
+      disableBackdropClick={false}
+      disableEscapeKeyDown={false}
+    >
+      <DialogTitle>Example Dialog</DialogTitle>
+      <DialogContent>
+        <DialogContentText>
+          This is an example of a dialog with additional features.
+        </DialogContentText>
+      </DialogContent>
+      <DialogActions>
+        <Button onClick={() => setOpen(false)}>Cancel</Button>
+        <Button onClick={() => setOpen(false)} variant="contained">
+          Confirm
+        </Button>
+      </DialogActions>
     </Dialog>
   )
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a9bfa1 and 45e522d.

📒 Files selected for processing (10)
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/AccountPopover.mdx (1 hunks)
  • packages/components/modules/navigations/Header/__storybook__/Header.mdx (1 hunks)
  • packages/components/modules/navigations/NavCentered/__storybook__/NavCentered.mdx (1 hunks)
  • packages/components/modules/navigations/NavHorizontal/__storybook__/NavHorizontal.mdx (1 hunks)
  • packages/components/modules/navigations/NavMini/__storybook__/NavMini.mdx (1 hunks)
  • packages/components/modules/navigations/NavVertical/__storybook__/NavVertical.mdx (1 hunks)
  • packages/components/modules/navigations/NavigationLayout/__storybook__/NavigationLayout.mdx (1 hunks)
  • packages/design-system/components/Scrollbar/__storybook__/Scrollbar.mdx (1 hunks)
  • packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx (1 hunks)
  • packages/design-system/components/displays/LoadingState/__storybook__/LoadingState.mdx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/design-system/components/displays/LoadingState/storybook/LoadingState.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/design-system/components/Scrollbar/storybook/Scrollbar.mdx
🧰 Additional context used
🪛 LanguageTool
packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx

[style] ~10-~10: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)

Comment on lines +24 to +26
- **navData** (array): Navigation items data containing routes and content
- **openNav** (boolean): Controls visibility of mobile navigation drawer
- **onCloseNav** (function): Callback when mobile navigation drawer closes
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 information

Add type information and required/optional status for each prop.

- **navData** (array): Navigation items data containing routes and content
- **openNav** (boolean): Controls visibility of mobile navigation drawer 
- **onCloseNav** (function): Callback when mobile navigation drawer closes
+ **navData** (NavigationItem[], required): Array of navigation items containing routes and content
+   ```typescript
+   interface NavigationItem {
+     title: string;
+     icon?: React.ReactNode;
+     path?: string;
+   }
+   ```
+ **openNav** (boolean, required): Controls visibility of mobile navigation drawer 
+ **onCloseNav** (() => void, required): Callback function invoked when mobile navigation drawer closes

Comment on lines +24 to +26
- **settings** (object): Configuration settings for the navigation component
- **setSettings** (function): Callback to update navigation settings
- **navData** (array): Navigation items data containing routes and content
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Document settings type structure

Add detailed type information for the settings object.

- **settings** (object): Configuration settings for the navigation component
- **setSettings** (function): Callback to update navigation settings
+ **settings** (UISettings, required): Configuration settings for the navigation component
+   ```typescript
+   interface UISettings {
+     themeMode: 'light' | 'dark';
+     themeLayout: 'vertical' | 'horizontal' | 'mini';
+     themeStretch: boolean;
+     themeContrast: 'default' | 'bold';
+   }
+   ```
+ **setSettings** ((settings: Partial<UISettings>) => void, required): Callback to update navigation settings


## Props

- **navData** (NavigationData): Navigation configuration data containing routes, icons, and menu structure
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Document NavigationData type structure

Add detailed type information for the NavigationData structure.

- **navData** (NavigationData): Navigation configuration data containing routes, icons, and menu structure
+ **navData** (NavigationData[], required): Navigation configuration data containing routes, icons, and menu structure
+   ```typescript
+   interface NavigationData {
+     subheader?: string;
+     items: Array<{
+       title: string;
+       path?: string;
+       icon?: React.ReactNode;
+       info?: React.ReactNode;
+       children?: NavigationData[];
+     }>;
+   }
+   ```

Comment on lines +45 to +77
```javascript
import { AccountPopover } from '@baseapp-frontend/design-system'

const MyComponent = () => {
return (
<AccountPopover
MenuItemsProps={{
menuItems: [
{ label: 'Profile', onClick: () => console.log('Profile clicked') },
{ label: 'Settings', onClick: () => console.log('Settings clicked') },
],
}}
SwitchProfileMenuProps={{
label: 'Switch Profile',
onClick: () => console.log('Switch Profile clicked'),
}}
ProfilesListProps={{
label: 'Profiles List',
onClick: () => console.log('Profiles List clicked'),
}}
AddProfileMenuItemProps={{
label: 'Add Profile',
onClick: () => console.log('Add Profile clicked'),
}}
LogoutItemProps={{
label: 'Logout',
onClick: () => console.log('Logout clicked'),
}}
/>
)
}
export default MyComponent
```
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Update example usage to match simplified props structure.

The example usage should reflect the simplified props structure for better clarity.

Consider updating the example:

 const MyComponent = () => {
   return (
     <AccountPopover
-      MenuItemsProps={{
-        menuItems: [
+      menuItems={[
           { label: 'Profile', onClick: () => console.log('Profile clicked') },
           { label: 'Settings', onClick: () => console.log('Settings clicked') },
-        ],
-      }}
-      SwitchProfileMenuProps={{
+      ]}
+      switchProfile={{
         label: 'Switch Profile',
         onClick: () => console.log('Switch Profile clicked'),
       }}
-      ProfilesListProps={{
-        label: 'Profiles List',
-        onClick: () => console.log('Profiles List clicked'),
-      }}
-      AddProfileMenuItemProps={{
-        label: 'Add Profile',
-        onClick: () => console.log('Add Profile clicked'),
-      }}
-      LogoutItemProps={{
-        label: 'Logout',
-        onClick: () => console.log('Logout clicked'),
+      profiles={{
+        list: [],
+        onAdd: () => console.log('Add Profile clicked'),
       }}
+      onLogout={() => console.log('Logout clicked')}
     />
   )
 }
📝 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 { AccountPopover } from '@baseapp-frontend/design-system'
const MyComponent = () => {
return (
<AccountPopover
MenuItemsProps={{
menuItems: [
{ label: 'Profile', onClick: () => console.log('Profile clicked') },
{ label: 'Settings', onClick: () => console.log('Settings clicked') },
],
}}
SwitchProfileMenuProps={{
label: 'Switch Profile',
onClick: () => console.log('Switch Profile clicked'),
}}
ProfilesListProps={{
label: 'Profiles List',
onClick: () => console.log('Profiles List clicked'),
}}
AddProfileMenuItemProps={{
label: 'Add Profile',
onClick: () => console.log('Add Profile clicked'),
}}
LogoutItemProps={{
label: 'Logout',
onClick: () => console.log('Logout clicked'),
}}
/>
)
}
export default MyComponent
```
import { AccountPopover } from '@baseapp-frontend/design-system'
const MyComponent = () => {
return (
<AccountPopover
menuItems={[
{ label: 'Profile', onClick: () => console.log('Profile clicked') },
{ label: 'Settings', onClick: () => console.log('Settings clicked') },
]}
switchProfile={{
label: 'Switch Profile',
onClick: () => console.log('Switch Profile clicked'),
}}
profiles={{
list: [],
onAdd: () => console.log('Add Profile clicked'),
}}
onLogout={() => console.log('Logout clicked')}
/>
)
}
export default MyComponent

@joaosoutto joaosoutto force-pushed the BA-2016-missing-MDX-group2 branch from 45e522d to 27ca7da Compare January 8, 2025 15:27
@joaosoutto joaosoutto force-pushed the BA-2016-missing-MDX-group2 branch from 27ca7da to f754a0b Compare January 8, 2025 17:00
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: 1

🧹 Nitpick comments (9)
packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx (4)

9-10: Enhance accessibility documentation

The description is good, but could be more specific about accessibility features. Consider adding:

  • ARIA roles and attributes used
  • Keyboard navigation patterns
  • Screen reader behavior

Also, fix these grammatical issues for better clarity:

-Opens as a modal overlay centered on the screen. Can be closed via a close button
+The dialog opens as a modal overlay centered on the screen. It can be closed via a close button
-pressing ESC key
+pressing the ESC key
🧰 Tools
🪛 LanguageTool

[style] ~10-~10: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)


[uncategorized] ~10-~10: You might be missing the article “the” here.
Context: ...cking outside (if enabled), or pressing ESC key (if enabled). Should trap focus wit...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


23-25: Document additional common dialog props

Consider documenting these additional props for completeness:

  • maxWidth: Maximum width of the dialog
  • fullWidth: If true, the dialog stretches to maximum width
  • fullScreen: If true, the dialog fills the screen
  • disableEscapeKeyDown: Disable the ESC key handler
  • disableBackdropClick: Disable clicking outside to close

29-32: Add cross-references to related components

Consider adding links to the documentation of related components to help users navigate between them:

-- ConfirmDialog: A specialized version for confirmation actions
+- [ConfirmDialog](/docs/designSystem-dialogs-confirmdialog--docs): A specialized version for confirmation actions

36-49: Enhance example usage section

Consider adding more comprehensive examples:

  1. Dialog with custom width and fullScreen behavior
  2. Dialog with form elements showing focus management
  3. Dialog with custom close behavior
  4. Dialog with different content layouts

Example:

const MyComponent = () => {
  const [open, setOpen] = useState(false);
  
  const handleClose = (event, reason) => {
    if (reason !== 'backdropClick') {
      setOpen(false);
    }
  };

  return (
    <Dialog 
      open={open} 
      onClose={handleClose}
      maxWidth="md"
      fullWidth
      disableBackdropClick
    >
      <DialogTitle>Custom Dialog</DialogTitle>
      <DialogContent>
        <form>
          {/* Form elements */}
        </form>
      </DialogContent>
      <DialogActions>
        <Button onClick={() => setOpen(false)}>Close</Button>
      </DialogActions>
    </Dialog>
  );
};
packages/design-system/components/displays/LoadingState/__storybook__/LoadingState.mdx (5)

1-3: Standardize the Storybook title format.

Consider using forward slashes consistently throughout the title for better hierarchy:

-<Meta title="@baseapp-frontend | designSystem/Displays/LoadingState" />
+<Meta title="@baseapp-frontend/Design System/Displays/LoadingState" />

9-10: Add accessibility information to the component overview.

Consider adding details about the component's accessibility features, such as ARIA attributes or screen reader behavior.


24-24: Enhance props documentation with more details and links.

Consider:

  1. Adding a link to the MUI CircularProgress documentation
  2. Including common CircularProgressProps that users might want to customize
  3. Adding a props table with type information

28-31: Clarify relationships with related components.

For each related component, explain when to use one over the other and provide specific scenarios. For example:

  • When to use LoadingState vs. plain CircularProgress
  • Specific examples of using LoadingState within Dialog or Popover

35-43: Expand example usage with more real-world scenarios.

Consider adding:

  1. Multiple examples showing different use cases
  2. Error handling scenarios
  3. Integration with async operations
  4. Usage within containers (Dialog, Popover)

Example:

import { LoadingState } from '@baseapp-frontend/design-system'

// Basic usage
const SimpleExample = () => (
  <LoadingState CircularProgressProps={{ size: 40 }} />
)

// Usage with async data fetching
const DataFetchingExample = () => {
  const [isLoading, setIsLoading] = useState(true)
  
  return (
    <div style={{ position: 'relative', minHeight: '200px' }}>
      {isLoading && <LoadingState />}
      {/* Content */}
    </div>
  )
}

// Usage within Dialog
const DialogExample = () => (
  <Dialog open={true}>
    <LoadingState CircularProgressProps={{ size: 24 }} />
  </Dialog>
)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 45e522d and f754a0b.

📒 Files selected for processing (10)
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/__storybook__/AccountPopover.mdx (1 hunks)
  • packages/components/modules/navigations/Header/__storybook__/Header.mdx (1 hunks)
  • packages/components/modules/navigations/NavCentered/__storybook__/NavCentered.mdx (1 hunks)
  • packages/components/modules/navigations/NavHorizontal/__storybook__/NavHorizontal.mdx (1 hunks)
  • packages/components/modules/navigations/NavMini/__storybook__/NavMini.mdx (1 hunks)
  • packages/components/modules/navigations/NavVertical/__storybook__/NavVertical.mdx (1 hunks)
  • packages/components/modules/navigations/NavigationLayout/__storybook__/NavigationLayout.mdx (1 hunks)
  • packages/design-system/components/Scrollbar/__storybook__/Scrollbar.mdx (1 hunks)
  • packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx (1 hunks)
  • packages/design-system/components/displays/LoadingState/__storybook__/LoadingState.mdx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/design-system/components/Scrollbar/storybook/Scrollbar.mdx
  • packages/components/modules/navigations/NavCentered/storybook/NavCentered.mdx
  • packages/components/modules/navigations/Header/storybook/Header.mdx
  • packages/components/modules/navigations/NavHorizontal/storybook/NavHorizontal.mdx
  • packages/components/modules/navigations/Header/AccountMenu/AccountPopover/storybook/AccountPopover.mdx
  • packages/components/modules/navigations/NavMini/storybook/NavMini.mdx
  • packages/components/modules/navigations/NavigationLayout/storybook/NavigationLayout.mdx
  • packages/components/modules/navigations/NavVertical/storybook/NavVertical.mdx
🧰 Additional context used
🪛 LanguageTool
packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx

[style] ~10-~10: To form a complete sentence, be sure to include a subject.
Context: ...a modal overlay centered on the screen. Can be closed via a close button, clicking ...

(MISSING_IT_THERE)


[uncategorized] ~10-~10: You might be missing the article “the” here.
Context: ...cking outside (if enabled), or pressing ESC key (if enabled). Should trap focus wit...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Component Test Applications and Packages
  • GitHub Check: Lint
🔇 Additional comments (2)
packages/design-system/components/dialogs/Dialog/__storybook__/BaseDialog.mdx (1)

1-3: Verify title structure consistency

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

✅ Verification successful

Title structure is consistent with other MDX files

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check title structure consistency across MDX files
# Expected pattern: "@baseapp-frontend | designSystem/<category>/<component>"

# Search for Meta title patterns in MDX files
rg -t mdx '<Meta title="@baseapp-frontend \| designSystem/' -A 1

Length of output: 94


Script:

#!/bin/bash
# Find all MDX files and search for Meta title patterns
fd '.mdx$' | xargs rg '<Meta title=".*designSystem/'

# Alternative search to catch potential variations
fd '.mdx$' | xargs rg 'title="@baseapp-frontend.*designSystem'

Length of output: 1563

packages/design-system/components/displays/LoadingState/__storybook__/LoadingState.mdx (1)

14-14: Enhance the Current Usage section with specific examples.

As per the previous review feedback, please provide more specific and direct information about how the component is currently being used within the package. Instead of a generic description, include concrete examples of where and how it's implemented.

Let's find specific usage examples in the codebase:

✅ Verification successful

Update Current Usage section with concrete examples

The Current Usage section should be updated to reflect the actual implementation patterns found in the codebase:

- **Current Usage**: Used as a loading indicator in several key scenarios:
  - Suspense boundaries for async component loading
  - Infinite scroll pagination in lists (messages, notifications, comments)
  - Initial data fetching states in profile and member views
  - Processing feedback during user interactions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for actual usage of LoadingState component
rg -l "LoadingState" --type ts --type tsx | grep -v "__storybook__" | grep -v "\.stories\."

Length of output: 117


Script:

#!/bin/bash
# Find all TypeScript and React files
echo "=== TypeScript and React files containing LoadingState ==="
fd "\.(ts|tsx)$" | xargs rg "LoadingState" -l | grep -v "__storybook__" | grep -v "\.stories\."

echo -e "\n=== Usage context (showing 3 lines before and after) ==="
fd "\.(ts|tsx)$" | xargs rg "LoadingState" -B 3 -A 3 | grep -v "__storybook__" | grep -v "\.stories\."

echo -e "\n=== Import statements ==="
fd "\.(ts|tsx)$" | xargs rg "import.*LoadingState" | grep -v "__storybook__" | grep -v "\.stories\."

Length of output: 46510

Comment on lines +14 to +19
- **Current Usage**: Used in confirmation flows, detailed information display, form submissions, and important user notifications.
- **Potential Usage**: Could be used for:
- User preferences or settings panels
- Detailed item previews
- Multi-step forms
- Error or success messages requiring acknowledgment
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify current usage examples per reviewer's feedback

As requested by @deboracosilveira, the "Current Usage" section should be more direct and specific. Consider:

  1. Providing concrete examples from the actual codebase
  2. Including code snippets for each use case
  3. Removing generic descriptions in favor of specific implementations

@joaosoutto joaosoutto merged commit 1be5f9c into master Jan 8, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants