Skip to content

Added setting for link color to CTA card #1477

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

Merged
merged 7 commits into from
Mar 17, 2025
Merged

Added setting for link color to CTA card #1477

merged 7 commits into from
Mar 17, 2025

Conversation

sanne-san
Copy link
Member

Ref https://linear.app/ghost/issue/PLG-377/add-link-color-setting

  • Switched from two to three tabs in the settings panel, to make the settings easier to digest.
  • Added link color setting to the CTA card settings panel that allows switching between the default text color and the site accent color.

Ref https://linear.app/ghost/issue/PLG-377/add-link-color-setting
- Switched from two to three tabs in the settings panel, to make the settings easier to digest.
- Added link color setting to the CTA card settings panel that allows switching between the default text color and the site accent color.
Copy link

coderabbitai bot commented Mar 13, 2025

Walkthrough

The changes introduce a new configurable property, linkColor, with a default value of 'text', into multiple components related to call-to-action functionality. In the CallToActionNode class, this property is added to the properties array without affecting existing configurations. The CallToActionCard component is refactored to replace a static theme object with a new getTheme function that tailors its output based on the provided linkColor. A new constant, callToActionLinkColorPicker, is exported for managing link color options. Additionally, the CallToActionNodeComponent now accepts the linkColor prop and incorporates a new handler, handleLinkColorChange, to update the property dynamically. A visual spacing change is also applied in the TabView component, reducing gap spacing from gap-5 to gap-3. Lastly, obsolete CSS classes for CTA link styling have been removed.

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/koenig-lexical/test/e2e/cards/call-to-action-card.test.js

Oops! Something went wrong! :(

ESLint: 8.57.0

ESLint couldn't find the config "react-app" to extend from. Please check that the name of the config is correct.

The config "react-app" was referenced from the config file in "/packages/koenig-lexical/.eslintrc.cjs".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ 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 configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/kg-default-nodes/lib/nodes/call-to-action/calltoaction-renderer.js (1)

215-216: Consider adding validation for the linkColor property

While the linkColor property has been correctly added to the dataset object, there's no validation for it unlike buttonColor and backgroundColor which have validation checks. Consider adding validation to ensure only valid values ('text' or 'accent') are used.

 // Add validation for backgroundColor
 
 if (!dataset.backgroundColor || !dataset.backgroundColor.match(/^[a-zA-Z\d-]+|#([a-fA-F\d]{3}|[a-fA-F\d]{6})$/)) {
     dataset.backgroundColor = 'white';
 }
+
+// Add validation for linkColor
+if (!dataset.linkColor || !['text', 'accent'].includes(dataset.linkColor)) {
+    dataset.linkColor = 'text';
+}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2cfead6 and 9fa1cbb.

📒 Files selected for processing (1)
  • packages/kg-default-nodes/lib/nodes/call-to-action/calltoaction-renderer.js (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Node 20.11.1
🔇 Additional comments (2)
packages/kg-default-nodes/lib/nodes/call-to-action/calltoaction-renderer.js (2)

26-26: Good implementation of conditional class for link color styling

The addition of the kg-cta-link-accent class when linkColor is set to 'accent' follows the existing pattern of conditional classes in the template. This allows for proper styling of links within the CTA card based on user preference.


180-180: Consistent implementation across template variants

The same conditional class has been correctly added to the email template, ensuring consistent styling behavior across both web and email renderings of the CTA card. This is a good practice for maintaining visual consistency.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/koenig-lexical/src/styles/components/koenig-lexical.css (1)

6-8: New Rule for CTA Link Color Styling

The rule for .koenig-lexical .cta-link-color applies color: var(--cta-link-color) !important; to ensure that CTA link colors are enforced. While the use of !important guarantees priority, please confirm that this approach does not conflict with other styling rules in the application.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6fab0b2 and 146d255.

📒 Files selected for processing (6)
  • packages/koenig-lexical/src/components/ui/ButtonGroupBeta.jsx (2 hunks)
  • packages/koenig-lexical/src/components/ui/ColorOptionButtonsBeta.jsx (1 hunks)
  • packages/koenig-lexical/src/components/ui/ColorPickerBeta.jsx (3 hunks)
  • packages/koenig-lexical/src/components/ui/TabView.jsx (2 hunks)
  • packages/koenig-lexical/src/components/ui/cards/CallToActionCard.jsx (10 hunks)
  • packages/koenig-lexical/src/styles/components/koenig-lexical.css (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/koenig-lexical/src/components/ui/TabView.jsx
  • packages/koenig-lexical/src/components/ui/cards/CallToActionCard.jsx
🔇 Additional comments (10)
packages/koenig-lexical/src/components/ui/ColorOptionButtonsBeta.jsx (2)

34-34: Consistent dark mode styling for color selection indicator

This change adds proper dark mode styling for the color selection indicator by using dark:border-grey-950 class, ensuring the border is visible against the dark background.


40-40: Consistent dark mode background for popover

Using dark:bg-grey-900 for the color options popover ensures consistent styling with other popover components in dark mode. This change improves visual consistency across the UI.

packages/koenig-lexical/src/components/ui/ButtonGroupBeta.jsx (2)

10-10: Improved dark mode styling for button group container

The addition of dark:bg-grey-900 class ensures the button group container has appropriate background styling in dark mode, consistent with the project's dark theme implementation.


39-39: Enhanced active button styling in dark mode

The updated class string properly styles active buttons in dark mode by removing dark:hover:bg-grey-900 and adding dark:border-grey-800 dark:bg-grey-950. This creates better visual distinction for active states in dark mode.

packages/koenig-lexical/src/components/ui/ColorPickerBeta.jsx (3)

205-206: Consistent color indicator border in dark mode

Adding dark:border-grey-950 ensures the color indicator has appropriate contrast against dark backgrounds, matching the styling used in other color selection components.


221-222: Standardized dark mode background for color picker popover

Changing to dark:bg-grey-900 for the popover background standardizes the dark mode styling across all popovers in the application, improving UI consistency.


274-275: Consistent dark mode styling for custom color indicator

Adding dark:border-grey-950 to this span element ensures consistent styling with the other color indicator elements in dark mode.

packages/koenig-lexical/src/styles/components/koenig-lexical.css (3)

3-4: CSS Variable Addition for Light Mode CTA Link Color

The addition of --cta-link-color-text: var(--grey-900); on lines 3–4 sets the default text color for CTA links in light mode. This aligns well with the new configurable link color setting introduced in the PR.


46-47: Dark Mode Variable Update for CTA Link Color

Setting --cta-link-color-text: var(--grey-200); on lines 46–47 correctly adjusts the CTA link text color for dark mode. This update is consistent with maintaining good contrast in dark mode themes.


127-132: CTA Card Underline for Links

The new rule for .koenig-lexical-cta-label a (lines 127–132) adds an underline to links within CTA cards, enhancing visual distinction. This change supports the PR’s objective of offering customizable link color settings and styling.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/koenig-lexical/test/e2e/cards/call-to-action-card.test.js (2)

319-335: Consider verifying additional image attributes
The test reliably checks that the preview image appears. For more thorough coverage, you could also confirm attributes like alt text or verify dimensions.


366-390: Robust background color tests
Looping through color configurations ensures broad validation. Consider a parameterized test if your test framework supports it for easier maintenance.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6ba7750 and 0bd8ae7.

📒 Files selected for processing (1)
  • packages/koenig-lexical/test/e2e/cards/call-to-action-card.test.js (3 hunks)
🔇 Additional comments (10)
packages/koenig-lexical/test/e2e/cards/call-to-action-card.test.js (10)

122-128: Tests confirm default visibility of button settings
These assertions comprehensively validate that button-related elements are visible by default and properly initialized.


348-348: Design tab click aligns with updated UI
Navigating to the newly introduced design tab is consistent with the PR’s objective of expanding settings options.


357-357: Tab usage is consistent
Switching to the design tab again ensures consistent UI interaction. No issues found.


392-406: Effective popup dismissal check
Verifying the color picker closes on outside click adds valuable coverage for user interactions.


408-429: Comprehensive link color checks
Confirming default and accent color changes via getComputedStyle is an effective approach. Great coverage for the new linkColor feature.


431-435: Verifies accent color as default
Ensuring the button defaults to the site’s accent color matches the intended design.


437-444: Testing black button color
Shows that the button color can be toggled away from accent. Implementation looks correct.


446-453: Verifies grey button color
This test ensures additional styling flexibility. No issues detected.


455-461: Color picker usage is validated
Good approach verifying custom color changes. The helper utility keeps the test concise.


463-475: Button text color updates alongside background
Checking style attributes effectively confirms dynamic text color changes. This is thorough coverage of the styling logic.

@kevinansfield kevinansfield merged commit 4784787 into main Mar 17, 2025
3 checks passed
@kevinansfield kevinansfield deleted the link-color branch March 17, 2025 19:58
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