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

storybook audit fixes for typography,hamburger and sidebar #142

Merged
merged 4 commits into from
Oct 29, 2024

Conversation

Swathi-eGov
Copy link

No description provided.

Copy link

coderabbitai bot commented Oct 28, 2024

Walkthrough

This pull request introduces several changes across multiple files, primarily focusing on enhancing typography styles in the index.scss file and updating CSS links to a new version. New story files for typography components have been created to demonstrate various text styles, while existing components like BreadCrumb, MobileSidebar, and Uploader have been modified to include new properties or functionality. Additionally, some story files have been deleted or renamed to streamline the structure and categorization of components.

Changes

File Path Change Summary
react/css/src/digitv2/index.scss Added new typography styles with nested classes for headings and body text, including media queries.
react/example/public/index.html Updated CSS link version from 0.0.2-beta.39 to 0.0.2-beta.40.
react/ui-components/.storybook/preview-head.html Updated CSS link version from 0.0.2-beta.39 to 0.0.2-beta.40.
react/ui-components/public/index.html Updated CSS link version from 0.0.2-beta.39 to 0.0.2-beta.40.
react/ui-components/src/atoms/BreadCrumb.js Added handleRedirect function for external navigation.
react/ui-components/src/atoms/MobileSidebar.js Added size prop to Button and isSearchable prop to propTypes.
react/ui-components/src/atoms/MultiSelectDropdown.js Added hideClose property to Chip component.
react/ui-components/src/atoms/UploadFile.js Added hideClose property to Chip component in uploaded files.
react/ui-components/src/atoms/Uploader.js Added hideClose property and refined error handling logic.
react/ui-components/src/atoms/stories/BodyTypography.stories.js Introduced new story variations for body typography components.
react/ui-components/src/atoms/stories/ButtonTypography.stories.js Introduced new story variations for button typography components.
react/ui-components/src/atoms/stories/CaptionTypography.stories.js Introduced new story variations for caption typography components.
react/ui-components/src/atoms/stories/Dropdown.stories.js Renamed exports and updated title for dropdown stories, removed multi-select options.
react/ui-components/src/atoms/stories/Hamburger.stories.js Deleted file containing stories for MobileSidebar.
react/ui-components/src/atoms/stories/HeadingTypography.stories.js Introduced new story variations for heading typography components.
react/ui-components/src/atoms/stories/LabelTypography.stories.js Introduced new story for label typography components.
react/ui-components/src/atoms/stories/LinkTypography.stories.js Introduced new story for link typography components.
react/ui-components/src/atoms/stories/MultiselectDropdown.stories.js Introduced new story file for custom dropdown functionality.
react/ui-components/src/atoms/stories/Typography.stories.js Deleted file containing various typography stories.
react/ui-components/src/molecules/stories/DarkThemeHamburger.stories.js Introduced new story file for MobileSidebar in dark theme.
react/ui-components/src/molecules/stories/DarkThemeHeader.stories.js Introduced new story file for TopBar in dark theme.
react/ui-components/src/molecules/stories/Footer.stories.js Updated title from "Atoms/Footer" to "Molecules/Footer".
react/ui-components/src/molecules/stories/LightThemeHamburger.stories.js Introduced new story file for MobileSidebar in light theme.
react/ui-components/src/molecules/stories/LightThemeHeader.stories.js Updated title from "Atoms/Header" to "Molecules/Header/Light" and removed dark theme exports.

Possibly related PRs

  • updated style prop and added chip shadow #138: The changes in this PR involve updates to SCSS files that enhance button and chip styles, which may relate to the overall typography and styling improvements introduced in the main PR's typography section.

Suggested reviewers

  • jagankumar-egov

Poem

🐇 In the garden of styles, we hop and play,
New fonts and colors brighten the day.
With links and buttons, all dressed in cheer,
Our UI shines bright, let’s give a big cheer!
Typography dances, stories unfold,
In the world of design, new tales are told! 🌼


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

🧹 Outside diff range and nitpick comments (21)
react/example/public/index.html (1)

12-12: Consider adding version constraints.

To prevent unintended updates and ensure consistent behavior, consider using version constraints (e.g., exact version or caret/tilde ranges) in package.json instead of directly referencing unpkg URLs.

This approach would:

  1. Make version management more maintainable
  2. Ensure consistent versions across environments
  3. Allow for proper dependency tracking
react/ui-components/src/atoms/stories/LinkTypography.stories.js (1)

4-8: Add component documentation and controls.

Consider enhancing the story configuration with:

  • Component description using the parameters.docs.description field
  • Common props in argTypes for interactive documentation
 export default {
   title: "Foundations/Typography/Link",
+  parameters: {
+    docs: {
+      description: {
+        component: 'Typography component for links in different sizes: L (20pts), S (16pts), and XS (14pts).'
+      }
+    }
+  },
   argTypes: {
+    className: {
+      description: 'Additional CSS class names',
+      control: 'text'
+    },
+    children: {
+      description: 'Link content',
+      control: 'text'
+    }
   },
 };
react/ui-components/src/atoms/stories/ButtonTypography.stories.js (1)

1-88: Enhance accessibility and internationalization.

Consider the following improvements:

  1. Add proper ARIA labels and roles
  2. Use semantic HTML elements where appropriate
  3. Extract text content for internationalization

Example improvements:

+import { useTranslation } from 'react-i18next';

 const ButtonTypography = ({ size }) => {
+  const { t } = useTranslation();
   const sizeMap = {
-    large: { text: "button large / 20pts", className: "large" },
+    large: { text: t('typography.button.large.label'), className: "large" },
     // ... other sizes
   };
   
   return (
     <div
+      role="presentation"
+      aria-label={t('typography.button.preview')}
       // ... other props
     >
react/ui-components/src/molecules/stories/Footer.stories.js (1)

6-6: Resolve component naming and categorization inconsistencies.

There are several architectural inconsistencies that need to be addressed:

  1. The story is titled "Footer" but demonstrates the ActionBar component
  2. The component is imported from "atoms" but categorized under "Molecules"
  3. The file name Footer.stories.js doesn't match the actual component being demonstrated

Consider the following improvements:

  1. Rename the file to ActionBar.stories.js to match the component
  2. Either move the story back to "Atoms" or move the ActionBar component to the molecules directory
  3. Update the story title accordingly based on the chosen categorization

This will improve maintainability and make the component easier to discover in Storybook.

react/ui-components/src/atoms/stories/HeadingTypography.stories.js (1)

10-19: Improve style object formatting and positioning.

  1. The use of absolute positioning might cause layout issues in different viewport sizes
  2. Style properties should have consistent spacing
 const style = {
-  position: "absolute",
-  top: "50%",
-  left: "50%",
+  margin: "2rem auto",
   color: "#363636",
   display: "flex",
   justifyContent: "center",
-  transform: "translate(-50%, -50%)",
-  lineHeight:"normal"
+  lineHeight: "normal"
 };
react/ui-components/src/atoms/BreadCrumb.js (2)

Line range hint 103-112: Add missing PropType validation and improve type definitions.

The new externalPath property is not defined in PropTypes, and some existing prop validations could be more specific.

Update the PropTypes definition:

 BreadCrumb.propTypes = {
-  crumbs: PropTypes.array,
+  crumbs: PropTypes.arrayOf(PropTypes.shape({
+    content: PropTypes.node.isRequired,
+    path: PropTypes.string,
+    externalPath: PropTypes.bool,
+    show: PropTypes.bool,
+    icon: PropTypes.node,
+    isBack: PropTypes.bool,
+    count: PropTypes.number
+  })).isRequired,
   className: PropTypes.string,
   style: PropTypes.object,
   spanStyle: PropTypes.object,
   customSeparator: PropTypes.element,
   maxItems: PropTypes.number,
   itemsAfterCollapse: PropTypes.number,
   itemsBeforeCollapse: PropTypes.number,
   expandText: PropTypes.string
 };

Line range hint 64-98: Improve accessibility and React key handling in the breadcrumb list.

The current implementation has some accessibility and React key issues that should be addressed.

Consider these improvements:

  1. Add proper ARIA attributes for breadcrumb navigation
  2. Replace Fragment with proper key handling
  3. Add proper role attributes
-          <>
+          <Fragment key={`crumb-${ci}`}>
             <li
-              key={ci}
               style={props?.itemStyle}
-              className="digit-bread-crumb--item"
+              className="digit-bread-crumb--item"
+              role="listitem"
             >
               {/* ... existing content ... */}
             </li>
-          </>
+          </Fragment>

Also, consider adding these attributes to the outer ol element:

     <ol
       className={`digit-bread-crumb ${
         props?.className ? props?.className : ""
       }`}
+      role="navigation"
+      aria-label="Breadcrumb"
       style={props?.style}
     >
react/ui-components/src/molecules/stories/DarkThemeHamburger.stories.js (1)

15-15: Fix inconsistent spacing in object properties.

The isSearchable property has inconsistent spacing. Maintain consistent spacing in object properties.

-    isSearchable:{control:"boolean"},
+    isSearchable: { control: "boolean" },
react/ui-components/src/molecules/stories/LightThemeHamburger.stories.js (1)

9-24: Improve argTypes organization and consistency.

Consider grouping related props together and maintaining consistent spacing:

 argTypes: {
+  // Appearance
   theme: { control: "select", options: ["dark", "light"] },
   variant: { control: "select", options: ["primary", "secondary"] },
   transitionDuration: { control: "number" },
+  // Content
   items: { control: "object" },
   usermanuals: { control: "object" },
   userManualLabel: { control: "text" },
   profile: { control: "text" },
+  // Behavior
   isSearchable: { control: "boolean" },
   hideUserManuals: { control: "boolean" },
   reopenOnLogout: { control: "boolean" },
   closeOnClickOutside: { control: "boolean" },
+  // Events
   onSelect: { action: "onChange" },
   onLogout: { action: "onChange" },
   onOutsideClick: { action: "onChange" }
 }
react/ui-components/src/molecules/stories/LightThemeHeader.stories.js (1)

Line range hint 1-358: Consider enhancing story documentation.

While the component stories demonstrate various configurations well, consider adding JSDoc comments to describe:

  • The purpose of each story variant
  • The expected behavior of the interactive elements
  • The use cases for different configurations

This would improve the documentation value of the storybook.

Example enhancement:

+/**
+ * Default light theme header with basic configuration.
+ * Shows the header with city name and language selector.
+ */
export const LightThemeHeader = Template.bind({});

+/**
+ * Light theme header with dropdown menu options.
+ * Demonstrates the header with multiple dropdown fields for city selection,
+ * language preference, and user profile actions.
+ */
export const WithActionFields = Template.bind({});
react/ui-components/src/molecules/stories/DarkThemeHeader.stories.js (1)

192-204: Update default theme in commonArgs.

Since this file is specifically for dark theme stories, consider updating the default theme.

 const commonArgs = {
   img: "",
   className: "",
   style: {},
-  theme: "light",
+  theme: "dark",
   setImageToLeft: false,
react/ui-components/src/atoms/stories/Dropdown.stories.js (2)

Line range hint 7-31: Update argTypes to match new naming convention and remove deprecated options.

The configuration needs to be aligned with the new naming convention and removed features:

  1. The type options still include "multiselectdropdown" despite multi-select functionality being removed
  2. The variant options use old naming (e.g., "nesteddropdown") while story exports use new naming (e.g., "Categorical")

Apply this diff to update the configuration:

  type: { control: "select", options: [
-   "dropdown", "multiselectdropdown"
+   "dropdown"
  ]},
  variant: {
    control: "select",
    options: [
-     "nesteddropdown",
-     "treedropdown",
-     "nestedtextdropdown",
-     "profiledropdown",
-     "profilenestedtext",
+     "categorical",
+     "tree",
+     "nestedText",
+     "profile",
+     "profileNestedText",
    ],
  },

Line range hint 254-399: Enhance story documentation and align variant names.

While the story exports are well-organized, consider these improvements:

  1. Add descriptions to each story export to explain its purpose and use case
  2. Ensure variant names in story exports match those in argTypes

Example enhancement for the Basic story:

 export const Basic = Template.bind({});
+Basic.parameters = {
+  docs: {
+    description: {
+      story: 'A simple dropdown component with basic functionality. Use this variant for standard single-select dropdowns.',
+    },
+  },
+};
 Basic.args = {
   ...commonArgs,
   type: "dropdown",
 };
react/ui-components/src/atoms/MobileSidebar.js (1)

Line range hint 348-354: Verify isSearchable prop documentation

The isSearchable prop has been added to propTypes, which formalizes the existing search functionality. Consider adding JSDoc comments to document this feature for better developer experience.

Add documentation above the propTypes:

/**
 * @property {boolean} isSearchable - When true, enables search functionality for items with children
 */
react/ui-components/src/atoms/stories/MultiselectDropdown.stories.js (4)

1-31: Consider simplifying the component setup.

The QueryClientProvider setup seems unnecessary for a presentational Storybook story since the dropdown component doesn't appear to make any queries. Consider removing it unless there's a specific requirement.

-import { QueryClient, QueryClientProvider } from "react-query";
-const queryClient = new QueryClient();

 const Template = (args) => (
-  <QueryClientProvider client={queryClient}>
     <FieldV1 {...args} />
-  </QueryClientProvider>
 );

42-180: Improve mock data organization and naming conventions.

  1. The mock data variable names are inconsistent:

    • gendersOptions (camelCase)
    • OptionsWithIcons (PascalCase)
    • NestedTextOptionWithIcons (PascalCase)
  2. The nested options have inconsistent naming patterns:

    • "Option A" vs "Option 1" vs "Option1"

Consider standardizing the naming conventions:

-const OptionsWithIcons = [
+const optionsWithIcons = [

-const NestedTextOptionWithIcons = [
+const nestedTextOptionsWithIcons = [

211-241: Refine common arguments configuration.

  1. The name property in populators is set to "genders" but used for generic options
  2. Boolean flags like addSelectAllCheck and addCategorySelectAllCheck could be more descriptive
  3. There are typos in some property names:
    • isSearchable:true (missing space after colon)
    • clearLabel:"Clear All" (missing space after colon)

Consider these improvements:

 populators: {
-  name: "genders",
+  name: "options",
   defaultValue: "FEMALE",
   optionsCustomStyle: {},
   optionsKey: "name",
   options: gendersOptions,
   showIcon: false,
-  isSearchable:true,
-  clearLabel:"Clear All",
+  isSearchable: true,
+  clearLabel: "Clear All",
-  addSelectAllCheck:false,
-  addCategorySelectAllCheck:false,
+  enableSelectAll: false,
+  enableCategorySelectAll: false,

1-404: Consider adding stories for edge cases.

The current stories cover the main use cases well, but consider adding stories for:

  1. Error states (invalid options, network errors)
  2. Loading states
  3. Empty states (no options)
  4. Maximum selection limit
  5. Custom option rendering

Would you like me to help generate additional stories for these edge cases?

react/ui-components/src/atoms/MultiSelectDropdown.js (3)

712-712: LGTM! Consider documenting the hideClose prop.

The addition of hideClose={false} maintains consistent behavior with other components. However, since this is a new property, it would be helpful to document it in the PropTypes.

Add the following to the PropTypes definition:

 MultiSelectDropdown.propTypes = {
   options: PropTypes.array.isRequired,
   optionsKey: PropTypes.string.isRequired,
   selected: PropTypes.array,
   onSelect: PropTypes.func.isRequired,
   defaultLabel: PropTypes.string,
   defaultUnit: PropTypes.string,
   BlockNumber: PropTypes.number,
   isOBPSMultiple: PropTypes.bool,
   props: PropTypes.object,
   isPropsNeeded: PropTypes.bool,
   ServerStyle: PropTypes.object,
   config: PropTypes.object,
+  // Document that this prop is passed to the Chip component
+  hideClose: PropTypes.bool,
 };

Line range hint 391-449: Consider refactoring keyboard navigation logic for better maintainability.

The keyChange function directly manipulates DOM elements and contains complex scrolling logic. Consider extracting this into a custom hook for better reusability and testability.

Here's a suggested approach:

// useKeyboardNavigation.js
const useKeyboardNavigation = (options, optionIndex, setOptionIndex) => {
  const handleKeyDown = (e, scrollRef) => {
    if (options.length === 0) return;

    switch(e.key) {
      case "ArrowDown":
        e.preventDefault();
        const nextIndex = optionIndex + 1 >= options.length ? 0 : optionIndex + 1;
        setOptionIndex(nextIndex);
        scrollRef.current?.children[nextIndex]?.scrollIntoView({ 
          behavior: 'smooth',
          block: 'nearest'
        });
        break;
      case "ArrowUp":
        e.preventDefault();
        const prevIndex = optionIndex === 0 ? options.length - 1 : optionIndex - 1;
        setOptionIndex(prevIndex);
        scrollRef.current?.children[prevIndex]?.scrollIntoView({ 
          behavior: 'smooth',
          block: 'nearest'
        });
        break;
    }
  };

  return handleKeyDown;
};

Line range hint 32-95: Consider memoizing complex calculations and callbacks.

The component re-renders frequently due to state changes. Memoizing callbacks and computed values would improve performance.

Consider these optimizations:

const memoizedFilteredOptions = useMemo(() => 
  searchQuery?.length > 0
    ? options?.filter(option => 
        t(option[optionsKey]?.toString().toUpperCase())
          .toLowerCase()
          .includes(searchQuery.toLowerCase())
      )
    : options,
  [searchQuery, options, optionsKey]
);

const handleSelect = useCallback((e, option) => {
  if (isPropsNeeded) {
    onSelectToAddToQueue(e, option, props);
  } else if (isOBPSMultiple) {
    onSelectToAddToQueue(e, option, BlockNumber);
  } else {
    onSelectToAddToQueue(e, option);
  }
}, [isPropsNeeded, isOBPSMultiple, BlockNumber, props]);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 039899a and cdeb4d1.

⛔ Files ignored due to path filters (6)
  • react/css/package.json is excluded by !**/*.json
  • react/example/package.json is excluded by !**/*.json
  • react/modules/core/package.json is excluded by !**/*.json
  • react/modules/sample/package.json is excluded by !**/*.json
  • react/package.json is excluded by !**/*.json
  • react/ui-components/package.json is excluded by !**/*.json
📒 Files selected for processing (24)
  • react/css/src/digitv2/index.scss (1 hunks)
  • react/example/public/index.html (1 hunks)
  • react/ui-components/.storybook/preview-head.html (1 hunks)
  • react/ui-components/public/index.html (1 hunks)
  • react/ui-components/src/atoms/BreadCrumb.js (2 hunks)
  • react/ui-components/src/atoms/MobileSidebar.js (1 hunks)
  • react/ui-components/src/atoms/MultiSelectDropdown.js (1 hunks)
  • react/ui-components/src/atoms/UploadFile.js (1 hunks)
  • react/ui-components/src/atoms/Uploader.js (1 hunks)
  • react/ui-components/src/atoms/stories/BodyTypography.stories.js (1 hunks)
  • react/ui-components/src/atoms/stories/ButtonTypography.stories.js (1 hunks)
  • react/ui-components/src/atoms/stories/CaptionTypography.stories.js (1 hunks)
  • react/ui-components/src/atoms/stories/Dropdown.stories.js (10 hunks)
  • react/ui-components/src/atoms/stories/Hamburger.stories.js (0 hunks)
  • react/ui-components/src/atoms/stories/HeadingTypography.stories.js (1 hunks)
  • react/ui-components/src/atoms/stories/LabelTypography.stories.js (1 hunks)
  • react/ui-components/src/atoms/stories/LinkTypography.stories.js (1 hunks)
  • react/ui-components/src/atoms/stories/MultiselectDropdown.stories.js (1 hunks)
  • react/ui-components/src/atoms/stories/Typography.stories.js (0 hunks)
  • react/ui-components/src/molecules/stories/DarkThemeHamburger.stories.js (1 hunks)
  • react/ui-components/src/molecules/stories/DarkThemeHeader.stories.js (1 hunks)
  • react/ui-components/src/molecules/stories/Footer.stories.js (1 hunks)
  • react/ui-components/src/molecules/stories/LightThemeHamburger.stories.js (1 hunks)
  • react/ui-components/src/molecules/stories/LightThemeHeader.stories.js (2 hunks)
💤 Files with no reviewable changes (2)
  • react/ui-components/src/atoms/stories/Hamburger.stories.js
  • react/ui-components/src/atoms/stories/Typography.stories.js
✅ Files skipped from review due to trivial changes (2)
  • react/ui-components/.storybook/preview-head.html
  • react/ui-components/public/index.html
🧰 Additional context used
🪛 Biome
react/ui-components/src/molecules/stories/DarkThemeHeader.stories.js

[error] 54-76: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 80-90: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 91-101: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 102-112: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 116-126: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 127-137: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 138-153: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 157-167: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 168-178: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


[error] 179-189: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (14)
react/example/public/index.html (1)

12-12: Verify CSS package version consistency across files.

The CSS package version has been updated to 0.0.2-beta.40. Let's verify this change is consistent across all related files.

✅ Verification successful

CSS package version is consistent across active imports

The version 0.0.2-beta.40 is consistently used in both active imports:

  • react/example/public/index.html
  • react/ui-components/public/index.html

There is one commented out reference to version 1.5.41 which doesn't affect the runtime behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any inconsistencies in the CSS package version across HTML files

# Test: Search for any references to the CSS package to ensure consistent versioning
rg --type html "@egovernments/digit-ui-components-css@" -A 1 -B 1

Length of output: 942

react/ui-components/src/atoms/stories/LinkTypography.stories.js (1)

30-30: Verify typography classes exist in CSS.

Let's ensure the typography classes used in the stories are properly defined in the CSS files.

Also applies to: 53-53, 76-76

✅ Verification successful

Typography classes are properly defined in the codebase

The typography classes (link-L, link-S, link-XS) used in the stories are correctly defined in:

  • Primary source: react/css/src/digitv2/typography.scss
  • Extended usage in button components: react/css/src/digitv2/components/buttonsV2.scss
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if typography classes are defined in CSS files
# Test: Search for link typography class definitions
rg -t css "\.link-(L|S|XS)" react/

Length of output: 1312

react/ui-components/src/atoms/stories/BodyTypography.stories.js (1)

30-30: Verify typography classes are properly defined.

The story uses typography-related classes (body-l, body-s, body-xs). Let's ensure these classes are properly defined in the CSS.

Also applies to: 62-62, 94-94

✅ Verification successful

Based on the search results, I can see that the typography classes are well-defined in the codebase. The search shows:

  1. The main typography definitions are in react/css/src/digitv2/typography.scss
  2. The classes body-l, body-s, and body-xs are extensively used across many components
  3. The typography classes follow a consistent pattern and are properly extended using SCSS's @extend .typography.body-* syntax

Typography classes are properly defined and consistently used.

The story is using the correct typography classes that are well-established in the codebase's design system. No issues found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for typography class definitions
echo "Searching for typography class definitions..."
rg -l "body-(l|s|xs)" --type css

# Check for any inconsistencies in class naming
echo "Checking for class naming consistency..."
rg "typography-?(story)?" --type css

Length of output: 57938

react/ui-components/src/atoms/stories/HeadingTypography.stories.js (1)

30-30: Verify className definitions in SCSS files.

Let's ensure both typography and typography-story classes are properly defined.

Also applies to: 76-76, 122-122

✅ Verification successful

Classes are properly defined and used correctly

The typography and heading-xl classes are properly defined in react/css/src/digitv2/typography.scss. The typography class serves as a base class with nested modifiers including heading-xl, which has appropriate responsive styles defined for different screen sizes. The implementation is consistent with the design system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for typography class definitions in SCSS files
echo "Searching for typography classes..."
rg -t scss "\.typography(-story)?\s*{" 

Length of output: 235


Script:

#!/bin/bash
# Search for typography class definitions in SCSS files with fixed regex
echo "Searching for typography classes..."
rg -t scss "\.typography"

# Also search for heading-xl class
echo -e "\nSearching for heading-xl class..."
rg -t scss "\.heading-xl"

# List all scss files to ensure we're not missing anything
echo -e "\nListing all SCSS files:"
fd -e scss

Length of output: 3342


Script:

#!/bin/bash
# Search for typography classes in the typography.scss file
echo "Checking typography.scss for class definitions..."
cat react/css/src/digitv2/typography.scss

# Search for any typography related classes in index.scss files
echo -e "\nChecking index.scss files..."
cat react/css/src/digitv2/index.scss
cat react/css/src/index.scss

Length of output: 42811

react/ui-components/src/atoms/UploadFile.js (2)

72-74: LGTM! The change maintains component consistency.

The addition of hideClose={false} aligns with similar updates in other components like Uploader and MultiSelectDropdown, ensuring consistent behavior across the UI components.


72-72: Verify if hideClose prop is necessary.

The explicit hideClose={false} might be redundant if this is already the default behavior of the Chip component.

Let's verify the Chip component's implementation:

✅ Verification successful

The explicit hideClose={false} prop is necessary

The Chip component has hideClose defaulting to true in its defaultProps, so explicitly setting it to false is required to show the close button. This is consistent with other components like Uploader and MultiSelectDropdown that also set hideClose={false} when they need the close functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if hideClose prop exists and its default value in Chip component

# Search for hideClose prop definition in Chip component
ast-grep --pattern 'PropTypes.{
  $$$
  hideClose: $_
  $$$
}'

# Search for defaultProps definition
ast-grep --pattern 'Chip.defaultProps = {
  $$$
  hideClose: $_
  $$$
}'

Length of output: 139


Script:

#!/bin/bash
# Let's try a different approach to find the Chip component and its props

# First, let's locate the Chip component file
fd -t f "Chip.js" -x cat {}

# Also search for any references to hideClose prop in the codebase
rg "hideClose" -B 2 -A 2

Length of output: 7114

react/ui-components/src/molecules/stories/DarkThemeHamburger.stories.js (2)

1-181: Overall structure looks good!

The story file is well-organized and effectively demonstrates various use cases of the MobileSidebar component. The use of common arguments and clear story variations makes it easy to understand and maintain.


33-97: Replace placeholder paths with meaningful routes.

All navigation paths are currently set to "/". Consider replacing these with actual routes that reflect the intended navigation structure.

react/ui-components/src/molecules/stories/LightThemeHeader.stories.js (2)

7-7: Appropriate reclassification from Atoms to Molecules.

The move from "Atoms/Header" to "Molecules/Header/Light" better reflects the component's complexity, as it composes multiple atomic components (TopBar, Dropdown, SVG) into a more complex molecule. This aligns well with atomic design principles.


358-358: LGTM: Added missing semicolon.

The addition of the semicolon improves code consistency.

react/ui-components/src/molecules/stories/DarkThemeHeader.stories.js (1)

1-51: LGTM! Well-structured Storybook configuration.

The story configuration follows best practices with appropriate controls for all props.

react/ui-components/src/atoms/stories/Dropdown.stories.js (1)

Line range hint 1-399: Verify the impact of dropdown story changes.

These story changes might affect:

  1. Documentation references to the old story names
  2. Other components that might be importing these stories
  3. Test files that might be using the old variant names
react/ui-components/src/atoms/MobileSidebar.js (1)

336-336: LGTM: Button size standardization

The addition of size="medium" to the Button component aligns with UI standardization efforts. This explicit size declaration improves consistency across the application.

react/ui-components/src/atoms/Uploader.js (1)

400-400: LGTM! UX improvement for file removal.

Making the close button always visible improves the discoverability of the file removal action.

@jagankumar-egov
Copy link
Collaborator

check other code rabbit comments

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

🧹 Outside diff range and nitpick comments (3)
react/ui-components/src/atoms/BreadCrumb.js (2)

Line range hint 114-123: Improve props configuration.

  1. The successful prop in defaultProps isn't used in the component.
  2. Consider adding default values for the new pagination props.
 BreadCrumb.propTypes = {
   crumbs: PropTypes.array,
   className: PropTypes.string,
   style: PropTypes.object,
   spanStyle: PropTypes.object,
   customSeparator: PropTypes.element,
   maxItems: PropTypes.number,
   itemsAfterCollapse: PropTypes.number,
   itemsBeforeCollapse: PropTypes.number,
   expandText: PropTypes.string
 };

 BreadCrumb.defaultProps = {
-  successful: true,
+  maxItems: null,
+  itemsAfterCollapse: Math.floor(maxItems / 2),
+  itemsBeforeCollapse: Math.ceil(maxItems / 2),
+  expandText: "..."
 };

Line range hint 1-124: Consider enhancing type safety for link properties.

To better align with the internal/external link distinction, consider adding proper type validation:

 BreadCrumb.propTypes = {
-  crumbs: PropTypes.array,
+  crumbs: PropTypes.arrayOf(
+    PropTypes.shape({
+      content: PropTypes.node.isRequired,
+      icon: PropTypes.node,
+      show: PropTypes.bool,
+      isBack: PropTypes.bool,
+      internalLink: PropTypes.string,
+      externalLink: PropTypes.string,
+      count: PropTypes.number
+    })
+  ),
   // ... rest of the props
 };
🧰 Tools
🪛 Biome

[error] 64-64: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

react/ui-components/CHANGELOG.md (1)

Line range hint 1-400: Improve changelog maintenance practices.

Several areas of the changelog could be improved:

  1. Fill in the missing dates (YYYY-MM-DD) for beta versions
  2. Use consistent categorization across entries (Breaking Changes, Features, Bug Fixes, etc.)
  3. Provide more detailed descriptions of changes, including the rationale and impact

Consider using a changelog maintenance tool like standard-version to automate versioning and changelog generation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cdeb4d1 and 0168473.

📒 Files selected for processing (2)
  • react/ui-components/CHANGELOG.md (1 hunks)
  • react/ui-components/src/atoms/BreadCrumb.js (6 hunks)
🧰 Additional context used
🪛 Biome
react/ui-components/src/atoms/BreadCrumb.js

[error] 64-64: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (2)
react/ui-components/src/atoms/BreadCrumb.js (2)

26-29: Previous security concerns about URL validation remain unaddressed.

The current implementation of handleRedirect still lacks proper URL validation and sanitization.


79-86: External navigation implementation needs revision.

The component still uses Router's Link for external navigation instead of anchor tags as suggested in the previous review.

react/ui-components/src/atoms/BreadCrumb.js Outdated Show resolved Hide resolved
react/ui-components/CHANGELOG.md Show resolved Hide resolved
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 (2)
react/ui-components/src/atoms/stories/BreadCrumb.stories.js (2)

Line range hint 1-206: Add story examples for externalLink usage.

The stories currently only demonstrate internalLink usage. Since the component now supports both internalLink and externalLink properties, it would be beneficial to add examples showing the externalLink functionality.

Consider adding a new story example:

export const WithExternalLinks = Template.bind({});
WithExternalLinks.args = {
  crumbs: [
    {
      content: "Home",
      show: true,
      internalLink: "/home",
    },
    {
      content: "Documentation",
      show: true,
      externalLink: "https://digit-ui.netlify.app/",
    },
    {
      content: "External Page",
      show: true,
      externalLink: "https://example.com",
    },
  ],
};

Line range hint 6-23: Enhance component documentation with property descriptions.

The argTypes configuration would benefit from descriptions of the new internalLink and externalLink properties to help other developers understand their usage.

Add property descriptions to the argTypes:

  argTypes: {
+   crumbs: {
+     description: 'Array of breadcrumb items. Each item can have either internalLink (for internal routing) or externalLink (for external URLs)',
+     control: { type: "object" },
+   },
    // ... other properties
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0168473 and 3e09ed9.

📒 Files selected for processing (1)
  • react/ui-components/src/atoms/stories/BreadCrumb.stories.js (6 hunks)
🔇 Additional comments (1)
react/ui-components/src/atoms/stories/BreadCrumb.stories.js (1)

49-49: Property name change from path to internalLink is consistently applied.

The migration from path to internalLink has been implemented consistently across all story examples. This aligns with the component's updated functionality.

Also applies to: 54-54, 59-59, 70-70, 75-75, 80-80, 85-85, 90-90, 102-102, 107-107, 112-112, 117-117, 122-122, 136-136, 141-141, 146-146, 151-151, 156-156, 167-167, 173-173, 179-179, 193-193, 198-198, 203-203

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 (2)
react/ui-components/src/atoms/BreadCrumb.js (2)

24-24: Consider adding null checks for optional props in dependency array.

The useEffect dependency array includes props?.expandText which uses optional chaining, but this could lead to unnecessary re-renders if the prop transitions between undefined and null.

Consider destructuring required props at the component start and providing default values:

 const BreadCrumb = (props) => {
+  const { 
+    crumbs,
+    maxItems,
+    itemsBeforeCollapse,
+    itemsAfterCollapse,
+    expandText = "..."
+  } = props;
   // ... rest of the code

Line range hint 110-124: Update component props configuration.

The component has several issues in its props configuration:

  1. The successful prop in defaultProps isn't used anywhere in the component
  2. Missing default values for new collapse-related props

Consider this update:

 BreadCrumb.propTypes = {
   crumbs: PropTypes.array.isRequired,
   className: PropTypes.string,
   style: PropTypes.object,
   spanStyle: PropTypes.object,
   customSeparator: PropTypes.element,
   maxItems: PropTypes.number,
   itemsAfterCollapse: PropTypes.number,
   itemsBeforeCollapse: PropTypes.number,
   expandText: PropTypes.string
 };

 BreadCrumb.defaultProps = {
-  successful: true,
+  maxItems: null,
+  itemsAfterCollapse: 1,
+  itemsBeforeCollapse: 1,
+  expandText: "..."
 };
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3e09ed9 and 555e20f.

📒 Files selected for processing (1)
  • react/ui-components/src/atoms/BreadCrumb.js (6 hunks)
🧰 Additional context used
🪛 Biome
react/ui-components/src/atoms/BreadCrumb.js

[error] 65-65: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

react/ui-components/src/atoms/BreadCrumb.js Show resolved Hide resolved
react/ui-components/src/atoms/BreadCrumb.js Show resolved Hide resolved
react/ui-components/src/atoms/BreadCrumb.js Show resolved Hide resolved
@jagankumar-egov jagankumar-egov merged commit 7e4473b into develop Oct 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants