Fade out the last visible paragraph on access-restricted posts#71
Conversation
…d posts Uses a CSS mask gradient on the last <p> child of .gh-content, scoped via :has() to only apply when a .gh-post-upgrade-cta sibling is present. This gives readers a visual cue that the article continues beyond the preview, a common pattern on paywalled content (Medium, Substack, NYT…). No HTML changes, no new files.
4f5de34 to
cb33a42
Compare
WalkthroughAdded a CSS rule that targets the last paragraph of content blocks containing an upgrade CTA element. The rule applies a linear gradient mask that fades the paragraph out from bottom to top, creating a visual indicator of truncated content for access-restricted previews. Both vendor-prefixed ( Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@assets/css/screen.css`:
- Around line 2274-2275: The mask gradient on the paragraph is starting at 1%
which fades almost the entire block; update the mask declarations
(-webkit-mask-image and mask-image) to begin the opaque region much lower (e.g.,
change the first color stop from 1% to around 50–70%) so the majority of the
paragraph remains fully readable while only the final portion fades to
transparent; locate the two properties in the CSS and adjust the first stop
percentage to ~60% (or your desired 50–70% value).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 728c61f5-2f07-4a8c-b288-4d11a32b5ef2
⛔ Files ignored due to path filters (1)
assets/built/screen.css.mapis excluded by!**/*.map
📒 Files selected for processing (2)
assets/built/screen.cssassets/css/screen.css
| -webkit-mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%); | ||
| mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%); |
There was a problem hiding this comment.
The gradient starts too early, potentially making most of the paragraph unreadable.
The gradient begins at 1% opacity, meaning 99% of the paragraph's height will fade from opaque to transparent. For a typical paragraph of 5-10 lines, most of the text will be partially transparent or invisible, severely impacting readability. Consider starting the fade at a higher percentage (e.g., 50-70%) to keep more of the paragraph legible while still providing the visual cue that content continues.
🎨 Suggested gradient adjustment
-.gh-content:has(> .gh-post-upgrade-cta) > p:last-of-type {
- -webkit-mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%);
- mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%);
-}
+.gh-content:has(> .gh-post-upgrade-cta) > p:last-of-type {
+ -webkit-mask-image: linear-gradient(to bottom, var(--color-black) 60%, transparent 100%);
+ mask-image: linear-gradient(to bottom, var(--color-black) 60%, transparent 100%);
+}📝 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.
| -webkit-mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%); | |
| mask-image: linear-gradient(to bottom, var(--color-black) 1%, transparent 100%); | |
| -webkit-mask-image: linear-gradient(to bottom, var(--color-black) 60%, transparent 100%); | |
| mask-image: linear-gradient(to bottom, var(--color-black) 60%, transparent 100%); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@assets/css/screen.css` around lines 2274 - 2275, The mask gradient on the
paragraph is starting at 1% which fades almost the entire block; update the mask
declarations (-webkit-mask-image and mask-image) to begin the opaque region much
lower (e.g., change the first color stop from 1% to around 50–70%) so the
majority of the paragraph remains fully readable while only the final portion
fades to transparent; locate the two properties in the CSS and adjust the first
stop percentage to ~60% (or your desired 50–70% value).
Problem
When a visitor lands on an access-restricted post (members-only, paid, tiers), Ghost truncates the content and renders a CTA below it. Currently the truncated paragraph ends abruptly with no visual signal that more content is hidden.
Solution
A single CSS rule that fades out the last visible paragraph via a mask gradient, scoped strictly to restricted posts (those that contain a
.gh-post-upgrade-ctaelement) using the:has()selector.Why this approach
.gh-post-upgrade-ctaexists as a direct child of.gh-content.Browser support
Uses CSS
:has()andmask-image. Both are supported in all major browsers since 2023::has(): Chrome 105+, Safari 15.4+, Firefox 121+mask-image: universalOverall browser support in late 2026 is ~98%. Visitors on older browsers see the truncated content normally — graceful degradation, no broken layout.
Opt-out
Theme overriders or end users who don't want this effect can disable it with:
Replaces previous attempt
This PR was previously a partial-based implementation with several issues (broken file extension, duplicated content, malformed HTML, no i18n). It has been rewritten with the much cleaner CSS-only approach above.