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

chore: Update dark theme logos styling (Fixes #1209) #1213

Merged
merged 6 commits into from
Jul 26, 2024

Conversation

rahulharpal1603
Copy link
Contributor

@rahulharpal1603 rahulharpal1603 commented Jul 23, 2024

This PR fixes the Issue #1209. Now, when you toggle dark mode on the page, the GitHub and Algolia logos adapt to the change in background colour:

Demo Video: https://streamable.com/79bbls

Before:
image

After:
image

Before:
image

After:
image

Summary by CodeRabbit

  • New Features

    • Introduced conditional styling for SVG elements in the HomepageFeatures and HomepageSponsored components, allowing for dark mode adaptability.
  • Style

    • Added new styles for SVGs in dark mode, improving contrast and visibility for a better user experience.

Copy link

coderabbitai bot commented Jul 23, 2024

Walkthrough

The changes enhance the HomepageFeatures and HomepageSponsored components by introducing an optional allowsDarkMode property. This allows for conditional styling of SVG elements, improving contrast and visibility in dark mode. These updates ensure a more adaptable and user-friendly experience, particularly for logos like GitHub and Algolia, making the components visually appealing across different themes.

Changes

Files Change Summary
docs/src/components/HomepageFeatures/index.tsx
docs/src/components/HomepageSponsored/index.tsx
Added allowsDarkMode property to FeatureItem type, enabling dynamic class assignment for SVGs based on dark mode.
docs/src/components/HomepageFeatures/styles.module.css
docs/src/components/HomepageSponsored/styles.module.css
Implemented .svgDarkMode CSS rule to change SVG fill color to white in dark mode, enhancing visibility and aesthetics.
docs/src/components/AdsContainer/styles.css
docs/src/components/BannerSponsor/styles.css
Minor formatting changes by adding newlines at the end of CSS files for improved coding standards.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Homepage
    participant Feature
    participant SVG

    User->>Homepage: Visit homepage
    Homepage->>Feature: Render features
    Feature->>SVG: Check allowsDarkMode
    alt Dark mode enabled
        Feature->>SVG: Assign svgClassName with dark mode styling
    else Light mode
        Feature->>SVG: Assign svgClassName with default styling
    end
    SVG->>Feature: Render SVG with svgClassName
    Feature->>Homepage: Display features
Loading

Poem

🐇 In the digital garden, colors bloom bright,
SVGs dance and twinkle in the soft night light.
GitHub and Algolia, in shadows they play,
With a splash of white magic, they brighten the day!
Hopping through code, we make it all right,
For a theme that's delightful, a true coding delight! 🌙✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@rahulharpal1603
Copy link
Contributor Author

@gabrieljablonski Please review

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 143221a and adf7836.

Files ignored due to path filters (1)
  • docs/static/img/Algolia-logo.svg is excluded by !**/*.svg
Files selected for processing (4)
  • docs/src/components/HomepageFeatures/index.tsx (1 hunks)
  • docs/src/components/HomepageFeatures/styles.module.css (1 hunks)
  • docs/src/components/HomepageSponsored/index.tsx (1 hunks)
  • docs/src/components/HomepageSponsored/styles.module.css (1 hunks)
Files skipped from review due to trivial changes (1)
  • docs/src/components/HomepageSponsored/styles.module.css
Additional comments not posted (3)
docs/src/components/HomepageFeatures/styles.module.css (1)

13-15: LGTM!

The new CSS rule correctly targets the .githubLogo for dark theme and ensures better contrast and visibility.

docs/src/components/HomepageFeatures/index.tsx (1)

45-49: LGTM!

The changes correctly implement conditional styling for the GitHub logo based on the Svg prop. The logic for matching the GitHub logo and applying the class names is sound.

Also applies to: 53-53

docs/src/components/HomepageSponsored/index.tsx (1)

54-58: LGTM!

The changes correctly implement conditional styling for the Algolia logo based on the Svg prop. The logic for matching the Algolia logo and applying the class names is sound.

Also applies to: 63-63

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between adf7836 and 9db6838.

Files selected for processing (2)
  • docs/src/components/HomepageFeatures/index.tsx (1 hunks)
  • docs/src/components/HomepageSponsored/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • docs/src/components/HomepageFeatures/index.tsx
  • docs/src/components/HomepageSponsored/index.tsx

Copy link
Member

@gabrieljablonski gabrieljablonski left a comment

Choose a reason for hiding this comment

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

Looks mostly good, but please see the suggested changes.

They're mostly the result of running yarn run prettier docs/src, so the code style matches our eslint rules, but I've also renamed classVar to svgClassName for clarity.

docs/src/components/HomepageFeatures/index.tsx Outdated Show resolved Hide resolved
docs/src/components/HomepageFeatures/index.tsx Outdated Show resolved Hide resolved
docs/src/components/HomepageFeatures/styles.module.css Outdated Show resolved Hide resolved
docs/src/components/HomepageSponsored/index.tsx Outdated Show resolved Hide resolved
docs/src/components/HomepageSponsored/index.tsx Outdated Show resolved Hide resolved
docs/src/components/HomepageSponsored/styles.module.css Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Could you please explain why changing the SVG was needed?

Copy link
Contributor Author

@rahulharpal1603 rahulharpal1603 Jul 24, 2024

Choose a reason for hiding this comment

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

Yes, I changed a code inside svg which controlled the fill colour of the logo. That part was preventing the change of fill colour using CSS property: "fill: #000"

So, I removed the following part from it:
<style>.cls-1,.cls-2{fill:#000;}.cls-2{fill-rule:evenodd;}</style>

Co-authored-by: Gabriel Jablonski <gabriel.g.jablonski@gmail.com>
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9db6838 and 9de0343.

Files selected for processing (4)
  • docs/src/components/HomepageFeatures/index.tsx (1 hunks)
  • docs/src/components/HomepageFeatures/styles.module.css (1 hunks)
  • docs/src/components/HomepageSponsored/index.tsx (1 hunks)
  • docs/src/components/HomepageSponsored/styles.module.css (1 hunks)
Files skipped from review due to trivial changes (1)
  • docs/src/components/HomepageSponsored/styles.module.css
Files skipped from review as they are similar to previous changes (3)
  • docs/src/components/HomepageFeatures/index.tsx
  • docs/src/components/HomepageFeatures/styles.module.css
  • docs/src/components/HomepageSponsored/index.tsx

Copy link
Member

@gabrieljablonski gabrieljablonski left a comment

Choose a reason for hiding this comment

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

Please try applying this patch for an alternative instead of checking for exactly the github and algolia logos.

https://gist.github.com/gabrieljablonski/ff6371cc273b17521f27b86630ead4aa

See if you have any suggestions.

@rahulharpal1603
Copy link
Contributor Author

Please try applying this patch for an alternative instead of checking for exactly the github and algolia logos.

https://gist.github.com/gabrieljablonski/ff6371cc273b17521f27b86630ead4aa

See if you have any suggestions.

Yes, that idea is better. I will make these changes and get back to you.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9de0343 and 8e9115c.

Files selected for processing (4)
  • docs/src/components/HomepageFeatures/index.tsx (4 hunks)
  • docs/src/components/HomepageFeatures/styles.module.css (1 hunks)
  • docs/src/components/HomepageSponsored/index.tsx (3 hunks)
  • docs/src/components/HomepageSponsored/styles.module.css (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • docs/src/components/HomepageFeatures/index.tsx
  • docs/src/components/HomepageFeatures/styles.module.css
Additional comments not posted (5)
docs/src/components/HomepageSponsored/styles.module.css (1)

33-35: LGTM!

The new CSS rule correctly improves the visibility of SVG elements in dark mode.

docs/src/components/HomepageSponsored/index.tsx (4)

17-17: LGTM!

The addition of the allowsDarkMode property to the FeatureItem type is correctly typed.


34-34: LGTM!

The addition of the allowsDarkMode property to the Algolia entry in the FeatureList array is consistent with the objective of improving visibility in dark mode.


55-55: LGTM!

The Feature function is correctly updated to include the allowsDarkMode property in its parameters.


60-63: LGTM!

The SVG's class name is dynamically assigned using the clsx utility, combining the default featureSvg class with styles.svgDarkMode if allowsDarkMode is true.

@rahulharpal1603
Copy link
Contributor Author

@gabrieljablonski, I have now used an alternative approach that you suggested. Please review.

Copy link
Member

@gabrieljablonski gabrieljablonski left a comment

Choose a reason for hiding this comment

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

LGTM, but please run yarn run prettier docs/src/ as there are a few code-style issues.

Also waiting on @danielbarion to give a final word on this.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e9115c and 8053b9e.

Files selected for processing (4)
  • docs/src/components/AdsContainer/styles.css (1 hunks)
  • docs/src/components/BannerSponsor/styles.css (1 hunks)
  • docs/src/components/HomepageFeatures/index.tsx (4 hunks)
  • docs/src/components/HomepageSponsored/index.tsx (3 hunks)
Files skipped from review due to trivial changes (2)
  • docs/src/components/AdsContainer/styles.css
  • docs/src/components/BannerSponsor/styles.css
Files skipped from review as they are similar to previous changes (2)
  • docs/src/components/HomepageFeatures/index.tsx
  • docs/src/components/HomepageSponsored/index.tsx

Copy link
Member

@danielbarion danielbarion left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants