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

add lifecycle badge component #4528

Merged
merged 9 commits into from
Nov 27, 2023
Merged

add lifecycle badge component #4528

merged 9 commits into from
Nov 27, 2023

Conversation

mirnawong1
Copy link
Contributor

creating a lifecycle badge to enable the docs team and documentarians to use a component allowing them to add a lifecycle badge on specific content.

@mirnawong1 mirnawong1 requested a review from a team as a code owner November 22, 2023 11:49
Copy link

vercel bot commented Nov 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2023 3:27pm

@github-actions github-actions bot added content Improvements or additions to content Docs team Authored by the Docs team @dbt Labs size: small This change will take 1 to 2 days to address labels Nov 22, 2023
@mirnawong1 mirnawong1 changed the title add index and styles add lifecycle badge component Nov 22, 2023
Copy link
Collaborator

@JKarlavige JKarlavige left a comment

Choose a reason for hiding this comment

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

Great work again with this @mirnawong1!! Left one comment requesting one additional improvement to make within the component. This goes into conditional rendering to only return the span tag if props.status exists.

Let me know if you have any questions!!

Comment on lines 4 to 8
export default function Lifecycle(props) {
return (
<span className={styles.lifecycle}>{props.status}</span>
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We didn't get to this during our meeting today, but I think there's more more improvement we can make with this. As-is, it will always apply the span tag, even if a user forgets to pass in content into the status prop. This will cause the pill to still appear with no text within it.

What we can do is check if props.status is set before adding the span tag to the page. If not, we should return null here rather than returning the span tag.

Here's React's documentation on how you can do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hey @JKarlavige ! thank you and great flag -- i added the null conditional rendering and if a user doesn't add anything, a small '-' appears at the end but i think it's related to the docusaurus' id assignment.

i also experimented to see if i could pass a props from the frontmatter object (as opposed to the string) and it works too!

Screenshot 2023-11-24 at 05 01 47

Copy link
Collaborator

@JKarlavige JKarlavige left a comment

Choose a reason for hiding this comment

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

This lgtm! Added a couple comments with non-blocking recommended adjustments. Let me know if you have any questions with my notes on the font size!

Comment on lines 4 to 10
// function Item ({ status }) {
// if (status) {
// return null;
// }

// return <span className={styles.lifecycle}>{status}</span>;
// }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a note to remove this unused code!

.lifecycle {
background-color: #047377; /* Teal background to align with dbt Labs' color */
color: #fff; /* Light text color for contrast */
font-size: 0.4em; /* Slightly smaller text */
Copy link
Collaborator

@JKarlavige JKarlavige Nov 27, 2023

Choose a reason for hiding this comment

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

Regarding the font-size - em is making the font size relative to the parent element the lifecyle component is a part of, so in this case the header size. One situation where this might cause an issue is if the lifecycle component is used outside of the header.

In this case, .4em would make the font size relative to it's parent. For example, if i add the lifecycle component on it's own line, it's parent element becomes a div, which has a smaller font size set than headers. .4em of the div's font size (1.125rem) would end up small and difficult to read.

image

One adjustment you can make here is switch from em to rem, which makes the font size relative to the root, which is usually 1rem. If you adjust the font-size to use rem, that size will remain consistent no matter where the component is used. .4rem would be pretty small, but bumping it up a bit should get you close to the font size you had when using em.

Using .9rem for example would say 'this text should always be slightly smaller than the default font size for the site.'

As long as the component is always used with headers, this won't be an issue. But if this is ever used outside of the headers, the font size will likely need to be adjusted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thank you @JKarlavige ! ok i've changed it to 0.78rem so it's a bit more relative to the parent. this component should mostly be used for headers so hopefully won't be an issue but it's good to allow flexibility.

@mirnawong1
Copy link
Contributor Author

going to merge this now, thanks so much @JKarlavige !!!

@mirnawong1 mirnawong1 merged commit 587c12d into current Nov 27, 2023
7 checks passed
@mirnawong1 mirnawong1 deleted the add-lifecycle-badge branch November 27, 2023 15:31
@JKarlavige
Copy link
Collaborator

Great work again @mirnawong1!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content Docs team Authored by the Docs team @dbt Labs size: small This change will take 1 to 2 days to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants