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

fix-#275: Fixed the redirect icon color to match theme #345

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions frontend/src/components/latest-post-card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useNavigate } from 'react-router-dom';
import linkIcon from '@/assets/svg/link.svg';
// import linkIcon from '@/assets/svg/link.svg';
import Post from '@/types/post-type';
Copy link
Owner

Choose a reason for hiding this comment

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

Kindly remove the comments, never have code comments in the PR

Copy link
Author

Choose a reason for hiding this comment

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

Will remove the comments

Copy link
Owner

Choose a reason for hiding this comment

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

You have not yet removed @Ashu0216

import formatPostTime from '@/utils/format-post-time';
import CategoryPill from '@/components/category-pill';
Expand All @@ -24,7 +24,14 @@ export default function LatestPostCard({
<CategoryPill key={`${category}-${index}`} category={category} />
))}
</div>
<img src={linkIcon} alt={post.title} className="h-3 w-3" />
{/* <img src={linkIcon} alt={post.title} className="h-3 w-3" /> */}
<svg
Copy link
Owner

Choose a reason for hiding this comment

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

Same here

Copy link
Author

Choose a reason for hiding this comment

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

Will remove the comments

Copy link
Owner

Choose a reason for hiding this comment

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

same

xmlns="http://www.w3.org/2000/svg"
Copy link
Owner

Choose a reason for hiding this comment

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

Instead of embedding this as a svg, create file and import from there, like the existing linkIcon.
Ideally rename the existing linkIcon to link-light-icon and have a new one link-dark-icon

Copy link
Author

Choose a reason for hiding this comment

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

  1. I did try having it in assets itself, but the classes that I added on the svg were not reflecting the color on UI. I also did try to change the img styling but didnt seem to work .So I referred the tailwind Doc and therefore did it this way.
    Here is the method I followed : SVGstyling.

  2. Yes, ideally it should be two different SVGs (one for light and another for dark theme). But then this would involve lifting up the state from Toggle > Header > Home page and then passing it down till LatestPostCard. Hence I thought instead of unncessary passing of state we could use svg properties to deal with this.

Copy link
Author

Choose a reason for hiding this comment

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

I can give containing SVG in assests and use it like the previous embedded linkIcon one more try.

Copy link
Owner

Choose a reason for hiding this comment

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

We don't prefer embedding and about the 2nd point
Just use this hook useThemeClass from utils

And conditionally rendor light and dark svg

Copy link
Author

Choose a reason for hiding this comment

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

Hi @krishnaacharyaa , I tried adopting this approach, added two separate svgs and conditionally rendered them using the useThemeClass.
But there is an issue in this, the theme is not updated dynamically when the theme-toggle-button updates the theme. As a solution , I would propose that we can use ThemeContext which would define the theme for the entire app. And accordingly modify the theme-toggle component ti use the method of ThemeContext to update the theme which can then be accessed by any children component.

Copy link
Owner

Choose a reason for hiding this comment

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

We can't use context api, as it renders every component beneath, we can use zustand state management instead, if you can stick to the contributing guidelines and do nice refactoring @Ashu0216

Copy link
Author

Choose a reason for hiding this comment

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

Sure, will try to utilize zutsand, and will keep you updated of the progress @krishnaacharyaa

className="text-primary h-3 w-3 fill-current dark:text-dark-primary"
viewBox="0 0 515.283 515.283"
>
<path d="M372.149 515.283H85.881c-22.941 0-44.507-8.934-60.727-25.155S.001 452.34.001 429.402V143.134c0-22.94 8.934-44.506 25.154-60.726s37.786-25.154 60.727-25.154h114.507c15.811 0 28.627 12.816 28.627 28.627s-12.816 28.627-28.627 28.627H85.881c-7.647 0-14.835 2.978-20.241 8.384s-8.385 12.595-8.385 20.242v286.268c0 7.647 2.978 14.835 8.385 20.243 5.406 5.405 12.594 8.384 20.241 8.384h286.267c7.647 0 14.835-2.978 20.242-8.386 5.406-5.406 8.384-12.595 8.384-20.242V314.895c0-15.811 12.817-28.626 28.628-28.626s28.628 12.816 28.628 28.626v114.507c0 22.94-8.934 44.505-25.155 60.727-16.221 16.22-37.788 25.154-60.726 25.154zm-171.76-171.762c-7.327 0-14.653-2.794-20.242-8.384-11.179-11.179-11.179-29.306 0-40.485L417.544 57.254H314.896c-15.811 0-28.626-12.816-28.626-28.627S299.085 0 314.896 0h171.761a28.542 28.542 0 0 1 19.997 8.144l.002.002.056.056.017.016.044.044.029.029.032.032.062.062.062.062.031.032.029.029a.62.62 0 0 1 .06.061l.056.057.002.002a28.55 28.55 0 0 1 8.144 19.998v171.761c0 15.811-12.817 28.627-28.628 28.627s-28.626-12.816-28.626-28.627V97.739l-237.4 237.399c-5.585 5.59-12.911 8.383-20.237 8.383z" />
Copy link
Owner

Choose a reason for hiding this comment

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

I see the icon is just replaced, How will it be different based on the theme?

Copy link
Author

Choose a reason for hiding this comment

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

I have added the fill current class to the svg with the colors mentioned for both light and dark theme (referenced the figma desgin for the required colors) that will make the color change whenever the theme changes.

</svg>
</div>
<div className="mb-2 line-clamp-1 font-semibold text-light-title dark:text-dark-title">
{post.title}
Expand Down
Loading