Skip to content

Tshepo/f/text#3107

Merged
James-Baloyi merged 6 commits intoshesha-io:mainfrom
Tshepo1103-lab:tshepo/f/text
Apr 4, 2025
Merged

Tshepo/f/text#3107
James-Baloyi merged 6 commits intoshesha-io:mainfrom
Tshepo1103-lab:tshepo/f/text

Conversation

@Tshepo1103-lab
Copy link
Copy Markdown
Contributor

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

Summary by CodeRabbit

  • New Features

    • Introduced additional formatting options such as italic, code, strikethrough, underline, ellipsis, mark, keyboard shortcuts, and copyable text in the settings.
  • Refactor

    • Enhanced text styling for improved consistency based on text type, with refined alignment, size handling, and responsive dimensions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2025

Walkthrough

This pull request updates several aspects of the text-related components within the application. The GenericText component now uses a new size prop and adjusts its styling logic based on the textType property. The text styling migration in the TextComponent now passes the textType to the defaultStyles function. Additionally, the settings form has been expanded with multiple new switch options and updated hidden field conditions. Finally, the default styling logic has been modified to apply conditional font sizing, change background color, and adjust dimensions.

Changes

File(s) Change Summary
shesha-reactjs/src/designer-components/text/genericText.tsx - Removed fontSize prop and added size prop.
- Updated style object: conditionally includes fontSize (set to undefined when textType is 'title'), replaced textAlign with justifyContent, and removed display: 'block'.
shesha-reactjs/src/designer-components/text/index.tsx - Modified the migrator method in TextComponent to call defaultStyles(prev.textType) instead of defaultStyles().
shesha-reactjs/src/designer-components/text/settingsForm.ts - Expanded getSettings with new input rows for italic/code, strikethrough/underline, ellipsis/mark, and keyboard/copyable options.
- Updated dropdown for text alignment from textAlign to font.align and adjusted hidden property conditions based on textType.
- Added tooltips for shadow properties and introduced a new shadow spread field.
shesha-reactjs/src/designer-components/text/utils.ts - Updated the defaultStyles function to accept a textType parameter.
- Set font.size to undefined when textType is 'title', else to 14.
- Changed background color from 'transparent' to '#fff'.
- Adjusted dimensions.height from '32px' to '100%'.

Sequence Diagram(s)

sequenceDiagram
    participant TC as TextComponent Migrator
    participant DS as defaultStyles Function
    participant GT as GenericText Component

    TC->>DS: Call defaultStyles(prev.textType)
    DS-->>TC: Return style object (conditional font size, updated background & dimensions)
    TC->>GT: Pass props including new style and `size`
    GT-->>TC: Render text with updated styles
Loading

Possibly related PRs

Suggested reviewers

  • James-Baloyi

Poem

Oh, I’m a rabbit, hopping with glee,
New props and styles set the code free.
From fontSize to size, a hop so neat,
With switches and defaults, it can't be beat!
Celebrating changes with every little leap—
CodeRabbit cheers, as the bugs take a sleep!
🐇💻

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

🧹 Nitpick comments (2)
shesha-reactjs/src/designer-components/text/settingsForm.ts (2)

269-272: Incorrect ID for ellipsis property

The ellipsis property is using the ID 'strong-s4gmBg31azZC0UjZjpfTm', which could cause confusion as it doesn't match the property name.

-                      id: 'strong-s4gmBg31azZC0UjZjpfTm',
+                      id: 'ellipsis-s4gmBg31azZC0UjZjpfTm',

217-218: Typo in component ID

There's a typo in the component ID: "switeches" instead of "switches".

-                  id: 'switeches-s4gmBg31azZC0UjZjpfTm',
+                  id: 'switches-s4gmBg31azZC0UjZjpfTm',

Same applies to other similar IDs at lines 240, 263, and 286.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd1510 and 5ab7ee5.

📒 Files selected for processing (4)
  • shesha-reactjs/src/designer-components/text/genericText.tsx (4 hunks)
  • shesha-reactjs/src/designer-components/text/index.tsx (1 hunks)
  • shesha-reactjs/src/designer-components/text/settingsForm.ts (7 hunks)
  • shesha-reactjs/src/designer-components/text/utils.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-test
🔇 Additional comments (11)
shesha-reactjs/src/designer-components/text/index.tsx (1)

120-120: Update migrator method to pass text type to defaultStyles

The migrator method now correctly passes the text type to the defaultStyles function, ensuring that styles are properly migrated based on the text type of the component. This is a good change that aligns with the updates in the defaultStyles function.

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

27-27: Prop replacement: fontSize → size

Changed from using fontSize prop to size prop, which is a good update for consistency with the changes in the defaultStyles function.


90-90: Simplified text component styling

Removed the display: 'block' property from the Text component style, making the component more flexible in different layout contexts.

shesha-reactjs/src/designer-components/text/utils.ts (4)

89-89: Updated defaultStyles signature to accept textType parameter

The defaultStyles function now accepts a textType parameter, which enables conditional styling based on the text type. This is a good improvement for more flexible styling.


94-94: Conditional font size based on text type

Font size is now conditionally set based on the text type, which aligns well with the changes in the GenericText component.


96-96: Changed background color from transparent to white

The background color has been changed from 'transparent' to '#fff', which may affect the appearance of existing text components.

Please verify that this change doesn't negatively impact the appearance of existing text components in your application, particularly those that may be overlaid on non-white backgrounds.


111-111: Changed height from fixed to fluid

The height has been changed from a fixed '32px' to a fluid '100%', which may affect the layout of existing components.

Please verify that this change doesn't disrupt the layout of existing text components, especially in containers where the height is determined by the content.

shesha-reactjs/src/designer-components/text/settingsForm.ts (4)

216-307: Added multiple text formatting options

Added new switch options for text formatting: italic, code, strikethrough, underline, ellipsis, mark, keyboard, and copyable. This is a great enhancement that provides more control over text formatting.


424-463: Enhanced conditional display of font size settings

Added conditional display of font size and size unit dropdowns based on the text type, which is a good improvement for the user experience. This ensures that the appropriate controls are shown for each text type.


492-492: Updated property name for text alignment

Changed the property name from 'textAlign' to 'font.align', which provides better organization of the font properties.


944-953: Added shadow spread radius control

Added a new field for shadow spread radius, enhancing the shadow customization options.

Comment on lines +61 to +66
style: {
...style,
color: contentType === 'custom' ? style.color : undefined,
fontSize: textType === 'title' ? undefined : style?.fontSize,
justifyContent: style.textAlign,
},
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

Potential misuse of justifyContent property

The code uses justifyContent: style.textAlign which may not work as expected since these CSS properties have different behaviors. textAlign controls text alignment, while justifyContent aligns flex items along the main axis.

-      justifyContent: style.textAlign,
+      textAlign: style.textAlign,

Also, the conditional fontSize handling for titles should be documented for clarity:

-      fontSize: textType === 'title' ? undefined : style?.fontSize,
+      // Title components use their own fontSize based on level prop
+      fontSize: textType === 'title' ? undefined : style?.fontSize,
📝 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
style: {
...style,
color: contentType === 'custom' ? style.color : undefined,
fontSize: textType === 'title' ? undefined : style?.fontSize,
justifyContent: style.textAlign,
},
style: {
...style,
color: contentType === 'custom' ? style.color : undefined,
// Title components use their own fontSize based on level prop
fontSize: textType === 'title' ? undefined : style?.fontSize,
textAlign: style.textAlign,
},

@Tshepo1103-lab
Copy link
Copy Markdown
Contributor Author

#3987

@James-Baloyi James-Baloyi merged commit 77ee372 into shesha-io:main Apr 4, 2025
2 of 4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 23, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jul 17, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jul 29, 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