Skip to content

Fixed responsive styles for CTA card frontend rendering#22210

Merged
sanne-san merged 3 commits intomainfrom
cta-frontend-tweaks
Feb 19, 2025
Merged

Fixed responsive styles for CTA card frontend rendering#22210
sanne-san merged 3 commits intomainfrom
cta-frontend-tweaks

Conversation

@sanne-san
Copy link
Contributor

Ref https://linear.app/ghost/issue/PLG-337/create-cta-card-web-design

  • The minimal layout version now changes to a column layout on mobile
  • The sponsor label color now inherits the theme color so that it works on any background color
  • The spacing is adjusted for mobile

Ref https://linear.app/ghost/issue/PLG-337/create-cta-card-web-design
- The minimal layout version now changes to a column layout on mobile
- The sponsor label color now inherits the theme color so that it works on any background color
- The spacing is adjusted for mobile
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Walkthrough

The pull request introduces several styling updates to the CTA card CSS file. It modifies the background color of the .kg-cta-bg-grey class and changes the text color for the .kg-cta-sponsor-label a class to currentColor. New media queries have been added for screen widths of 600px or less, which adjust layout properties such as margins, padding, and image sizes for classes including .kg-cta-sponsor-label, .kg-cta-content, and .kg-cta-minimal .kg-cta-image-container img. Additionally, the .kg-cta-text p class now includes a text-wrap: pretty; property, and a new style rule is introduced for .kg-cta-sponsor-label p span:not(a span). These changes enhance the responsiveness and visual consistency of the CTA card styles without altering any exported or public entity declarations.

Possibly related PRs

  • Updated CTA card bg and link styles #22207: This PR modifies the styling of the .kg-cta-sponsor-label a class, which is relevant to the changes in the main pull request.
  • Added frontend styles for CTA card #22163: The changes in the main PR for the .kg-cta-sponsor-label and other CTA-related classes are directly related to the modifications in this PR, which also involves styling for CTA components, specifically the .kg-cta-card.
  • Added email styles for CTA card #22167: The changes in the main PR are related to the modifications of the .kg-cta-sponsor-label class and the .kg-cta-bg-grey background color, which are also addressed in this PR's updates to the same classes.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 01d1fb3 and 0a1238f.

⛔ Files ignored due to path filters (3)
  • ghost/core/test/e2e-api/admin/__snapshots__/email-previews.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/integration/services/email-service/__snapshots__/batch-sending.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/integration/services/email-service/__snapshots__/cards.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • ghost/core/core/frontend/src/cards/css/cta.css (5 hunks)
  • ghost/email-service/lib/email-templates/partials/styles.hbs (13 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • ghost/core/core/frontend/src/cards/css/cta.css
  • ghost/email-service/lib/email-templates/partials/styles.hbs
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (2)
ghost/core/core/frontend/src/cards/css/cta.css (2)

53-54: Addition of text-wrap: pretty; to Sponsor Label
The property text-wrap: pretty; has been added to .kg-cta-sponsor-label, likely intended to improve text wrapping aesthetics. Since this property is still experimental, please verify browser support and consider adding a fallback if necessary.


67-71: New Color Mix Rule for Nested Sponsor Label Text
A new rule for .kg-cta-sponsor-label p span:not(a span) leverages the CSS color-mix function to blend currentColor with transparency. This enhances visual integration, but please verify that the color-mix(in srgb, currentColor 40%, transparent) function is supported by all target browsers or consider adding a fallback.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cb0fe4b and f3bf9e0.

📒 Files selected for processing (1)
  • ghost/core/core/frontend/src/cards/css/cta.css (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
🔇 Additional comments (8)
ghost/core/core/frontend/src/cards/css/cta.css (8)

12-14: CTA Background Color Update
The background color for .kg-cta-bg-grey has been updated to rgba(151, 163, 175, 0.14), which gives the card a refreshed tone. Please verify that this new color harmonizes well with the overall theme and design system.


56-60: Responsive Spacing for Sponsor Label
The media query for screens with a maximum width of 600px now adjusts the margin and padding for .kg-cta-sponsor-label. This change should enhance readability and layout consistency on mobile devices.


72-74: Consistent Color Inheritance for Sponsor Label Links
The color for .kg-cta-sponsor-label a is now set to currentColor, which ensures that link colors inherit from their parent element. This change contributes to a consistent theming approach across the CTA card.


82-87: Improved Mobile Spacing for CTA Content
A media query targeting screens ≤600px adjusts the padding and gap of .kg-cta-content to 2rem each. This update enhances content spacing and overall mobile responsiveness.


94-98: Responsive Padding for .kg-cta-bg-none .kg-cta-content
The media query now sets the padding of .kg-cta-bg-none .kg-cta-content to 2rem 0 on mobile devices, which should provide a cleaner and more cohesive layout.


104-109: Responsive Layout for Minimal CTA Content
For screens ≤600px, the .kg-cta-minimal .kg-cta-content is adjusted to a column layout with a gap of 1.6rem. This change aligns with responsive design best practices by ensuring content stacks neatly on smaller devices.


121-125: Adjusted Gap in Inner CTA Content for Mobile
The media query for .kg-cta-content-inner reduces the gap to 2rem on mobile, which helps maintain a balanced vertical spacing within the card.


142-147: Reduced Image Size for Minimal CTA on Mobile
Within a media query for screens with a maximum width of 600px, the image in .kg-cta-minimal .kg-cta-image-container is resized to 52px by 52px. This reduction is likely intended to maintain visual proportionality in compact layouts. Please ensure that the smaller images remain clear and effective on mobile devices.

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

🧹 Nitpick comments (1)
ghost/email-service/lib/email-templates/partials/styles.hbs (1)

1057-1060: Document the reason for style duplication.

The styles here are duplicated from the button container styles above. While this might be necessary for email client compatibility, it would be helpful to add a comment explaining why this duplication is needed.

Add a comment explaining the necessity of style duplication:

+/* Duplicate styles from container for email client compatibility */
 .kg-cta-immersive a.kg-cta-button.kg-style-accent {
     background-color: {{accentColor}} !important;
     color: #fff !important;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f3bf9e0 and 01d1fb3.

📒 Files selected for processing (1)
  • ghost/email-service/lib/email-templates/partials/styles.hbs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Ghost-CLI tests
  • GitHub Check: Regression tests (Node 20.11.1, sqlite3)
  • GitHub Check: Database tests (Node 20.11.1, sqlite3)
  • GitHub Check: Regression tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 20.11.1, mysql8)
  • GitHub Check: Database tests (Node 18.12.1, mysql8)
  • GitHub Check: Unit tests (Node 20.11.1)
  • GitHub Check: Unit tests (Node 18.12.1)
  • GitHub Check: Lint
  • GitHub Check: i18n
🔇 Additional comments (2)
ghost/email-service/lib/email-templates/partials/styles.hbs (2)

1052-1055: LGTM! Consistent implementation with minimal CTA styles.

The accent style for the immersive CTA button container follows the same pattern as the minimal CTA styles, which is good for maintainability.


1031-1034:

Details

✅ Verification successful

LGTM! Ensure color contrast meets WCAG guidelines.

The accent style for minimal CTA buttons is well-implemented. The use of !important is appropriate for email templates.

Please verify that the accent color provides sufficient contrast with white text using the following script:


🏁 Script executed:

#!/bin/bash
# Description: Check color contrast ratio between accent color and white text.
# Note: This script assumes the accent color is defined in a config file.

# Search for accent color definition
rg -A 1 'accentColor.*=.*#[0-9a-fA-F]{6}'

Length of output: 11393


Approval: Minimal CTA accent style verified.
The accent style for minimal CTA buttons in ghost/email-service/lib/email-templates/partials/styles.hbs (lines 1031–1034) is well-implemented. Using {{accentColor}} for the background and #fff for the text provides excellent contrast—as confirmed by the configuration, which defaults to #15212A in multiple email templates. This strong contrast should satisfy WCAG guidelines, and the use of !important is appropriate for email client consistency.

@sanne-san sanne-san enabled auto-merge (squash) February 19, 2025 10:15
@sanne-san sanne-san merged commit 31bb7d1 into main Feb 19, 2025
24 checks passed
@sanne-san sanne-san deleted the cta-frontend-tweaks branch February 19, 2025 10:36
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.

1 participant