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

Card refactoring #76

Merged
merged 7 commits into from
Aug 21, 2021
Merged

Card refactoring #76

merged 7 commits into from
Aug 21, 2021

Conversation

marekrozmus
Copy link
Collaborator

@marekrozmus marekrozmus commented Aug 19, 2021

Please take a look if this looks OK.

Added also pending state:

pending_button

All proposals are welcome 🙂

Closes #63

@netlify
Copy link

netlify bot commented Aug 19, 2021

✔️ Deploy Preview for helpafamily-margarita-humanitarian ready!
Built without sensitive environment variables

🔨 Explore the source changes: cbc0179

🔍 Inspect the deploy log: https://app.netlify.com/sites/helpafamily-margarita-humanitarian/deploys/6120cd8366766a000846a6ad

😎 Browse the preview: https://deploy-preview-76--helpafamily-margarita-humanitarian.netlify.app

@marekrozmus marekrozmus marked this pull request as draft August 19, 2021 14:05
Copy link
Collaborator

@RedFox0x20 RedFox0x20 left a comment

Choose a reason for hiding this comment

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

Very nice refactor, simplifies the card creation process, reducing the need to rewrite the same sequences, dynamically chooses which parts of the card are needed based on what is provided.

A very good start, nice work!

addressLabel,
backgroundImageSource,
children,
text,
Copy link
Collaborator

@RedFox0x20 RedFox0x20 Aug 19, 2021

Choose a reason for hiding this comment

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

Perhaps text would be better named as description as the use case appears to be to describe the cause?

</button>
</div>
)}
{children}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure what your use case of children is expected to be when looking at other cards?

Except maybe to allow additional paragraphs and text objects such as in Health Education Workshop where there are two paragraphs. In which case maybe it is better placed before the action.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. I forgot about several paragraphs. Will redisign it tomorrow... Somehow ;)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds like a plan, a case of balancing ease of modification and not doing my usual trick of over-engineering everything haha!

@marekrozmus
Copy link
Collaborator Author

@RedFox0x20 What do you think about such component:

import Card, { CardAction, CardParagraph, CardTitle } from './Card';

function NewCard() {
  return (
    <Card backgroundImageSource="/images/HygieneKit.webp">
      <CardTitle>{'This is title'}</CardTitle>
      <CardParagraph>{'First one paragraph'}</CardParagraph>
      <CardParagraph>{'Second one paragraph'}</CardParagraph>
      <CardAction onClick={() => {}}>{'Action name'}</CardAction>
    </Card>
  );
}

?

@RedFox0x20
Copy link
Collaborator

RedFox0x20 commented Aug 19, 2021

@RedFox0x20 What do you think about such component:

import Card, { CardAction, CardParagraph, CardTitle } from './Card';

function NewCard() {
  return (
    <Card backgroundImageSource="/images/HygieneKit.webp">
      <CardTitle>{'This is title'}</CardTitle>
      <CardParagraph>{'First one paragraph'}</CardParagraph>
      <CardParagraph>{'Second one paragraph'}</CardParagraph>
      <CardAction onClick={() => {}}>{'Action name'}</CardAction>
    </Card>
  );
}

?

I like that a lot, very clear what's going on, hides all the specific details ensuring all cards will be the same style. Allows for elements to be in a different order if so desired which is nice.

@marekrozmus
Copy link
Collaborator Author

So far only two cards were reimplemented. If this is approved I will update others.

@marekrozmus marekrozmus marked this pull request as ready for review August 20, 2021 09:02
@audreyfeldroy
Copy link
Member

Thanks so much for your proposal @marekrozmus! I'm in meetings this morning but will review it ASAP today once I have the bandwidth to study it deeply.

@audreyfeldroy
Copy link
Member

I love this proposal. Strong 👍 on going forward. It's elegant, clean, and easy to understand. We can iterate as cards evolve. Thank you @marekrozmus for the proposal and @RedFox0x20 for the review.

@marekrozmus
Copy link
Collaborator Author

@audreyfeldroy all done - please review and merge if OK 🙂

Copy link
Member

@audreyfeldroy audreyfeldroy left a comment

Choose a reason for hiding this comment

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

All looks good, merging.

import React from 'react';
import { useRouter } from 'next/router';

const dollarsToCentsMultiplier = 100;
Copy link
Member

Choose a reason for hiding this comment

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

I like how you moved this in here, being Stripe-specific.

}
</CardParagraph>
<CardAction isPending={isPending} onClick={handleSubmit}>
{`Provide 1 Seat for $${actionCost}`}
Copy link
Member

Choose a reason for hiding this comment

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

Nice having a single source for the actionCost.

router.push(result.url);
};

return [handleSubmit, isPending];
Copy link
Member

Choose a reason for hiding this comment

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

I appreciate how elegantly you factored handleSubmit into here. Tracking isPending like this is also a very nice touch.

@audreyfeldroy audreyfeldroy merged commit 598427d into margaritahumanitarian:main Aug 21, 2021
@audreyfeldroy
Copy link
Member

Merged. Thank you so much @marekrozmus!

@audreyfeldroy audreyfeldroy changed the title Initial proposal of Card refactoring Card refactoring Aug 21, 2021
</a>
) : (
<button
className={`btn btn-primary ${isPending ? 'loading' : ''}`}
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for your extra eye for detail here, tracking isPending state with the loading indicator. This sort of detail touch really matters and makes the experience better.

@theflucs theflucs mentioned this pull request Sep 7, 2021
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.

Refactor common code from cards
3 participants