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: created a global mark as favorite component #4203

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

aaryan610
Copy link
Collaborator

What's new?

This PR creates a global mark as/remove from favorites component which can be reused everywhere.

Why was this needed?

  1. To enhance reusability.
  2. To maintain consistency, currently to depict whether something is favorite or not different colors are used in different places, cycles and modules use Amber, pages use Yellow, views use Orange.

Implementation

type Props = {
  buttonClassName?: string;
  iconClassName?: string;
  onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
  selected: boolean;
};

Props used-

  1. buttonClassName- To update the class name of the button containing the icon.
  2. iconClassName- To update the class name of the icon itself.
  3. onClick- Callback triggered on button click event.
  4. selected- Boolean to check whether the item is favorite or not.
<button type="button" className={cn("h-4 w-4 grid place-items-center", buttonClassName)} onClick={onClick}>
  <Star
    className={cn(
      "h-4 w-4 text-custom-text-300 transition-all",
      {
        "fill-yellow-500 stroke-yellow-500": selected,
      },
      iconClassName
    )}
  />
</button>

@sriramveeraghanta sriramveeraghanta merged commit 6eed2c2 into develop Apr 16, 2024
11 of 12 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore/favorite-component branch April 16, 2024 07:53
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