Skip to content
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

Wired up visibility settings for CTA card #1440

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

kevinansfield
Copy link
Member

closes https://linear.app/ghost/issue/PLG-332

  • added useVisibilityToggle hook to <CallToActionNodeComponent>
  • passed toggleVisibility and visibilityOptions props from the hook through to <CtaCard> component ready for use by <VisibilitySettings>
  • replaced static visibility settings in <CtaCard> with <VisibilitySettings>
  • updated our insertCard e2e utility function to return a locator for the card making subsequent testing a little bit nicer

Copy link

coderabbitai bot commented Feb 6, 2025

Walkthrough

The pull request introduces several focused updates across components in the koenig-lexical package. In the UI components, modifications include updating dependency arrays in effect hooks, adding data attributes for testing, and restructuring JSX for enhanced clarity. The CtaCard component now integrates a dedicated VisibilitySettings component, with corresponding adjustments to its prop types and function signatures to support new visibility management features. Additionally, a new hook, useVisibilityToggle, is incorporated to manage visibility options within the CallToActionNodeComponent, propagating these settings down to the CtaCard. Test files have been updated to validate the new visibility settings, and the e2e utility now returns inserted card locators for improved test interactions.

Possibly related PRs

Suggested reviewers

  • ronaldlangeveld

Poem

I'm a rabbit in the code field, hopping through the lines,
Carrots of new props, and toggles that shine,
Visibility now twinkles like stars in the night,
With each test passing, everything feels just right,
ASCII hops and joyful loops in every redefined line,
Celebrating changes in code – oh, how divine! 🐰✨

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/src/components/ui/TabView.jsx

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.

packages/koenig-lexical/src/components/ui/SettingsPanel.jsx

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.

packages/koenig-lexical/src/nodes/CallToActionNodeComponent.jsx

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.

  • 5 others

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

closes https://linear.app/ghost/issue/PLG-332

- added `useVisibilityToggle` hook to `<CallToActionNodeComponent>`
- passed `toggleVisibility` and `visibilityOptions` props from the hook through to `<CtaCard>` component ready for use by `<VisibilitySettings>`
- replaced static visibility settings in `<CtaCard>` with `<VisibilitySettings>`
- updated our `insertCard` e2e utility function to return a locator for the card making subsequent testing a little bit nicer
@kevinansfield kevinansfield force-pushed the cta-visibility-settings branch from fc61c18 to 8ce0616 Compare February 6, 2025 17:28
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 (4)
packages/koenig-lexical/src/components/ui/cards/CtaCard.jsx (2)

237-244: Consider improving the alt text for better accessibility.

The current alt text "Placeholder" is generic. Consider making it more descriptive or dynamic based on the image content.

-                alt="Placeholder"
+                alt={`CTA card ${layout} image`}

269-280: Consider enhancing button accessibility.

The button could benefit from additional ARIA attributes for better screen reader support.

                                <Button
                                    color={'accent'}
                                    dataTestId="cta-button"
                                    placeholder="Add button text"
+                                   aria-label={buttonText || "Call to action button"}
+                                   role="link"
+                                   aria-haspopup="false"
                                    size={layout === 'immersive' ? 'medium' : 'small'}
                                    style={buttonColor ? {
                                        backgroundColor: buttonColor === 'accent' ? 'var(--accent-color)' : buttonColor,
                                        color: buttonTextColor
                                    } : undefined}
                                    value={buttonText}
                                    width={layout === 'immersive' ? 'full' : 'regular'}
                                />
packages/koenig-lexical/test/e2e/cards/cta-card.test.js (2)

369-402: Consider adding edge case tests for visibility settings.

While the current test is thorough, consider adding tests for:

  • Toggling all settings off and verifying the card's behavior
  • Testing visibility inheritance from parent elements
  • Testing visibility changes during card duplication

404-442: Consider adding error case tests for serialized visibility settings.

The test covers the happy path well. Consider adding tests for:

  • Invalid visibility settings in serialized data
  • Missing visibility settings
  • Malformed visibility data structure
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fc61c18 and 8ce0616.

📒 Files selected for processing (8)
  • packages/koenig-lexical/src/components/ui/SettingsPanel.jsx (1 hunks)
  • packages/koenig-lexical/src/components/ui/TabView.jsx (2 hunks)
  • packages/koenig-lexical/src/components/ui/VisibilitySettings.jsx (1 hunks)
  • packages/koenig-lexical/src/components/ui/cards/CtaCard.jsx (8 hunks)
  • packages/koenig-lexical/src/nodes/CallToActionNodeComponent.jsx (3 hunks)
  • packages/koenig-lexical/src/nodes/HtmlNodeComponent.jsx (2 hunks)
  • packages/koenig-lexical/test/e2e/cards/cta-card.test.js (3 hunks)
  • packages/koenig-lexical/test/utils/e2e.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/koenig-lexical/src/components/ui/VisibilitySettings.jsx
  • packages/koenig-lexical/src/components/ui/TabView.jsx
  • packages/koenig-lexical/src/components/ui/SettingsPanel.jsx
  • packages/koenig-lexical/src/nodes/HtmlNodeComponent.jsx
  • packages/koenig-lexical/test/utils/e2e.js
  • packages/koenig-lexical/src/nodes/CallToActionNodeComponent.jsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Node 20.11.1
🔇 Additional comments (3)
packages/koenig-lexical/src/components/ui/cards/CtaCard.jsx (2)

11-11: LGTM! Visibility settings integration looks good.

The new props and imports are correctly added to support visibility settings functionality.

Also applies to: 76-77, 86-87, 329-330


91-94: LGTM! Settings panel integration is well-structured.

The visibility settings are cleanly integrated into a dedicated tab, following good separation of concerns.

Also applies to: 198-203, 296-299

packages/koenig-lexical/test/e2e/cards/cta-card.test.js (1)

19-32: LGTM! Test data setup is comprehensive.

The serialized test card includes all necessary properties for thorough testing.

@kevinansfield kevinansfield merged commit 1396afb into TryGhost:main Feb 6, 2025
2 checks passed
@kevinansfield kevinansfield deleted the cta-visibility-settings branch February 6, 2025 19:40
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