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

Illiar/feat/kyb theme customization #2744

Merged
merged 15 commits into from
Oct 2, 2024

Conversation

chesterkmr
Copy link
Collaborator

@chesterkmr chesterkmr commented Oct 1, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new PoweredByLogo component that dynamically adjusts the logo based on the sidebar's background color.
    • Added a custom hook useTheme for easier access to theme settings.
    • Enhanced StepperUI component with improved breadcrumb management and rendering logic.
  • Bug Fixes

    • Corrected the property name from pallete to palette in the ITheme interface.
  • Documentation

    • Updated types and interfaces to include new properties for better customization of components.
  • Style

    • Improved styling logic for Breadcrumbs components, allowing for inline styles and dynamic styling based on component state.

@chesterkmr chesterkmr requested a review from alonp99 October 1, 2024 14:41
Copy link

changeset-bot bot commented Oct 1, 2024

⚠️ No Changeset found

Latest commit: a73e7a5

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
Contributor

coderabbitai bot commented Oct 1, 2024

Walkthrough

The pull request includes updates across several files, primarily focusing on dependency management, HTML structure, theme handling, and component functionality. The package.json version for @ballerine/backoffice-v2 has been incremented, and the lucide-react dependency has been locked to a specific version. The index.html file has been modified to replace the favicon with new icons. A custom hook useTheme has been introduced for theme management, and several components have been updated to enhance their functionality and styling capabilities.

Changes

File Change Summary
apps/backoffice-v2/package.json Version updated to 0.7.51; lucide-react dependency changed from caret version ^0.445.0 to fixed version 0.445.0.
apps/kyb-app/index.html Removed SVG favicon; added Apple touch icon and two PNG favicons (32x32 and 16x16).
apps/kyb-app/src/common/providers/ThemeProvider/useTheme.ts Introduced useTheme hook for accessing themeContext.
apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Wrapper.tsx Updated Wrapper component to include a style prop for inline styling.
`apps/kyb-app/src/components/layouts/AppShell/Navigation.tsx Modified onPrevious function to be asynchronous; updated button rendering logic.
apps/kyb-app/src/components/molecules/PoweredByLogo/PoweredByLogo.tsx Introduced PoweredByLogo component with dynamic logo source based on sidebar color.
apps/kyb-app/src/components/molecules/PoweredByLogo/helpers.ts Added utility functions for color manipulation: getLuminance, getRGBColorFromElement, and isColorDark.
apps/kyb-app/src/components/organisms/UIRenderer/elements/StepperUI/StepperUI.tsx Updated computeStepStatus function to accept a new context parameter; reintroduced hooks and optimized rendering logic.
apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/useUIElementProps.ts Updated useUIElementProps to include an optional index parameter for enhanced functionality.
apps/kyb-app/src/main.tsx Removed SettingsProvider and associated settings; added error handling for initialization functions.

Possibly related PRs

  • fix: fixed lucide icons version #2745: The changes in this PR involve updating the lucide-react dependency version in the package.json file, which directly relates to the version lock change from a caret version to a fixed version in the main PR.

Suggested reviewers

  • Omri-Levy
  • alonp99

Poem

In the garden of code, changes sprout,
With themes and icons, there's no doubt.
A rabbit hops, with joy in sight,
New hooks and styles, all feel just right!
With every tweak, we dance and play,
In this code world, we find our way! 🐇✨


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
Contributor

@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: 23

🧹 Outside diff range and nitpick comments (34)
services/workflows-service/prisma/migrations/20241001141655_add_theme_to_ui_definition/migration.sql (1)

1-2: LGTM! Consider data migration and indexing.

The addition of the "theme" column of type JSONB to the "UiDefinition" table is appropriate for storing flexible theme data. This aligns well with the PR objectives for theme customization.

Consider the following points:

  1. Existing rows will have NULL values for the new "theme" column. Determine if a data migration is needed to populate these with default themes.
  2. Depending on your query patterns, you might want to add an index on the "theme" column or specific JSON paths within it for performance optimization.
  3. If themes should always be present, consider adding a NOT NULL constraint and a DEFAULT value.

Example for adding a GIN index (if needed):

CREATE INDEX idx_ui_definition_theme ON "UiDefinition" USING GIN ("theme");
apps/kyb-app/src/common/providers/ThemeProvider/theme.context.ts (1)

4-4: Consider using a default value that matches IThemeContext.

The context is created with an empty object and type assertion. While this works, it might be safer to provide a default value that matches the IThemeContext interface structure.

Consider refactoring to:

export const themeContext = createContext<IThemeContext>({
  // Add properties that match IThemeContext
  // For example:
  // currentTheme: null,
  // setCurrentTheme: () => {},
  // ... other properties
});

This approach ensures type safety and provides meaningful default values, reducing the risk of runtime errors if the context is accessed before being properly initialized by a provider.

apps/kyb-app/src/components/layouts/AppShell/Sidebar.tsx (1)

9-12: LGTM with a minor suggestion.

The changes enhance the styling consistency and provide a unique identifier for the sidebar. However, consider the following suggestion:

Instead of using an id attribute, consider using a data attribute for better maintainability and to avoid potential conflicts. For example:

 <div
   className="bg-primary text-primary-foreground col-span-2 flex h-screen w-[24%] max-w-[418px] flex-col px-14 pb-4 pt-14"
-  id="sidebar"
+  data-testid="sidebar"
 >

This approach is more aligned with best practices in modern web development, especially if the ID is intended for testing or component identification rather than styling.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Outer.tsx (1)

7-11: LGTM! Consider destructuring props to avoid naming conflicts.

The addition of the style prop enhances the component's flexibility by allowing inline styling. This change is consistent with the component's purpose and doesn't introduce any apparent issues.

To avoid potential naming conflicts between the component's props and the hook's props, consider destructuring the props from useBreadcrumbElementLogic. This will make it clearer which props are coming from where:

-export const Outer = ({ className, children }: BreadcrumbsOuterProps) => {
-  const { props } = useBreadcrumbElementLogic<BreadcrumbsOuterProps>('outer');
+export const Outer = ({ className, children, style, ...rest }: BreadcrumbsOuterProps) => {
+  const { props: hookProps } = useBreadcrumbElementLogic<BreadcrumbsOuterProps>('outer');

   return (
-    <div className={className || props.className} style={props.style}>
+    <div className={className || hookProps.className} style={style || hookProps.style} {...rest}>
       {children}
     </div>
   );
 };

This change ensures that explicitly passed props take precedence over those from the hook, and allows for additional props to be passed through.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/Breadcrumbs.Label.tsx (3)

7-7: LGTM: Effective use of useMemo for performance optimization

The use of useMemo to memoize the result of pickLabelProps is a good performance optimization. It ensures that label properties are only recalculated when active or state changes.

Consider adding a comment explaining the purpose of this memoization, especially if pickLabelProps is a computationally expensive operation. This would help other developers understand the reasoning behind this optimization.


14-14: LGTM: Flexible prop spreading, but consider adding documentation

Spreading labelProps onto the <span> element allows for dynamic property assignment based on the state and active status, which is a flexible approach.

To improve code clarity and maintainability, consider adding a comment or documentation that outlines the possible properties that labelProps might contain. This would help other developers understand what additional properties might be applied to the span element without having to dive into the pickLabelProps function.


Line range hint 1-20: Overall assessment: Good improvements with some areas for clarification

The changes to this component introduce valuable performance optimizations through the use of useMemo and improve flexibility with dynamic prop assignment. These are positive improvements that align well with React best practices.

However, there are a few areas that could benefit from additional attention:

  1. The removal of the opacity-50 class for completed states needs verification to ensure it aligns with the intended design.
  2. Additional documentation for the labelProps spreading would improve code clarity.
  3. A comment explaining the purpose of the useMemo optimization could be helpful for future maintainers.

Addressing these points will further enhance the quality and maintainability of this component.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-wrapper.props.ts (1)

Line range hint 5-17: Consider adding documentation and default values.

While the function is well-structured and the new change is good, consider these minor improvements:

  1. Add a brief JSDoc comment to describe the function's purpose and parameters.
  2. Consider providing default values for themeParams.activeStyles and themeParams.styles to enhance robustness.

Example:

/**
 * Picks props for a breadcrumb wrapper based on its state and active status.
 * @param state - The current state of the breadcrumb
 * @param active - Whether the breadcrumb is active
 * @param theme - The theme object containing styling information
 * @returns The props object for the breadcrumb wrapper
 */
export const pickWrapperProps: ElementPropsPicker<BreadcrumbsWrapperProps> = (
  state,
  active,
  theme,
) => {
  const themeParams = theme[state].wrapper;

  const props: BreadcrumbsWrapperProps = {
    className: ctw(themeParams.className, { [themeParams.activeClassName || '']: active }),
    style: active ? (themeParams.activeStyles ?? {}) : (themeParams.styles ?? {}),
  };

  return props;
};

These changes would improve the function's documentation and make it more resilient to potential undefined theme properties.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-outer-props.ts (1)

Line range hint 8-16: Consider destructuring themeParams for improved readability

While the current implementation is correct, you could slightly improve readability by destructuring themeParams. Here's a suggested refactor:

 export const pickOuterProps: ElementPropsPicker<BreadcrumbsOuterProps> = (
   state,
   active,
   theme,
 ): BreadcrumbsOuterProps => {
-  const themeParams = theme[state].outer;
+  const { className, activeClassName, activeStyles, styles } = theme[state].outer;

   const props: BreadcrumbsOuterProps = {
-    className: ctw(themeParams.className, { [themeParams.activeClassName || '']: active }),
-    style: active ? themeParams.activeStyles : themeParams.styles,
+    className: ctw(className, { [activeClassName || '']: active }),
+    style: active ? activeStyles : styles,
   };

   return props;
 };

This change would make the code slightly more readable and reduce repetition of themeParams.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Inner.tsx (1)

9-9: LGTM! Consider documenting style precedence.

The addition of the style prop enhances the component's flexibility by allowing custom styles to be applied dynamically. This change is consistent with how the className prop is handled and doesn't introduce unnecessary complexity.

Consider adding a comment or updating the component's documentation to clarify the precedence of styles when both className and style are used, especially if they set conflicting properties. This will help prevent potential confusion for other developers using this component.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-inner-props.ts (1)

Line range hint 1-15: Consider enhancing robustness and type safety

The overall structure and logic of the pickInnerProps function look good. However, there are a few suggestions to enhance its robustness and type safety:

  1. Consider adding null checks or default values for themeParams properties to handle cases where the theme object might not have all expected properties.

  2. It might be beneficial to add more specific types for the state and theme parameters to ensure they always have the expected structure.

  3. If not already done elsewhere, consider adding unit tests for this function to ensure it behaves correctly with various inputs, including edge cases.

Here's an example of how you could add some null checks:

export const pickInnerProps: ElementPropsPicker<BreadcrumbsInnerProps> = (state, active, theme) => {
  const themeParams = theme[state]?.inner ?? {};

  const props: BreadcrumbsInnerProps = {
    className: ctw(themeParams.className ?? '', { [themeParams.activeClassName ?? '']: active }),
    icon: active ? (themeParams.activeIcon ?? themeParams.icon) : themeParams.icon,
    style: active ? (themeParams.activeStyles ?? {}) : (themeParams.styles ?? {}),
  };

  return props;
};

This version uses the nullish coalescing operator (??) to provide default values when properties are undefined, making the function more resilient to incomplete theme objects.

apps/kyb-app/src/components/molecules/PoweredByLogo/helpers.ts (1)

1-28: Overall assessment of color utility functions

The helpers.ts file provides a set of useful color manipulation functions that are likely used in the PoweredByLogo component. The implementation of these functions is generally sound, but there are opportunities for improvement:

  1. Enhance type safety by avoiding non-null assertions.
  2. Improve error handling, especially in the getRGBColorFromElement function.
  3. Add comprehensive comments to explain the purpose, limitations, and usage of each function.
  4. Consider making certain parameters (like the luminance threshold in isColorDark) configurable for greater flexibility.

These improvements will make the utility functions more robust, easier to understand, and more maintainable in the long run.

Consider creating a separate colorUtils.ts file in a shared utility folder if these color manipulation functions might be useful in other parts of the application beyond the PoweredByLogo component. This would promote code reuse and maintain a clear separation of concerns.

apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/helpers.ts (2)

4-6: Consider removing redundant type check.

The early return conditions are good for handling edge cases. However, the check if (!Array.isArray(rules)) might be redundant if TypeScript's type system ensures rules is always an array. If this check is necessary due to runtime considerations, consider adding a comment explaining why.


30-32: LGTM: Good functional structure. Consider minor clarity improvement.

The overall structure of the function is well-implemented, following functional programming principles. It's pure and should be easy to test.

For slightly improved readability, you could consider using an implicit return in the arrow function:

export const injectIndexesAtRulesPaths = (rules: Rule[], index: number | null = null) => {
  if (index === null) return rules;

  return rules.map(rule => 
    rule.type === 'json-logic'
      ? { ...rule, value: processJsonLogicRule(rule.value, index) }
      : rule
  );
};

// Helper function to process 'json-logic' rules
const processJsonLogicRule = (value: any, index: number) => {
  const stringValue = JSON.stringify(value);
  return JSON.parse(stringValue.replace(/\[({INDEX})\]/g, (match, p1, offset, string) => {
    // ... (rest of the replacement logic)
  }));
};

This structure separates concerns and makes the main function more concise.

apps/kyb-app/src/common/components/molecules/ProgressBar/ProgressBar.tsx (1)

Line range hint 10-41: LGTM! Consider extracting className for improved readability.

The changes to the component look good. The use of ctw for class composition and the addition of styles.bounceAnimation enhance the component's styling capabilities.

For improved readability, consider extracting the className prop into a separate variable:

+ const iconClassName = ctw(
+   'flex h-3 w-3 items-center justify-center rounded-full bg-[#00BD59]',
+   styles.bounceAnimation,
+ );

  return (
    <Chip
      icon={
        isLoading ? (
          <LoadingSpinner size="14" />
        ) : (
          <div
-           className={ctw(
-             'flex h-3 w-3 items-center justify-center rounded-full bg-[#00BD59]',
-             styles.bounceAnimation,
-           )}
+           className={iconClassName}
          >
            <Check size="8" color="#fff" />
          </div>
        )
      }
      className={className}
      variant={isLoading ? 'primary' : 'success'}
      text={isLoading ? t('saving') : t('progressSaved')}
    />
  );
apps/kyb-app/src/components/molecules/PoweredByLogo/PoweredByLogo.tsx (1)

4-7: Consider updating the interface naming convention.

The interface IPoweredByLogoProps follows an older naming convention. In modern TypeScript, it's more common to omit the I prefix for interfaces.

Consider renaming the interface to PoweredByLogoProps:

-interface IPoweredByLogoProps {
+interface PoweredByLogoProps {
   className?: string;
   sidebarRootId: string;
 }
apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-label-props.ts (2)

4-5: Consider adding an explicit return type for clarity.

The function signature is well-defined, but adding an explicit return type could improve readability and maintainability.

Consider updating the function signature as follows:

export const pickLabelProps = (
  state: BreadcrumbState,
  active: boolean
): { style: CSSProperties } => {
  // ...
}

6-36: LGTM: Well-structured props map with consistent use of CSS variables.

The propsMap is well-defined with a consistent structure across all states. The use of CSS variables for theming is a good practice, allowing for easy customization.

Consider extracting the common structure into a helper function to reduce repetition:

const createStateStyle = (state: BreadcrumbState, active: boolean) => ({
  style: {
    color: active
      ? `var(--stepper-breadcrumbs-${state}-label-text-color)`
      : `var(--stepper-breadcrumbs-${state}-label-text-active-color)`,
    opacity: active
      ? `var(--stepper-breadcrumbs-${state}-label-text-opacity)`
      : `var(--stepper-breadcrumbs-${state}-label-text-active-opacity)`,
  },
});

const propsMap: Record<BreadcrumbState, { style: CSSProperties }> = {
  idle: createStateStyle('idle', active),
  warning: createStateStyle('warning', active),
  completed: createStateStyle('completed', active),
};

This refactoring would make the code more DRY and easier to maintain.

apps/kyb-app/src/components/layouts/AppShell/Navigation.tsx (1)

39-41: Minor formatting improvement

The removal of the space before the comma in the ctw function call is a small but welcome improvement in code formatting.

apps/kyb-app/tailwind.config.cjs (1)

26-51: Summary of Tailwind configuration changes

The updates to the Tailwind configuration file improve the flexibility and consistency of color definitions throughout the application. The change from hsl(var(--color)) to var(--color) format allows for more direct use of CSS variables, which can enhance theme customization capabilities.

The addition of the new 'controls' color category suggests an expansion of the theming system to include specific styling for control elements. However, it would be beneficial to have documentation or comments explaining the intended use of this new category to maintain clarity for other developers working on the project.

Overall, these changes appear to be a positive step towards a more flexible and maintainable theming system.

Consider adding a comment in the configuration file explaining the purpose and intended use of the new 'controls' color category.

apps/kyb-app/src/components/layouts/AppShell/LanguagePicker.tsx (1)

44-51: Approved: Improved styling for DropdownInput trigger.

The changes to the trigger property enhance the visual consistency of the component:

  1. Wrapping the GlobeIcon in a span with text-primary-foreground class allows for more specific icon styling.
  2. Updating the className to use bg-primary and text-primary-foreground aligns the component with the application's color scheme.

Consider adding an aria-label to the trigger for improved accessibility:

 trigger: {
   icon: (
-    <span className="text-primary-foreground">
+    <span className="text-primary-foreground" aria-label="Select language">
       <GlobeIcon />
     </span>
   ),
   className: 'px-3 gap-x-2 bg-primary text-primary-foreground',
 },
apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/theme/base-theme.tsx (1)

41-46: Consistent improvements in the 'warning' state

The changes to the 'warning' state are consistent with those made in the 'idle' state, which is good for maintaining a uniform approach across the theme.

However, I noticed that the 'wrapper' property in the 'warning' state hasn't been updated to use CSS variables. For consistency, you might want to consider applying similar changes to the 'wrapper' property as well.

Consider updating the 'wrapper' property in the 'warning' state to use CSS variables, similar to the 'idle' state. This would provide consistent customization capabilities across all properties and states.

apps/kyb-app/src/domains/collection-flow/types/index.ts (1)

152-152: LGTM: Addition of theme property to UISchema

The addition of the theme property to the UISchema interface is well-implemented and aligns with the PR objectives for theme customization.

For consistency with other properties in the uiSchema object, consider adding a brief comment explaining the purpose of the theme property. For example:

uiSchema: {
  elements: UIPage[];
  // Theme configuration for UI customization
  theme: ITheme;
};
websites/docs/src/content/docs/en/collection-flow/theming.mdx (2)

Line range hint 64-86: Approved with suggestion: Consider consistent color format

The JSON structure is valid and the inclusion of a "muted" color adds flexibility to the theme. However, there's an inconsistency in the color value formats. Some use HSL with commas and percentages, while others use space-separated values.

Consider using a consistent format for all color values. For example:

"muted": {
    "color": "210, 40%, 96.1%",
    "foreground": "215.4, 16.3%, 46.9%"
},

Line range hint 89-104: Approved with minor suggestion: Consider removing trailing comma

The JSON structure is valid and consistent with the described Green theme. The use of HSL color format is consistent with the Default theme, which is good for maintaining uniformity.

Consider removing the trailing comma after the last property in the "palette" object:

 "accent": {
-  "color": "93, 100%, 89%",
+  "color": "93, 100%, 89%"
 }

While not a syntax error in JSON, removing trailing commas can improve consistency across different JSON parsers and reduce the likelihood of errors in stricter parsing contexts.

apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/hocs/withDynamicUIInput/withDynamicUIInput.tsx (1)

29-29: Approved: Exporting getInputIndex enhances reusability.

The decision to export the getInputIndex function improves code reusability. This change allows other parts of the codebase to utilize this functionality if needed.

Consider adding a brief JSDoc comment to describe the function's purpose and parameters. This will enhance code documentation, especially now that it's exported:

/**
 * Extracts the input index from the given input ID.
 * @param {string} inputId - The ID of the input element.
 * @returns {number|null} The extracted index or null if not found.
 */
export const getInputIndex = (inputId: string) => findLastDigit(inputId);
services/workflows-service/src/collection-flow/collection-flow.service.ts (1)

116-119: LGTM: Enhanced return object with theme and correct definition reference.

The changes improve the completeness and correctness of the returned object:

  1. Addition of the theme property to the uiSchema object.
  2. Correct referencing of uiDefinition.definition for the definition property.

These updates align with the expected changes and enhance the functionality of the getFlowConfiguration method.

Consider adding a type assertion for uiDefinition.theme to ensure type safety:

theme: uiDefinition.theme as Record<string, unknown>,

This will help prevent potential type-related issues in the future.

apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx (1)

195-195: LGTM: Improved logo source prioritization.

The change to prioritize themeDefinition.logo over customer?.logoImageUri enhances theme customization capabilities. This aligns well with the PR objectives.

Consider using the nullish coalescing operator (??) for a more concise expression:

logoSrc={themeDefinition.logo ?? customer?.logoImageUri}

This would prevent using an empty string from themeDefinition.logo if that's not desired.

apps/kyb-app/src/utils/transform-theme-to-inline-styles.ts (1)

18-20: Simplify path construction for readability

The path construction in the recursive calls can be simplified for better readability. Consider extracting the path prefix into a variable.

Apply this diff to simplify the path construction:

 Object.entries(elements).forEach(([variableKey, value]) => {
+    const currentPath = path ? `${path}-${variableKey}` : variableKey;
     if (typeof value === 'string') {
-        styles += createInlineVariable(`${path ? `${path}-` : ''}${variableKey}`, value);
+        styles += createInlineVariable(currentPath, value);
     } else {
-        buildInlineVariableForElements(value, `${path ? `${path}-` : ''}${variableKey}`);
+        buildInlineVariableForElements(value, currentPath);
     }
 });
apps/kyb-app/src/common/providers/ThemeProvider/ThemeProvider.tsx (1)

28-28: Nested Optional Chaining on uiSchema

The condition if (!uiSchema?.uiSchema?.theme) could be simplified for better readability.

Consider destructuring uiSchema or flattening the data structure if possible.

apps/kyb-app/src/components/organisms/UIRenderer/elements/StepperUI/StepperUI.tsx (1)

Line range hint 22-32: Remove unused parameter 'currentPage' from 'computeStepStatus'

In the computeStepStatus function, the parameter currentPage is declared in the type definition but is neither destructured nor used within the function. This may cause confusion and potentially lead to misunderstandings about the function's dependencies. Consider removing it if it's unnecessary.

Apply this diff to remove the unused parameter:

 const computeStepStatus = ({
   pageError,
   page,
   context,
   uiElementState,
 }: {
   page: UIPage;
   uiElementState: UIElementState;
   pageError: Record<string, ErrorField>;
-  currentPage: UIPage;
   context: CollectionFlowContext;
 }) => {
services/workflows-service/prisma/schema.prisma (1)

434-434: Fix typographical errors in the comments for clarity

There are several typos in the comments within the UiDefinition model that should be addressed for better readability.

  • In the comment for uiSchema, 'schmea' should be 'schema'.
  • In the comment for schemaOptions, 'documenTypes' should be 'documentTypes', and 'documenCateogries' should be 'documentCategories'.
  • In the comment for uiOptions, consider capitalizing the first letter for consistency.

Here are the corrected comments:

definition    Json? // Frontend UI xstate definition
uiSchema      Json  // JSON schema of how to render UI
theme         Json? // Theme for the UI
schemaOptions Json? // Document Schemas, rejectionReasons: {}, documentTypes: {}, documentCategories: {}
uiOptions     Json? // How the view will look overall
locales       Json? // Locales for the UI
apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/SubmitButton.tsx (2)

Line range hint 59-62: Avoid suppressing TypeScript errors with @ts-ignore

Using // @ts-ignore suppresses TypeScript errors, potentially hiding real issues. It's better to resolve the underlying type incompatibility.

Consider updating the type definitions or adding a null check to handle possible undefined values. Here's a suggested change:

- setPageElementsTouched(
-   // @ts-ignore
-   currentPage,
-   state,
- );
+ if (currentPage) {
+   setPageElementsTouched(
+     currentPage,
+     state,
+   );
+ }

This ensures currentPage is not undefined before calling setPageElementsTouched.


Line range hint 69-72: Avoid mutating the context object directly

Directly mutating the context object using set from Lodash may lead to unexpected behavior since React might not detect the changes for re-rendering.

Instead of mutating context directly, consider using a state updater function or context provider method. For example:

// Assuming there's a setter function available from the context
updateContext(prevContext => ({
  ...prevContext,
  flowConfig: {
    ...prevContext.flowConfig,
    stepsProgress: {
      ...prevContext.flowConfig.stepsProgress,
      [currentPage?.stateName]: {
        isCompleted: true,
      },
    },
  },
}));

This approach follows React's state management practices and ensures proper re-rendering.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cb1d027 and 7a98b7c.

⛔ Files ignored due to path filters (1)
  • apps/kyb-app/public/poweredby-white.svg is excluded by !**/*.svg
📒 Files selected for processing (46)
  • apps/kyb-app/src/__tests/providers/TestProvider/TestProvider.tsx (1 hunks)
  • apps/kyb-app/src/common/components/molecules/ProgressBar/ProgressBar.tsx (1 hunks)
  • apps/kyb-app/src/common/providers/ThemeProvider/ThemeProvider.tsx (1 hunks)
  • apps/kyb-app/src/common/providers/ThemeProvider/index.ts (1 hunks)
  • apps/kyb-app/src/common/providers/ThemeProvider/theme.context.ts (1 hunks)
  • apps/kyb-app/src/common/providers/ThemeProvider/types.ts (1 hunks)
  • apps/kyb-app/src/common/providers/ThemeProvider/useTheme.ts (1 hunks)
  • apps/kyb-app/src/common/types/settings.ts (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/Breadcrumbs.Label.tsx (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Inner.tsx (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Outer.tsx (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Wrapper.tsx (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-inner-props.ts (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-label-props.ts (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-outer-props.ts (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-wrapper.props.ts (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/theme/base-theme.tsx (3 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/theme/common.ts (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/types.ts (2 hunks)
  • apps/kyb-app/src/components/layouts/AppShell/Content.tsx (1 hunks)
  • apps/kyb-app/src/components/layouts/AppShell/FormContainer.tsx (1 hunks)
  • apps/kyb-app/src/components/layouts/AppShell/LanguagePicker.tsx (2 hunks)
  • apps/kyb-app/src/components/layouts/AppShell/Navigation.tsx (1 hunks)
  • apps/kyb-app/src/components/layouts/AppShell/Sidebar.tsx (1 hunks)
  • apps/kyb-app/src/components/molecules/PoweredByLogo/PoweredByLogo.tsx (1 hunks)
  • apps/kyb-app/src/components/molecules/PoweredByLogo/helpers.ts (1 hunks)
  • apps/kyb-app/src/components/molecules/PoweredByLogo/index.ts (1 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/FieldTemplate/FieldTemplate.tsx (3 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/FileUploaderField/FileUploaderField.tsx (2 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/helpers/findDefinitionByName.ts (7 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/hocs/withDynamicUIInput/withDynamicUIInput.tsx (1 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/StepperUI/StepperUI.tsx (3 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/SubmitButton.tsx (2 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/helpers.ts (1 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/useUIElementProps.ts (1 hunks)
  • apps/kyb-app/src/domains/collection-flow/types/index.ts (2 hunks)
  • apps/kyb-app/src/main.tsx (2 hunks)
  • apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx (4 hunks)
  • apps/kyb-app/src/utils/transform-theme-to-inline-styles.ts (1 hunks)
  • apps/kyb-app/tailwind.config.cjs (1 hunks)
  • apps/kyb-app/theme.json (1 hunks)
  • services/workflows-service/prisma/data-migrations (1 hunks)
  • services/workflows-service/prisma/migrations/20241001141655_add_theme_to_ui_definition/migration.sql (1 hunks)
  • services/workflows-service/prisma/schema.prisma (2 hunks)
  • services/workflows-service/src/collection-flow/collection-flow.service.ts (1 hunks)
  • websites/docs/src/content/docs/en/collection-flow/theming.mdx (3 hunks)
✅ Files skipped from review due to trivial changes (2)
  • apps/kyb-app/src/components/layouts/AppShell/FormContainer.tsx
  • services/workflows-service/prisma/data-migrations
🧰 Additional context used
🪛 Biome
apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/FieldTemplate/FieldTemplate.tsx

[error] 26-26: isNaN is unsafe. It attempts a type coercion. Use Number.isNaN instead.

See the MDN documentation for more details.
Unsafe fix: Use Number.isNaN instead.

(lint/suspicious/noGlobalIsNan)

🔇 Additional comments (91)
apps/kyb-app/src/components/molecules/PoweredByLogo/index.ts (1)

1-1: LGTM! This change improves module organization and import cleanliness.

The addition of this index file with the export statement is a good practice. It offers several benefits:

  1. It simplifies imports for other modules using the PoweredByLogo component.
  2. It enhances code organization by centralizing exports.
  3. It provides better encapsulation of the component's internal structure.
  4. It aligns with common React project structures, promoting consistency across the codebase.

This change will make it easier for developers to use the PoweredByLogo component throughout the application.

apps/kyb-app/src/common/providers/ThemeProvider/index.ts (1)

1-2: LGTM! Improved module interface.

The addition of the useTheme export enhances the ThemeProvider module's interface. This change allows consumers to import both ThemeProvider and useTheme directly from the same module, which improves code organization and usability.

apps/kyb-app/src/common/providers/ThemeProvider/types.ts (2)

3-5: Great improvement in type definition!

The introduction of the IThemeContext interface is a positive change:

  1. It provides a more structured and explicit definition for the theme context.
  2. The use of an interface allows for easy future expansion if additional properties are needed.
  3. The property name themeDefinition is clear and self-explanatory.

This change enhances type safety and improves code readability.


1-1: LGTM! Verify the usage of ITheme.

The import statement has been updated to import ITheme instead of ISettings, which aligns with the PR's focus on theme customization. This change provides a more specific and relevant import for the file's purpose.

To ensure the imported ITheme is used correctly throughout the file, run the following command:

✅ Verification successful

Verified: ITheme is correctly imported and utilized in IThemeContext.

The usage of ITheme has been confirmed in apps/kyb-app/src/common/providers/ThemeProvider/types.ts, ensuring that the import statement and its application align with the PR's theme customization objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of ITheme in the current file

# Test: Check if ITheme is used in the file
rg --type typescript 'ITheme' apps/kyb-app/src/common/providers/ThemeProvider/types.ts

Length of output: 121


Script:

#!/bin/bash
# Description: Verify the usage of ITheme in the current file by searching directly without specifying file type.

# Test: Check if ITheme is used in the file
rg 'ITheme' apps/kyb-app/src/common/providers/ThemeProvider/types.ts

Length of output: 178

apps/kyb-app/src/common/providers/ThemeProvider/useTheme.ts (1)

1-4: LGTM! Clean and concise implementation of the useTheme hook.

The custom hook is well-implemented, following React best practices for context usage. It provides a clean abstraction for accessing the theme context throughout the application.

apps/kyb-app/src/common/providers/ThemeProvider/theme.context.ts (1)

1-2: LGTM: Imports look good.

The import statements are clear and concise. Importing IThemeContext from a local path and createContext from 'react' is appropriate for creating a typed React context.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/theme/common.ts (1)

3-3: Verify the intended border visibility.

The removal of 'border-transparent' from outerCommonClassName will make the 2px border visible. This change appears intentional, but please confirm that this aligns with the desired design across all use cases of this component.

To ensure this change doesn't unintentionally affect other components, please run the following script:

✅ Verification successful

[/run_scripts]


Border visibility change verified successfully.

The removal of 'border-transparent' from outerCommonClassName has been confirmed across relevant components, ensuring the 2px border is now consistently visible as intended.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for other usages of outerCommonClassName to ensure the change is appropriate

# Search for files using outerCommonClassName
echo "Files using outerCommonClassName:"
rg --type typescript --type tsx "outerCommonClassName" apps/kyb-app/src

# Search for any hardcoded 'border-transparent' classes that might be related
echo "\nFiles with hardcoded 'border-transparent' classes in the Breadcrumbs component:"
rg --type typescript --type tsx "border-transparent" apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs

Length of output: 521


Script:

#!/bin/bash
# Description: Check for other usages of outerCommonClassName to ensure the change is appropriate

# Search for files using outerCommonClassName
echo "Files using outerCommonClassName:"
rg "outerCommonClassName" --glob '*.ts' --glob '*.tsx' apps/kyb-app/src

# Search for any hardcoded 'border-transparent' classes that might be related
echo "\nFiles with hardcoded 'border-transparent' classes in the Breadcrumbs component:"
rg "border-transparent" --glob '*.ts' --glob '*.tsx' apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs

Length of output: 1120

apps/kyb-app/src/common/types/settings.ts (4)

4-4: Approved: Enhanced flexibility for elements property in ITheme

The type update for the elements property from Record<string, string> to Record<string, string | Record<string, string>> provides more flexibility in defining theme elements. This allows for both simple string values and nested records of string key-value pairs.

To ensure this change is properly handled throughout the codebase, let's verify the usage and type checking:

#!/bin/bash
# Description: Check usage of ITheme.elements and verify type checking

# Search for usage of ITheme.elements
echo "Usage of ITheme.elements:"
rg --type typescript "theme.*elements" -g '!**/settings.ts'

# Search for type checking or handling of elements property
echo "Type checking or handling of elements property:"
rg --type typescript "(typeof.*elements|elements\s+instanceof|Object\.keys\(elements\))" -g '!**/settings.ts'

Please ensure that all code interacting with ITheme.elements properly handles both possible types (string and Record<string, string>). Consider adding type guards or checks where necessary to safely work with this more flexible structure.


Line range hint 7-15: Note: Potential impact on ISettings usage

While the ISettings interface itself remains unchanged, it references the updated ITheme interface. This means that code using ISettings.theme will need to account for the changes made to ITheme, particularly the new optional logo property and the more flexible elements property.

Let's verify the usage of ISettings to ensure it's consistent with the updated ITheme:

#!/bin/bash
# Description: Check usage of ISettings and its theme property

# Search for usage of ISettings
echo "Usage of ISettings:"
rg --type typescript "ISettings" -g '!**/settings.ts'

# Search for usage of ISettings.theme
echo "Usage of ISettings.theme:"
rg --type typescript "settings.*theme" -g '!**/settings.ts'

Please review the usage of ISettings and ISettings.theme to ensure they align with the updated ITheme interface.


3-3: Approved: Corrected spelling from pallete to palette

The renaming of the property from pallete to palette corrects a typographical error, improving code quality and readability.

To ensure this change is consistently applied throughout the codebase, let's verify the usage:

#!/bin/bash
# Description: Check for any remaining instances of 'pallete' and verify 'palette' usage

# Search for any remaining instances of 'pallete'
echo "Remaining instances of 'pallete':"
rg --type typescript "pallete"

# Verify correct usage of 'palette'
echo "Usage of correct 'palette':"
rg --type typescript "palette"

Please ensure all occurrences of pallete are updated to palette throughout the codebase.


2-2: Approved: New optional logo property added to ITheme

The addition of an optional logo property to the ITheme interface provides more flexibility for theme customization. However, it's worth noting that the ISettings interface also has a logo property.

To ensure there's no confusion or unintended redundancy, let's verify the usage of both logo properties:

Consider adding a comment to clarify the relationship between these two logo properties if they serve different purposes.

✅ Verification successful

Verification Completed: No Conflicts Found for logo Properties

The usage of both ITheme.logo and ISettings.logo does not appear to overlap or cause redundancy within the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of logo properties in ITheme and ISettings

# Search for usage of ITheme.logo
echo "Usage of ITheme.logo:"
rg --type typescript "theme.*logo" -g '!**/settings.ts'

# Search for usage of ISettings.logo
echo "Usage of ISettings.logo:"
rg --type typescript "settings.*logo" -g '!**/settings.ts'

Length of output: 534


Script:

#!/bin/bash
# Description: Check usage of logo properties in ITheme and ISettings

# Search for usage of ITheme.logo
echo "Usage of ITheme.logo:"
rg "ITheme\.logo" -g '*.ts' -g '*.tsx'

# Search for usage of ISettings.logo
echo "Usage of ISettings.logo:"
rg "ISettings\.logo" -g '*.ts' -g '*.tsx'

Length of output: 196

apps/kyb-app/src/components/layouts/AppShell/Content.tsx (1)

8-17: Excellent improvements to theme customization!

The changes to the Content component enhance its flexibility and consistency with the overall theming system:

  1. The addition of text-secondary-foreground to the className ties the text color to the theme, ensuring consistency across the application.
  2. Using the CSS variable var(--secondary) for the background color allows for easier theme customization and potential dark mode support.

These modifications align well with the PR's objective of improving theme customization. The implementation is clean and maintains the component's original structure while significantly improving its theming capabilities.

apps/kyb-app/src/__tests/providers/TestProvider/TestProvider.tsx (1)

17-17: Verify ThemeProvider functionality after removal of SettingsProvider

The simplification of the component structure by directly wrapping children with ThemeProvider aligns with the PR objectives for centralized theme management. However, this change raises some concerns:

  1. Can the ThemeProvider function correctly without the previously passed settings?
  2. How does this affect theme management in the test environment?

Please ensure that:

  1. The ThemeProvider can still provide the necessary theming functionality without explicit settings.
  2. Any tests relying on specific theme settings are updated to reflect this change.

To verify the impact, you can run the following script:

This script will help identify any remaining references to the removed SettingsProvider or settingsJson, and show how ThemeProvider is now being used in test files.

✅ Verification successful

ThemeProvider Refactoring Verified Successfully

The removal of SettingsProvider and settingsJson has been successfully verified with no remaining references in the test files. The ThemeProvider is correctly wrapping children, ensuring that theming functionality remains intact in the test environment.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining references to SettingsProvider or settingsJson in test files

echo "Checking for references to SettingsProvider in test files:"
rg --type typescript --type tsx "SettingsProvider" "apps/kyb-app/src/__tests"

echo "Checking for references to settingsJson in test files:"
rg --type typescript --type tsx "settingsJson" "apps/kyb-app/src/__tests"

echo "Checking ThemeProvider usage in test files:"
rg --type typescript --type tsx "ThemeProvider" "apps/kyb-app/src/__tests"

Length of output: 668


Script:

#!/bin/bash
# Description: Check for any remaining references to SettingsProvider or settingsJson in test files

echo "Checking for references to SettingsProvider in test files:"
rg "SettingsProvider" -g "*.ts" -g "*.tsx" "apps/kyb-app/src/__tests"

echo "Checking for references to settingsJson in test files:"
rg "settingsJson" -g "*.ts" -g "*.tsx" "apps/kyb-app/src/__tests"

echo "Checking ThemeProvider usage in test files:"
rg "ThemeProvider" -g "*.ts" -g "*.tsx" "apps/kyb-app/src/__tests"

Length of output: 785

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/Breadcrumbs.Label.tsx (2)

1-1: LGTM: Good use of helper function and React hooks

The addition of pickLabelProps and useMemo demonstrates good practices:

  1. Separation of concerns by moving logic to a helper function.
  2. Performance optimization through memoization.

These changes align well with React best practices and should improve code maintainability and performance.

Also applies to: 4-4


11-17: Verify the removal of opacity for completed state

The AI summary mentions that the opacity-50 class for the completed state has been removed. This change is not directly visible in the provided code snippet, but it could significantly affect the visual representation of completed steps.

Could you please clarify the reasoning behind removing the opacity for completed states? Was this an intentional design change? If so, how should completed steps be visually distinguished now?

To verify this change, you can run the following command:

This will help ensure that the opacity removal was consistent across all relevant files.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-wrapper.props.ts (1)

14-14: LGTM! Enhances styling flexibility for breadcrumbs.

The addition of the style property to the returned props object is a good improvement. It allows for more dynamic and flexible styling of breadcrumbs based on their active state. This change is consistent with the function's purpose and enhances its functionality without introducing any breaking changes.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-outer-props.ts (1)

14-14: Excellent addition of dynamic styling!

The new style property in the returned BreadcrumbsOuterProps object enhances the component's flexibility by allowing dynamic style assignment based on the active state. This change improves the overall customization capabilities of the Breadcrumbs component.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-inner-props.ts (1)

11-11: LGTM: Style property added for enhanced theme customization

The addition of the style property to the returned props object is a good enhancement. It allows for more granular control over the styling of breadcrumb components based on their active state. This change aligns well with the purpose of the pickInnerProps function, which is to provide props for breadcrumb components with different states.

A few points to consider:

  1. Ensure that themeParams.activeStyles and themeParams.styles are always defined in the theme object to avoid potential undefined values.
  2. If these styles are meant to be merged with existing styles rather than replacing them, consider using a spread operator or a utility function for merging styles.
apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/helpers.ts (1)

1-3: LGTM: Import and function signature are well-defined.

The import statement and function signature are correctly implemented. The use of TypeScript types and a default parameter value for index is a good practice.

apps/kyb-app/src/main.tsx (2)

26-28: Approve ThemeProvider changes and verify theme fetching mechanism

The simplification of ThemeProvider usage is a good step towards centralized theme management. This aligns well with the removal of the settings prop.

Please confirm that:

  1. The theme fetching mechanism based on the application's language is properly implemented in the ThemeProvider component.
  2. The UI schema query for fetching themes is working as expected.

Run the following script to check the implementation of ThemeProvider:

#!/bin/bash
# Description: Check ThemeProvider implementation for language-based theme fetching

# Test: Search for ThemeProvider implementation
echo "Searching for ThemeProvider implementation:"
rg --type typescript --type tsx -A 10 "export.*ThemeProvider"

# Test: Search for UI schema query related to theme fetching
echo "Searching for UI schema query related to theme fetching:"
rg --type typescript --type tsx "query.*theme.*language"

Line range hint 1-32: Verify the impact of removing SettingsProvider

The AI summary mentions the removal of SettingsProvider and its associated settings JSON import. This change is not visible in the provided code but could have significant implications.

Please ensure that:

  1. All components previously relying on SettingsProvider have been updated to use alternative methods for accessing settings.
  2. The removal of settings JSON import doesn't leave any unused imports in the file.

Run the following script to check for any remaining references to SettingsProvider or settings imports:

apps/kyb-app/src/common/components/molecules/ProgressBar/ProgressBar.tsx (1)

4-7: LGTM! Verify usage of new imports.

The addition of ctw from '@ballerine/ui' and styles from './ProgressBar.module.css' are good improvements. The use of CSS modules helps in scoping styles to the component.

Let's verify the usage of ctw in the component:

✅ Verification successful

Verified usage of new imports.

The ctw function from @ballerine/ui is correctly utilized within the ProgressBar component's className prop.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of ctw in the ProgressBar component

# Test: Search for ctw usage in the file
rg --type typescript 'ctw\(' apps/kyb-app/src/common/components/molecules/ProgressBar/ProgressBar.tsx

Length of output: 138


Script:

#!/bin/bash
# Description: Verify the usage of ctw in the ProgressBar component

# Test: Search for ctw usage in the file without specifying the file type
rg 'ctw\(' apps/kyb-app/src/common/components/molecules/ProgressBar/ProgressBar.tsx

Length of output: 113

apps/kyb-app/src/components/molecules/PoweredByLogo/PoweredByLogo.tsx (1)

9-14: LGTM: Component declaration and state initialization.

The component is correctly declared as a functional component with proper typing. The use of useState for managing local state is appropriate and well-implemented.

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/helpers/pick-label-props.ts (3)

1-2: LGTM: Imports are appropriate and concise.

The imports are correctly defined and necessary for the function's implementation.


38-38: LGTM: Concise and correct return statement.

The return statement correctly uses the state parameter to access the appropriate style object from propsMap.


1-39: Overall, well-implemented helper function for theme customization.

The pickLabelProps function is a well-structured and type-safe implementation that aligns with the PR objectives of theme customization. The use of CSS variables for theming is commendable, allowing for easy customization of the Stepper component's Breadcrumbs.

Consider the suggested minor improvements to further enhance the code's maintainability and reusability.

apps/kyb-app/src/components/layouts/AppShell/Navigation.tsx (2)

26-31: Improved control flow in onPrevious function

The addition of the return; statement after exit() is a good improvement. It ensures that the function exits immediately after calling exit() when on the first step, preventing any potential unintended code execution. This change enhances the clarity and predictability of the function's behavior.


Line range hint 1-54: Summary of changes

The changes in this file are minimal but positive:

  1. The onPrevious function now has clearer control flow.
  2. There's a minor formatting improvement in the button's className.

These changes enhance code clarity and maintain good coding practices. Consider the suggested simplification of the onPrevious function for even better readability.

apps/kyb-app/tailwind.config.cjs (3)

26-27: Improved color definition format

The change from hsl(var(--primary)) to var(--primary) simplifies the color definition and allows for more flexible color values. This new format enables direct use of CSS variables, which can be beneficial for theme customization and consistency across the application.


30-31: Consistent color definition updates

The changes to secondary, destructive, success, muted, and accent color definitions are consistent with the primary color update. This consistency in using var(--color) format across all color definitions improves maintainability and allows for more flexible theming capabilities.

Also applies to: 34-35, 38-39, 42-43, 46-47


49-51: New 'controls' color category added

The addition of the controls color category is consistent with the existing color definition structure. This new category could provide more specific styling options for control elements in the application.

To better understand the usage of this new color category, please run the following script:

Could you provide more context on how this new color category will be used in the application?

✅ Verification successful

Further Verification Needed for 'controls' Color Usage

The initial attempt to search for the controls color usage failed due to directory and file type issues. Please run the following script to accurately search for usages across the entire codebase:


'controls' Color Category Verified

The new controls color category is properly utilized in the following components:

  • examples/report-generation-example/src/App.tsx - <div className="controls">
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/SubmitButton.tsx - className="bg-controls text-controls-foreground"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usage of the new 'controls' color in the codebase

# Search for 'controls' color usage in CSS/SCSS files
echo "Searching for 'controls' color usage in CSS/SCSS files:"
rg --type css 'controls' ./src

# Search for 'controls' color usage in JSX/TSX files
echo "Searching for 'controls' color usage in JSX/TSX files:"
rg --type tsx 'controls' ./src

Length of output: 387


Script:

#!/bin/bash
# Description: Search for usage of the new 'controls' color in the entire codebase

# Search for 'controls' color usage in all CSS/SCSS files
echo "Searching for 'controls' color usage in CSS/SCSS files:"
rg 'controls' --glob '*.css' --glob '*.scss'

# Search for 'controls' color usage in all JSX/TSX files
echo "Searching for 'controls' color usage in JSX/TSX files:"
rg 'controls' --glob '*.jsx' --glob '*.tsx'

Length of output: 563

apps/kyb-app/theme.json (2)

1-64: Overall assessment: Well-structured theme configuration with minor improvements needed

The theme.json file provides a comprehensive and well-organized theme configuration for the application. It effectively defines both the color palette and element styling, which should contribute to a consistent user interface.

Key strengths:

  1. Use of HSL color values in the palette, allowing for easy color manipulation.
  2. Detailed configuration for different states of the stepper component.
  3. Consistent use of border radius across elements.

Areas for improvement:

  1. Standardize color formats throughout the configuration (preferably to HSL).
  2. Review and either remove or document the purpose of empty objects.
  3. Ensure color contrast meets accessibility standards.

Addressing these minor issues will further enhance the maintainability and consistency of the theme configuration.


20-62: 🛠️ Refactor suggestion

Standardize color formats and review empty objects in elements configuration

The elements section provides a detailed configuration, especially for the stepper component. However, there are a few points to consider:

  1. Color formats are inconsistent throughout the configuration. For example:

    • Line 21: HSL format
    • Line 31: Hex format with alpha
    • Line 34: RGB format
      Standardizing these to a single format (preferably HSL to match the palette) would improve consistency and maintainability.
  2. There are several empty objects in the stepper configuration (e.g., lines 28, 37). If these are placeholders for future use, consider adding a comment to indicate this. Otherwise, they can be removed to keep the configuration clean.

  3. The use of a consistent border radius (0.5rem) is good for maintaining visual coherence across elements.

Consider refactoring the color values to use a consistent format throughout the theme. Here's an example of how you might standardize to HSL:

-              "active-border-color": "#007AFF33"
+              "active-border-color": "hsla(211, 100%, 50%, 0.2)"
-              "border-color": "rgb(226, 232, 240)",
+              "border-color": "hsl(214, 32%, 91%)",

To check for any remaining inconsistencies in color format, you can run this script:

#!/bin/bash
# Description: Check for inconsistent color formats in the theme

echo "Color formats used in the theme:"
jq -r '.. | objects | to_entries[] | select(.value | type == "string" and (test("^#") or test("^rgb") or test("^hsl"))) | .value' apps/kyb-app/theme.json | sort | uniq -c

This will list all color formats used in the theme, helping identify any remaining inconsistencies.

apps/kyb-app/src/components/layouts/AppShell/LanguagePicker.tsx (2)

2-9: LGTM: Import statements reorganized for better readability.

The reordering of import statements improves code organization by grouping similar imports together. This change enhances code readability without affecting functionality.


Line range hint 1-61: Summary: Styling enhancements with no functional changes.

The modifications to the LanguagePicker component are primarily cosmetic and align with the PR objectives of theme customization. The core functionality remains intact, while the visual presentation has been improved to better integrate with the application's design system.

To ensure these changes don't conflict with other components or global styles, let's verify the usage of the new color classes:

apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/helpers/findDefinitionByName.ts (5)

28-28: LGTM. Consistent with previous change.

The change from UIElement<AnyObject>[] to Array<UIElement<AnyObject>> is consistent with the change in findDefinitionByName and doesn't affect the function's behavior.


49-49: LGTM. Consistent with previous changes.

The change from UIElement<AnyObject>[] to Array<UIElement<AnyObject>> is consistent with the changes in previous functions and doesn't affect the function's behavior.


68-71: LGTM. Consistent changes with improved type annotations.

The changes in getAllDefinitions are consistent with previous functions:

  1. Parameter type changed from UIElement<AnyObject>[] to Array<UIElement<AnyObject>>.
  2. Return type annotation Array<UIElement<AnyObject>> added, improving type safety and readability.
  3. Internal run function's parameter type updated for consistency.

These changes enhance the overall type safety and consistency of the function.


Line range hint 1-86: Overall assessment: Consistent and beneficial changes.

The changes in this file demonstrate a consistent effort to standardize array type notations from UIElement<AnyObject>[] to Array<UIElement<AnyObject>>. This standardization:

  1. Improves code consistency.
  2. Potentially aligns with a larger codebase-wide initiative.
  3. Doesn't introduce any logical changes or potential issues.

The addition of a return type annotation in getAllDefinitions further enhances type safety and readability.

These changes are beneficial and align with good TypeScript practices.


7-7: LGTM. Verify consistent array type notation usage.

The change from UIElement<AnyObject>[] to Array<UIElement<AnyObject>> is syntactically equivalent and doesn't affect the function's behavior. This change appears to be part of a standardization effort.

To ensure consistency, let's check the usage of array type notations across the codebase:

✅ Verification successful

To address the issue with the unsupported typescript file type, please run the following updated scripts to verify the consistency of array type notations:


To successfully verify the consistency of array type notations, please run the following updated scripts that use file extension patterns instead of unsupported type flags:


LGTM. Verified consistent array type notation usage.

The change from UIElement<AnyObject>[] to Array<UIElement<AnyObject>> is consistent across the codebase and aligns with the standardization effort. No inconsistencies or issues were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for inconsistent array type notations in TypeScript files

# Test 1: Count occurrences of both notations
echo "Occurrences of 'Array<...>' notation:"
rg --type typescript 'Array<' -c

echo "Occurrences of '...[]' notation:"
rg --type typescript '\w+\[]' -c

# Test 2: List files with mixed usage
echo "Files with mixed array type notations:"
rg --type typescript -l 'Array<' | xargs -I {} sh -c 'rg --type typescript "\w+\[]" {} -q && echo {}'

Length of output: 539


Script:

# 
#!/bin/bash
# Description: Check for inconsistent array type notations in TypeScript files

# Test 1: Count occurrences of both notations
echo "Occurrences of 'Array<...>' notation:"
rg 'Array<' -t ts -t tsx -c

echo "Occurrences of '...[]' notation:"
rg '\w+\[]' -t ts -t tsx -c

# Test 2: List files with mixed usage
echo "Files with mixed array type notations:"
ts_files=$(rg 'Array<' -t ts -t tsx -l)
for file in $ts_files; do
  if rg '\w+\[]' "$file" > /dev/null; then
    echo "$file"
  fi
done

Length of output: 445


Script:

# 
#!/bin/bash
# Description: Check for inconsistent array type notations in TypeScript files

# Test 1: Count occurrences of both notations
echo "Occurrences of 'Array<...>' notation:"
rg 'Array<' --glob '*.ts' --glob '*.tsx' -c

echo "Occurrences of '...[]' notation:"
rg '\w+\[]' --glob '*.ts' --glob '*.tsx' -c

# Test 2: List files with mixed usage
echo "Files with mixed array type notations:"
ts_files=$(rg 'Array<' --glob '*.ts' --glob '*.tsx' -l)
for file in $ts_files; do
  if rg '\w+\[]' "$file" > /dev/null; then
    echo "$file"
  fi
done

Length of output: 78323

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/theme/base-theme.tsx (3)

17-31: Excellent use of CSS variables for improved theme customization

The changes to the 'idle' state in baseBreadcrumbTheme are well-structured and offer several benefits:

  1. Improved customization: Using CSS variables allows for easy theme adjustments without modifying the base theme file.
  2. Better separation of concerns: The new styles and activeStyles properties provide clear distinction between normal and active states.
  3. Consistent naming convention: The CSS variable names are descriptive and follow a logical pattern, enhancing readability and maintainability.

These changes will make it easier to manage and customize the breadcrumb styles across different themes.


59-71: Comprehensive improvements in the 'completed' state

The changes to the 'completed' state are well-implemented and offer several improvements:

  1. Consistent styling approach: The 'outer' property uses CSS variables, aligning with the changes in other states.
  2. Enhanced active state control: The 'wrapper' property now includes both 'activeClassName' and 'activeStyles', allowing for more precise styling of the active state.
  3. Maintained use of utility functions: The 'ctw' function is still used for className concatenation, preserving the existing pattern.

These changes provide a good balance between consistency across states and specific styling needs for the 'completed' state.


Line range hint 1-75: Summary: Improved theme customization and maintainability

Overall, the changes to baseBreadcrumbTheme significantly enhance the theme's flexibility and maintainability:

  1. Consistent use of CSS variables across states allows for easier theme customization.
  2. Separation of styles and activeStyles provides more granular control over different states.
  3. The changes maintain the existing structure while introducing improvements, ensuring backwards compatibility.

These updates will make it easier for developers to create and manage custom themes for the breadcrumbs component. The only minor suggestion would be to update the 'wrapper' property in the 'warning' state to match the pattern used in other states.

Great job on improving the theme structure!

apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/types.ts (6)

10-10: LGTM: Enhanced styling flexibility for BreadcrumbsOuterProps

The addition of the style property to BreadcrumbsOuterProps improves the component's flexibility by allowing custom inline styles. This change aligns well with React's styling practices and enhances the customization options for the Breadcrumbs component.


16-16: LGTM: Consistent styling enhancement for BreadcrumbsInnerProps

The addition of the style property to BreadcrumbsInnerProps is consistent with the changes made to BreadcrumbsOuterProps. This enhancement provides greater flexibility for styling the inner part of the Breadcrumbs component, maintaining a uniform approach to customization across the component's elements.


22-22: LGTM: Consistent styling approach applied to BreadcrumbsWrapperProps

The addition of the style property to BreadcrumbsWrapperProps completes the consistent application of inline styling capabilities across all main parts of the Breadcrumbs component (outer, inner, and wrapper). This uniform approach enhances the overall flexibility and customization options of the component, maintaining a coherent styling strategy.


37-38: LGTM: Enhanced theming capabilities for InnerThemeSettings

The addition of styles and activeStyles properties to the InnerThemeSettings interface significantly enhances the theming capabilities of the Breadcrumbs component. This change allows for more granular control over the styling of the inner part, including the ability to define different styles for active and inactive states. This improvement in flexibility aligns well with the component's theming system and provides developers with more precise styling options.


46-47: LGTM: Consistent theming enhancements for OuterThemeSettings

The addition of styles and activeStyles properties to the OuterThemeSettings interface mirrors the changes made to InnerThemeSettings. This consistency ensures that the enhanced theming capabilities are uniformly applied across different parts of the Breadcrumbs component. The change maintains a coherent approach to styling and theming, allowing developers to have fine-grained control over both the inner and outer parts of the breadcrumbs.


53-54: LGTM: Comprehensive theming system completed with WrapperThemeSettings enhancements

The addition of styles and activeStyles properties to the WrapperThemeSettings interface completes the enhanced theming capabilities across all main parts of the Breadcrumbs component (wrapper, inner, and outer). This change ensures a consistent and comprehensive approach to styling and theming throughout the component.

The overall impact of these changes is significant:

  1. It provides a uniform theming API across all parts of the Breadcrumbs.
  2. It allows for more granular control over styles, including active state styles.
  3. It enhances the component's flexibility and customization options.

These improvements will greatly benefit developers using this component, allowing for more precise and dynamic styling based on the component's state and specific requirements.

apps/kyb-app/src/domains/collection-flow/types/index.ts (2)

1-1: LGTM: New import statement for ITheme

The new import statement for ITheme is correctly added and necessary for the changes made to the UISchema interface.


1-1: Summary: Successful implementation of theme customization in UISchema

The changes made to this file effectively introduce theme customization capabilities to the UISchema interface. The new import statement and the addition of the theme property are well-implemented and align with the PR objectives.

These modifications will allow for more flexible and dynamic theming in the KYB application, enhancing the overall user experience and customization options.

Also applies to: 152-152

apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/FileUploaderField/FileUploaderField.tsx (3)

46-48: Excellent typo correction in the function name.

The change from handdleContainerClick to handleContainerClick improves code readability and maintainability. The function logic remains correct, and the use of useCallback is appropriate for optimizing performance.


67-67: Consistent update of the onClick handler.

The onClick handler has been correctly updated to use the renamed handleContainerClick function. This change maintains consistency with the function name update and ensures proper functionality of the component.


Line range hint 1-97: Overall assessment: Clean and focused changes.

The changes in this file are minimal and well-executed, focusing on correcting a typo in the function name. The updates improve code readability and maintain consistency throughout the component. No further issues or areas for improvement were identified in this review.

websites/docs/src/content/docs/en/collection-flow/theming.mdx (2)

Line range hint 42-55: Approved: Correct spelling and consistent structure

The change from "pallete" to "palette" is correct, improving the accuracy of the documentation. The JSON structure is valid and consistent with the described theme, using HSL color format for flexibility.


Line range hint 1-104: Overall improvement in documentation accuracy and consistency

The changes made to this file have significantly improved the quality of the theming documentation:

  1. Corrected the spelling of "palette" throughout the document, enhancing accuracy.
  2. Maintained consistent JSON structures across different theme examples.
  3. Used HSL color format, providing flexibility in color definitions.

These improvements contribute to better readability and understanding of the theming capabilities in Collection Flow.

services/workflows-service/src/collection-flow/collection-flow.service.ts (4)

90-93: LGTM: Variable name correction.

The change from uiDefintion to uiDefinition corrects a typo, improving code readability and consistency.


98-99: LGTM: Consistent variable name usage.

The change from uiDefintion to uiDefinition in the TranslationService constructor call is consistent with the previous rename, ensuring the correct variable is used.


106-111: LGTM: Consistent variable name usage in return object.

The change from uiDefintion to uiDefinition in the return object is consistent with the previous renames, ensuring the correct properties are accessed from the uiDefinition object.


Line range hint 1-280: Overall assessment: Improvements in code consistency and functionality.

The changes in this file primarily focus on correcting the variable name from uiDefintion to uiDefinition throughout the getFlowConfiguration method. These modifications enhance code readability and consistency. Additionally, the inclusion of the theme property in the returned uiSchema object and the correct referencing of the definition property improve the functionality of the method.

All changes align with the AI-generated summary and contribute positively to the code quality. A minor suggestion for type safety was provided for the theme property.

apps/kyb-app/src/pages/CollectionFlow/CollectionFlow.tsx (4)

7-7: LGTM: New imports for theme customization.

The addition of useTheme hook and PoweredByLogo component aligns with the PR objectives for theme customization. These imports enhance the component's theming capabilities and improve the structure for displaying the powered-by logo.

Also applies to: 9-9


94-94: LGTM: Theme integration using useTheme hook.

The use of useTheme hook to extract themeDefinition is a good practice for centralized theme management. This change aligns well with the PR objectives and provides access to theme-related properties within the component.


215-216: LGTM: Improved powered-by logo implementation.

Replacing the commented-out image tag with the PoweredByLogo component is a good improvement. It enhances code cleanliness and provides a more flexible way to manage the powered-by logo. The use of a dedicated component aligns well with React best practices and allows for easier customization if needed in the future.


Line range hint 1-278: LGTM: Successful implementation of theme customization.

The changes in this file successfully implement theme customization as per the PR objectives. Key improvements include:

  1. Integration of the useTheme hook for centralized theme management.
  2. Enhanced logo handling with theme-based prioritization.
  3. Improved implementation of the powered-by logo using a dedicated component.

These modifications increase the component's flexibility in terms of theming and branding without introducing any apparent issues or inconsistencies. The overall structure and logic of the component remain intact, focusing on the specific areas needed for theme customization.

apps/kyb-app/src/utils/transform-theme-to-inline-styles.ts (1)

3-5: Conversion to arrow function is appropriate

Changing createInlineVariable to an arrow function simplifies the code and maintains the same functionality.

apps/kyb-app/src/common/providers/ThemeProvider/ThemeProvider.tsx (13)

1-1: Importing APP_LANGUAGE_QUERY_KEY for Language Detection

Importing APP_LANGUAGE_QUERY_KEY is appropriate for retrieving the application's language from the URL parameters.


4-4: Importing useUISchemasQuery Hook

The useUISchemasQuery hook is correctly imported to fetch the UI schema based on the selected language.


5-5: Importing transformThemeToInlineStyles Utility

Importing this utility function helps in transforming the theme object into inline styles applied to the HTML element.


6-6: Importing useLayoutEffect and useMemo from React

These hooks are essential for managing side effects and memoization in the component.


7-7: Importing Default Theme

Importing defaultTheme from '../../../../theme.json' ensures there's a fallback theme if the custom theme fails to load.


8-8: Importing themeContext

This import brings in the context needed to provide the theme to the application.


10-10: Destructuring Provider from themeContext

Extracting Provider allows for the context to be supplied to the component tree.


15-15: Removing theme Prop from ThemeProvider

The removal of the theme prop aligns with the shift to fetching the theme dynamically based on language.


17-17: Fetching UI Schema with useUISchemasQuery

Fetching the UI schema based on the language ensures that the correct theme is loaded for the user.


19-31: Memoizing Theme Calculation

The use of useMemo to compute the theme is efficient and prevents unnecessary recalculations. The logic handles loading states, errors, and falls back to the default theme if necessary.


33-33: Creating Theme Context with useMemo

Memoizing the context value optimizes performance by preventing unnecessary re-renders of consumer components.


36-41: Applying Inline Styles to the HTML Element

Setting inline styles on the <html> element directly applies the theme globally. Ensure this does not conflict with other global styles or CSS frameworks.

Are there any existing global styles that might be overridden or cause conflicts?


43-43: Providing Theme Context to Children Components

Wrapping the application with the Provider and passing down the context makes the theme accessible throughout the component tree.

apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/useUIElementProps.ts (3)

4-4: Import statement added correctly

The injectIndexesAtRulesPaths helper function is imported successfully, enabling index injection into rule paths.


16-18: Memoization of availabilityRules is correctly implemented

Using useMemo to memoize availabilityRules based on definition and index optimizes performance by preventing unnecessary recalculations.


20-22: Memoization of visibilityRules is correctly implemented

The visibilityRules are appropriately memoized using useMemo, relying on definition and index as dependencies.

services/workflows-service/prisma/schema.prisma (1)

422-422: LGTM!

The addition of crossEnvKey with a unique constraint looks good and aligns with existing models.

apps/kyb-app/src/components/organisms/UIRenderer/elements/JSONForm/components/FieldTemplate/FieldTemplate.tsx (6)

9-9: Importing getInputIndex is appropriate

The addition of the getInputIndex import is necessary for computing inputIndex based on props.id.


11-11: Importing useUIElementProps is correct

Including useUIElementProps allows access to UI element properties such as hidden, which is important for conditional rendering.


23-25: Memoizing inputIndex calculation enhances performance

Using useMemo to memoize the computation of inputIndex based on props.id is efficient and prevents unnecessary recalculations.


31-31: Improved regex enhances fieldDefinition matching

Updating the regex in props.id.replace(/root_\d*_?/, '') provides a more flexible and accurate match for props.id, ensuring the correct field definition is found.


36-36: Destructuring hidden from useUIElementProps

Extracting the hidden property allows for better control over the component's visibility based on dynamic UI logic.


51-51: Conditional rendering based on hidden property

Adding if (hidden) return null; ensures that the field does not render when it should be hidden, enhancing the user interface by not displaying irrelevant fields.

apps/kyb-app/src/components/organisms/UIRenderer/elements/SubmitButton/SubmitButton.tsx (3)

14-14: Import of useFlowContextQuery is correctly added

The addition of useFlowContextQuery is appropriate and used correctly to access the flow context data.


18-18: Import of useCallback and useMemo is appropriate

Importing useCallback and useMemo from React is necessary for optimizing the component's performance.


100-100: Styling update aligns with design guidelines

The addition of className="bg-controls text-controls-foreground" enhances the button's appearance and conforms to the design system.

Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (2)
apps/kyb-app/src/components/organisms/UIRenderer/elements/StepperUI/StepperUI.tsx (2)

Line range hint 28-42: LGTM: Improved computeStepStatus function

The updated computeStepStatus function now includes the context parameter, allowing for more accurate step status computation. The logic considers warnings, page completion state, and UI element state, which should provide more precise status information.

Consider using early returns to simplify the function and improve readability:

const computeStepStatus = ({ pageError, page, context, uiElementState }: {
  page: UIPage;
  uiElementState: UIElementState;
  pageError: Record<string, ErrorField>;
  currentPage: UIPage;
  context: CollectionFlowContext;
}) => {
  if (Object.values(pageError || {}).some(error => error.type === 'warning')) return 'warning';
  if (isPageCompleted(page, context) || uiElementState?.isCompleted) return 'completed';
  return 'idle';
};

Line range hint 76-84: LGTM: Added auto-scroll for active breadcrumb

The new useEffect hook improves user experience by automatically scrolling the active breadcrumb into view. This is particularly useful for longer stepper sequences.

Consider adding a smooth scrolling behavior for a more polished user experience:

useEffect(() => {
  if (!activeStep) return;

  const activeBreadcrumb = document.querySelector(`[data-breadcrumb-id=${activeStep.id}]`);

  // Making sure that breadcrumb in viewport on transitions
  activeBreadcrumb?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}, [activeStep]);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 7a98b7c and a73e7a5.

⛔ Files ignored due to path filters (5)
  • apps/kyb-app/public/apple-touch-icon.png is excluded by !**/*.png
  • apps/kyb-app/public/favicon-16x16.png is excluded by !**/*.png
  • apps/kyb-app/public/favicon-32x32.png is excluded by !**/*.png
  • apps/kyb-app/public/vite.svg is excluded by !**/*.svg
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • apps/backoffice-v2/package.json (1 hunks)
  • apps/kyb-app/index.html (1 hunks)
  • apps/kyb-app/src/common/providers/ThemeProvider/useTheme.ts (1 hunks)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Wrapper.tsx (1 hunks)
  • apps/kyb-app/src/components/layouts/AppShell/Navigation.tsx (1 hunks)
  • apps/kyb-app/src/components/molecules/PoweredByLogo/PoweredByLogo.tsx (1 hunks)
  • apps/kyb-app/src/components/molecules/PoweredByLogo/helpers.ts (1 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/elements/StepperUI/StepperUI.tsx (3 hunks)
  • apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/useUIElementProps.ts (2 hunks)
  • apps/kyb-app/src/main.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/kyb-app/index.html
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/kyb-app/src/components/atoms/Stepper/components/atoms/Breadcrumbs/components/elements/Wrapper.tsx
  • apps/kyb-app/src/components/layouts/AppShell/Navigation.tsx
  • apps/kyb-app/src/components/molecules/PoweredByLogo/PoweredByLogo.tsx
  • apps/kyb-app/src/components/molecules/PoweredByLogo/helpers.ts
  • apps/kyb-app/src/components/organisms/UIRenderer/hooks/useUIElementProps/useUIElementProps.ts
  • apps/kyb-app/src/main.tsx
🔇 Additional comments (4)
apps/kyb-app/src/common/providers/ThemeProvider/useTheme.ts (1)

1-13: LGTM! Well-implemented custom hook with proper error handling.

The useTheme hook is well-implemented, incorporating the suggestions from the previous review:

  1. TypeScript types are used for the hook's return value (IThemeContext).
  2. Error handling is implemented to ensure the hook is used within a ThemeProvider.

The code follows React best practices and is well-structured. Good job on addressing the previous feedback!

apps/kyb-app/src/components/organisms/UIRenderer/elements/StepperUI/StepperUI.tsx (3)

2-7: LGTM: New imports and hooks reintroduction

The new imports and reintroduction of hooks appear to be part of a refactoring effort to improve the StepperUI component's structure and functionality. These changes align well with the component's purpose and should enhance its capabilities.

Also applies to: 11-11, 16-17


Line range hint 46-74: LGTM: Optimized steps and activeStep calculations

The use of useMemo for both steps and activeStep is a good optimization. This prevents unnecessary recalculations when the component re-renders, potentially improving performance. The dependencies for both hooks are appropriate, ensuring they update when relevant state changes.

The explicit typing of steps as BreadcrumbItemInput[] enhances type safety, which is a good practice.


Line range hint 86-117: LGTM: Render method improvements and addressed past issues

The changes in the render method have successfully addressed the issues mentioned in the past review comments:

  1. The className for the breadcrumb item has been simplified, removing the incomplete Tailwind CSS class 'last:bg-'.
  2. The unnecessary console.log statement has been removed, improving code cleanliness and potentially performance.

These changes demonstrate attention to code quality and responsiveness to review feedback.

apps/backoffice-v2/package.json Show resolved Hide resolved
@chesterkmr chesterkmr merged commit 9c21782 into dev Oct 2, 2024
10 checks passed
@chesterkmr chesterkmr deleted the illiar/feat/kyb-theme-customization branch October 2, 2024 10:31
@Omri-Levy Omri-Levy mentioned this pull request Nov 4, 2024
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