Skip to content

Tshepo/f/drawer#3128

Merged
AlexStepantsov merged 7 commits intoshesha-io:mainfrom
Tshepo1103-lab:tshepo/f/drawer
Apr 10, 2025
Merged

Tshepo/f/drawer#3128
AlexStepantsov merged 7 commits intoshesha-io:mainfrom
Tshepo1103-lab:tshepo/f/drawer

Conversation

@Tshepo1103-lab
Copy link
Copy Markdown
Contributor

@Tshepo1103-lab Tshepo1103-lab commented Apr 6, 2025

#3018

Summary by CodeRabbit

  • New Features

    • Added an option to customize the drawer's background, allowing for distinct styling of its body and content.
    • Introduced granular border customization, giving users refined control over border styles and corner radii.
  • Refactor

    • Updated the settings interface with reorganized, collapsible panels for action buttons and enhanced option selections for background, size, and position.
    • Improved the management of background settings by sourcing options from constants.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2025

Walkthrough

The changes update the drawer component by introducing a new background property for styling. The new prop is used to assign the body style, while the old style prop is reassigned to a new content style. Additionally, the index file is modified to pass background styles directly. The settings form is restructured to use imported constants for background types, sizes, and positions with new collapsible sections for buttons, and property names are updated accordingly. A new border configuration is also added to the default styles in the utility file.

Changes

Files / Group Change Summary
shesha-reactjs/src/designer-components/drawer/drawer.tsx Added an optional background?: CSSProperties property to the IShaDrawer interface; updated the ShaDrawer component to use background for the body style and moved the previous style value to a new content style.
shesha-reactjs/src/designer-components/drawer/index.tsx Removed the spread operator for backgroundStyles from additionalStyles and added a new line to pass backgroundStyles directly as the background prop to the ShaDrawer component.
shesha-reactjs/src/designer-components/drawer/settingsForm.ts Imported backgroundTypeOptions, positionOptions, and sizeOptions for background settings; restructured the settings with new collapsible panels for "Ok Button" and "Cancel Button"; updated property names for header and footer background settings.
shesha-reactjs/src/designer-components/drawer/utils.ts Introduced a new border property in the defaultStyles function with nested definitions for borders on all sides and detailed radius specifications.
shesha-reactjs/src/designer-components/text/utils.ts Modified the background property in the defaultStyles function to change the color attribute from '#fff' to an empty string ''.

Suggested reviewers

  • James-Baloyi

Possibly related PRs

Poem

Oh, what a joyful hop it is today,
A drawer with style in a brand new way.
Backgrounds and borders, neatly combined,
Settings and panels all perfectly aligned.
I, the rabbit, cheer with a twitch and a grin,
Hoping these changes bring magic from within!
🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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
Copy Markdown
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: 0

🧹 Nitpick comments (1)
shesha-reactjs/src/designer-components/drawer/settingsForm.ts (1)

1059-1060: Fix typo in ID and property name.

There appears to be a typo in the ID (footerStyleCollapsiblePanell with double 'l') and an inconsistent property name (headerStylePanell instead of headerStylePanel).

-  id: 'footerStyleCollapsiblePanell',
-  propertyName: 'headerStylePanell',
+  id: 'footerStyleCollapsiblePanel',
+  propertyName: 'headerStylePanel',
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f4a79c and bcef706.

📒 Files selected for processing (4)
  • shesha-reactjs/src/designer-components/drawer/drawer.tsx (4 hunks)
  • shesha-reactjs/src/designer-components/drawer/index.tsx (1 hunks)
  • shesha-reactjs/src/designer-components/drawer/settingsForm.ts (20 hunks)
  • shesha-reactjs/src/designer-components/drawer/utils.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-attempt
🔇 Additional comments (9)
shesha-reactjs/src/designer-components/drawer/index.tsx (1)

134-134: Clean implementation of background property.

The background styles are now correctly passed directly to the ShaDrawer component as a dedicated prop rather than being spread into additionalStyles. This change works well with the updated drawer component structure.

shesha-reactjs/src/designer-components/drawer/drawer.tsx (2)

30-30: Appropriate interface extension.

The new optional background property extends the interface correctly to support the enhanced styling capabilities.


153-154: Good separation of styling concerns.

The styles are now properly separated with background applied to body and style applied to content, which provides more granular styling control.

shesha-reactjs/src/designer-components/drawer/utils.ts (1)

5-16: Well-structured border defaults.

The new border configuration is comprehensive and properly structured with appropriate default values for all sides and corners.

shesha-reactjs/src/designer-components/drawer/settingsForm.ts (5)

5-10: Good use of imported constants.

Using imported constant collections instead of hardcoded values improves maintainability and consistency.


113-118: Clean organization of button settings.

The transition from section separators to collapsible panels improves the UI organization and user experience.


454-459: Consistent visibility conditions.

The visibility conditions for background controls have been properly standardized.


474-480: Improved tooltips and options.

The tooltips are now more descriptive and the options are sourced from imported constants.


1451-1453:

Details

✅ Verification successful

Potential duplicate property name.

The propertyName: 'footerStylePanel' might conflict with other footer style properties in the component. Consider ensuring consistent naming patterns throughout the form.


🏁 Script executed:

#!/bin/bash
# Check for potential duplicate or conflicting property names in the codebase
echo "Searching for 'footerStylePanel' and related properties..."
rg -A 1 -B 1 "propertyName: ['\"](headerStylePanel|footerStylePanel|headerStyle|footerStyle)['\"]" --glob "*.ts*"

Length of output: 401


Action Needed: Re-run Verification for Duplicate Property Names

It appears that our previous rg command didn’t search any files due to an overly restrictive glob filter. To properly verify if the property name "footerStylePanel" appears more than once (which may lead to conflicts), please run the following revised shell script that searches the entire repository without limiting file types:

Once you verify whether duplicate or conflicting property names exist, please update the review comment accordingly.


🏁 Script executed:

#!/bin/bash
echo "Searching for occurrences of 'propertyName: \"footerStylePanel\"' in the codebase..."
rg "propertyName: ['\"]footerStylePanel['\"]" .

Length of output: 356


Duplication Verification Passed: No Duplicate Property Found

After verifying the codebase, no additional occurrences of the property name "footerStylePanel" were found. This indicates that the current naming in the file is unique and does not conflict with any other similar footer style properties. You can safely disregard the potential duplicate concern here.

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (1)
shesha-reactjs/src/designer-components/text/utils.ts (1)

96-96: Consider using a more explicit value instead of an empty string for background color.

Changing the default background color from '#fff' to an empty string ('') may cause inconsistent behavior. While an empty string may work in some contexts, using explicit values like 'transparent' or 'inherit' would better communicate the intent and ensure consistent rendering across different browsers.

This change aligns with the drawer component updates mentioned in the summary, but consider whether this default style pattern should be applied consistently across other components as well.

-    background: { type: 'color', color: '' },
+    background: { type: 'color', color: 'transparent' },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bcef706 and 1b8fbb5.

📒 Files selected for processing (1)
  • shesha-reactjs/src/designer-components/text/utils.ts (1 hunks)

Copy link
Copy Markdown
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: 3

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1b8fbb5 and be6e990.

📒 Files selected for processing (1)
  • shesha-reactjs/src/designer-components/drawer/settingsForm.ts (20 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-attempt
🔇 Additional comments (7)
shesha-reactjs/src/designer-components/drawer/settingsForm.ts (7)

5-10: Good refactoring to use imported constants instead of hardcoded values.

The addition of imported constants for background configurations improves maintainability and ensures consistency throughout the codebase.


113-144: Well-structured collapsible panel for Ok Button configuration.

The implementation of a collapsible panel for the Ok Button settings creates a cleaner, more organized UI by grouping related settings together. The panel properly includes action configuration, custom text, and enabled state.


316-316: Good use of imported constants for button group options.

Using backgroundTypeOptions from a shared utility file improves code maintainability and ensures consistency.


449-455: Improved visibility condition for background controls.

The updated hidden condition correctly targets background controls based on the type being "color".


467-475: Enhanced dropdown with tooltip and proper options.

The addition of detailed tooltips and using the imported sizeOptions constant improves user experience and code maintainability.


702-706: Good conditional visibility for header and footer style panels.

The addition of proper hidden conditions for both header and footer style panels ensures they only display when relevant (when showHeader or showFooter is true).

Also applies to: 1094-1098


560-566: Good use of utility functions for border and corner inputs.

Using the imported utility functions getBorderInputs() and getCornerInputs() simplifies the code and promotes reusability.

Comment on lines +1053 to 1080
.addCollapsiblePanel({
id: 'footerStyleCollapsiblePanell',
propertyName: 'headerStylePanell',
label: 'Custom Styles',
labelAlign: 'right',
ghost: true,
parentId: 'styleRouter',
collapsible: 'header',
content: {
id: 'footerStylePnl',
components: new DesignerToolbarSettings()
.addSettingsInput({
readOnly: {
_code: 'return getSettingValue(data?.readOnly);',
_mode: 'code',
_value: false,
} as any,
id: 'custom-css-412c-8461-sc1d55e5c0734',
inputType: 'codeEditor',
propertyName: 'headerStyle',
hideLabel: false,
label: 'Style',
description:
'A script that returns the style of the element as an object. This should conform to CSSProperties',
})
.toJson(),
},
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix inconsistent naming in header styles panel.

The property name headerStylePanell has an inconsistent double 'l' which doesn't match the naming pattern used elsewhere.

-                                propertyName: 'headerStylePanell',
+                                propertyName: 'headerStylePanel',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.addCollapsiblePanel({
id: 'footerStyleCollapsiblePanell',
propertyName: 'headerStylePanell',
label: 'Custom Styles',
labelAlign: 'right',
ghost: true,
parentId: 'styleRouter',
collapsible: 'header',
content: {
id: 'footerStylePnl',
components: new DesignerToolbarSettings()
.addSettingsInput({
readOnly: {
_code: 'return getSettingValue(data?.readOnly);',
_mode: 'code',
_value: false,
} as any,
id: 'custom-css-412c-8461-sc1d55e5c0734',
inputType: 'codeEditor',
propertyName: 'headerStyle',
hideLabel: false,
label: 'Style',
description:
'A script that returns the style of the element as an object. This should conform to CSSProperties',
})
.toJson(),
},
})
.addCollapsiblePanel({
id: 'footerStyleCollapsiblePanell',
propertyName: 'headerStylePanel',
label: 'Custom Styles',
labelAlign: 'right',
ghost: true,
parentId: 'styleRouter',
collapsible: 'header',
content: {
id: 'footerStylePnl',
components: new DesignerToolbarSettings()
.addSettingsInput({
readOnly: {
_code: 'return getSettingValue(data?.readOnly);',
_mode: 'code',
_value: false,
} as any,
id: 'custom-css-412c-8461-sc1d55e5c0734',
inputType: 'codeEditor',
propertyName: 'headerStyle',
hideLabel: false,
label: 'Style',
description:
'A script that returns the style of the element as an object. This should conform to CSSProperties',
})
.toJson(),
},
})

Comment on lines +1445 to 1472
.addCollapsiblePanel({
id: 'footerStyleCollapsiblePanel',
propertyName: 'footerStylePanel',
label: 'Custom Styles',
labelAlign: 'right',
ghost: true,
parentId: 'styleRouter',
collapsible: 'header',
content: {
id: 'footerStylePnl',
components: new DesignerToolbarSettings()
.addSettingsInput({
readOnly: {
_code: 'return getSettingValue(data?.readOnly);',
_mode: 'code',
_value: false,
} as any,
id: 'custom-css-412c-8461-sc1d55e5c073',
inputType: 'codeEditor',
propertyName: 'footerStyle',
hideLabel: false,
label: 'Style',
description:
'A script that returns the style of the element as an object. This should conform to CSSProperties',
})
.toJson(),
},
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix duplicate panel ID causing potential conflicts.

The ID footerStyleCollapsiblePanel is used twice at lines 1086 and 1446, which could cause runtime conflicts or unexpected behavior.

-                                id: 'footerStyleCollapsiblePanel',
+                                id: 'footerCustomStyleCollapsiblePanel',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.addCollapsiblePanel({
id: 'footerStyleCollapsiblePanel',
propertyName: 'footerStylePanel',
label: 'Custom Styles',
labelAlign: 'right',
ghost: true,
parentId: 'styleRouter',
collapsible: 'header',
content: {
id: 'footerStylePnl',
components: new DesignerToolbarSettings()
.addSettingsInput({
readOnly: {
_code: 'return getSettingValue(data?.readOnly);',
_mode: 'code',
_value: false,
} as any,
id: 'custom-css-412c-8461-sc1d55e5c073',
inputType: 'codeEditor',
propertyName: 'footerStyle',
hideLabel: false,
label: 'Style',
description:
'A script that returns the style of the element as an object. This should conform to CSSProperties',
})
.toJson(),
},
})
.addCollapsiblePanel({
- id: 'footerStyleCollapsiblePanel',
+ id: 'footerCustomStyleCollapsiblePanel',
propertyName: 'footerStylePanel',
label: 'Custom Styles',
labelAlign: 'right',
ghost: true,
parentId: 'styleRouter',
collapsible: 'header',
content: {
id: 'footerStylePnl',
components: new DesignerToolbarSettings()
.addSettingsInput({
readOnly: {
_code: 'return getSettingValue(data?.readOnly);',
_mode: 'code',
_value: false,
} as any,
id: 'custom-css-412c-8461-sc1d55e5c073',
inputType: 'codeEditor',
propertyName: 'footerStyle',
hideLabel: false,
label: 'Style',
description:
'A script that returns the style of the element as an object. This should conform to CSSProperties',
})
.toJson(),
},
})

Comment on lines +146 to 177
.addCollapsiblePanel({
id: nanoid(),
propertyName: 'cancelButtonCustomEnabled',
label: 'Custom Enabled',
inputType: 'codeEditor',
description: 'Enter custom enabled of the Cancel button',
propertyName: 'cancelButtonCollapsiblePanel',
label: 'Cancel Button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
content: {
id: nanoid(),
components: new DesignerToolbarSettings()
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'onCancelAction',
label: 'Ok Cancel',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.addSettingsInput({
id: nanoid(),
propertyName: 'cancelText',
label: 'Cancel Text',
description: 'The text that will be displayed on the Cancel button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.addSettingsInput({
id: nanoid(),
propertyName: 'cancelButtonCustomEnabled',
label: 'Custom Enabled',
inputType: 'codeEditor',
description: 'Enter custom enabled of the Cancel button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.toJson(),
},
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix incorrect label in Cancel Button action configurator.

The label for the cancel button action configurator is incorrectly set to "Ok Cancel" which doesn't match its purpose.

-                                    label: 'Ok Cancel',
+                                    label: 'Cancel Action',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.addCollapsiblePanel({
id: nanoid(),
propertyName: 'cancelButtonCustomEnabled',
label: 'Custom Enabled',
inputType: 'codeEditor',
description: 'Enter custom enabled of the Cancel button',
propertyName: 'cancelButtonCollapsiblePanel',
label: 'Cancel Button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
content: {
id: nanoid(),
components: new DesignerToolbarSettings()
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'onCancelAction',
label: 'Ok Cancel',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.addSettingsInput({
id: nanoid(),
propertyName: 'cancelText',
label: 'Cancel Text',
description: 'The text that will be displayed on the Cancel button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.addSettingsInput({
id: nanoid(),
propertyName: 'cancelButtonCustomEnabled',
label: 'Custom Enabled',
inputType: 'codeEditor',
description: 'Enter custom enabled of the Cancel button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.toJson(),
},
})
.addCollapsiblePanel({
id: nanoid(),
propertyName: 'cancelButtonCollapsiblePanel',
label: 'Cancel Button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
content: {
id: nanoid(),
components: new DesignerToolbarSettings()
.addConfigurableActionConfigurator({
id: nanoid(),
propertyName: 'onCancelAction',
label: 'Cancel Action',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.addSettingsInput({
id: nanoid(),
propertyName: 'cancelText',
label: 'Cancel Text',
description: 'The text that will be displayed on the Cancel button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.addSettingsInput({
id: nanoid(),
propertyName: 'cancelButtonCustomEnabled',
label: 'Custom Enabled',
inputType: 'codeEditor',
description: 'Enter custom enabled of the Cancel button',
parentId: 'ccc24bf6-f76d-4139-a850-c99bf06c8b69',
})
.toJson(),
},
})

@AlexStepantsov AlexStepantsov merged commit 3d1d8ea into shesha-io:main Apr 10, 2025
2 of 4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 10, 2025
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