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

✨ DOP-4662 adds community pill to cards for when using tags #1130

Merged
merged 4 commits into from
Jun 13, 2024

Conversation

caesarbell
Copy link
Collaborator

@caesarbell caesarbell commented Jun 12, 2024

Stories/Links:

DOP-4662

Current Behavior:

Python Landing

Docs Landing

Staging Links:

Staged: Python Landing

Staged: Docs Landing (built from a forked repo)

Notes:

  • For this PR, I modified the community pill component to be reusable and swapped out the Tag component to use the new community pill component.

README updates

    • This PR introduces changes that should be reflected in the README, and I have made those updates.
    • This PR does not introduce changes that should be reflected in the README

@caesarbell caesarbell marked this pull request as ready for review June 12, 2024 20:15
* @param {string} [param0.text='community built'] - Text to display, defaults to 'community built'
* @returns {JSX.Element} The rendered CommunityPillLink component
*/
const CommunityPillLink = ({ nodeData, variant, text = 'community built' }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does variant need to default to "lightgray"?

Copy link
Collaborator Author

@caesarbell caesarbell Jun 12, 2024

Choose a reason for hiding this comment

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

@mmeigs good question, in this case, yes the variant prop for Badge should default to lightgray to support the original use case of the community pill.

I am doing so within the Badge component i.e.

<Badge variant={communityPillVariants[variant] || Variant.LightGray}>{text}</Badge>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could re-write this to be more like

const CommunityPillLink = ({ nodeData, variant = 'lightgray', text = 'community built' }) => {
  const { argument, options: { url } = {} } = nodeData || {};

  return (
    <div>
      {nodeData && argument && url && <Link to={url}>{getPlaintext(argument)}</Link>}
      <Badge variant={communityPillVariants[variant]}>{text}</Badge>
    </div>
  );
};

if you prefer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i like this!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mayaraman19 the former or latter?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wow, my brain. Yep - you're so right. I guess it would be nice to have the defaults be declared the same way! Either way is fine with me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mmeigs no worries, it's the middle of the week and our brains have been on overdrive. I will update the code to declare it the same way.

@caesarbell caesarbell requested a review from mmeigs June 12, 2024 20:42
Comment on lines 19 to 25
* @param {Object} param0 - The parameters object
* @param {Object} param0.nodeData - Data for the node
* @param {String} param0.nodeData.argument - Text to display for Link
* @param {Object} [param0.nodeData.options] - Options for the node data
* @param {string} [param0.nodeData.options.url] - URL in the options
* @param {string} param0.variant - Variant of the community pill link
* @param {string} [param0.text='community built'] - Text to display, defaults to 'community built'
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a little bit difficult to understand because of the repeated references to param0, nodeData, etc. Might be better to remove + ensure the code is straightforward to understand in order to reduce confusion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mayaraman19 I can remove this, it was to help when hovering your mouse over the component when called in another file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i see! that is a nice touch. I guess the confusion lies in naming param0 since it's not mentioned by name in the code, as well as I don't understand why some have brackets [] around them, since they don't seem to be array values? minor & non-blocking though, i trust your judgement!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mayaraman19 I went with your feedback, no need to add confusion when it's not needed. The brackets indicated the default value.

* @returns {JSX.Element} The rendered CommunityPillLink component
*/
const CommunityPillLink = ({ nodeData, variant, text = 'community built' }) => {
const { argument, options: { url } = {} } = nodeData || {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a way to define these as optional using the nodeData prop instead i.e.

const CommunityPillLink = ({ nodeData: {argument?, options?: {url}}, variant, text = 'community built' }) => {
...

or something like that. I'm forgetting my Javascript currently though so idk if this is possible

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mayaraman19 just out of curiosity, what are you trying to achieve, readability? I am asking so I can better understand the suggestion/comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mayaraman19 also, from what I understand that might not be doable in vanilla JavaScript. That is more of a Typescript approach.

Copy link
Collaborator

@mayaraman19 mayaraman19 Jun 13, 2024

Choose a reason for hiding this comment

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

i guess the intent was to use the convention we typically use for getting values from nodeData as well as remove the need to check for nodeData here. but if it is not possible that's okay, it's very minor

Comment on lines 19 to 25
* @param {Object} param0 - The parameters object
* @param {Object} param0.nodeData - Data for the node
* @param {String} param0.nodeData.argument - Text to display for Link
* @param {Object} [param0.nodeData.options] - Options for the node data
* @param {string} [param0.nodeData.options.url] - URL in the options
* @param {string} param0.variant - Variant of the community pill link
* @param {string} [param0.text='community built'] - Text to display, defaults to 'community built'
Copy link
Collaborator

Choose a reason for hiding this comment

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

i see! that is a nice touch. I guess the confusion lies in naming param0 since it's not mentioned by name in the code, as well as I don't understand why some have brackets [] around them, since they don't seem to be array values? minor & non-blocking though, i trust your judgement!

@caesarbell caesarbell merged commit f9b3d4c into main Jun 13, 2024
2 checks passed
@caesarbell caesarbell deleted the DOP-4662 branch June 13, 2024 15:30
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.

3 participants