Skip to content

feat(tools): add helpblock component - #45399

Merged
ahmaxed merged 3 commits into
freeCodeCamp:mainfrom
Ismailtlem:feat/add-helpblock-component
Mar 31, 2022
Merged

ahmaxed merged 3 commits into
freeCodeCamp:mainfrom
Ismailtlem:feat/add-helpblock-component

Conversation

@Ismailtlem

Copy link
Copy Markdown
Member

Checklist:

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the main branch of freeCodeCamp.
  • I have tested these changes either locally on my machine, or GitPod.

Related to #44668

@Ismailtlem
Ismailtlem requested a review from a team March 9, 2022 21:58
@gitpod-io

gitpod-io Bot commented Mar 9, 2022

Copy link
Copy Markdown

@github-actions github-actions Bot added the scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. label Mar 9, 2022
@ghost

ghost commented Mar 9, 2022 •

Copy link
Copy Markdown

👀 Review this PR in a CodeSee Review Map

Preview the Review Map

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@Ismailtlem
Ismailtlem marked this pull request as draft March 9, 2022 22:08
@Ismailtlem
Ismailtlem force-pushed the feat/add-helpblock-component branch 4 times, most recently from 8a7f256 to 4b80802 Compare March 12, 2022 21:50
@Ismailtlem
Ismailtlem marked this pull request as ready for review March 12, 2022 21:51
@Ismailtlem
Ismailtlem marked this pull request as draft March 12, 2022 21:51
@Ismailtlem
Ismailtlem force-pushed the feat/add-helpblock-component branch 2 times, most recently from e950252 to a4037bd Compare March 14, 2022 07:52
@Ismailtlem
Ismailtlem marked this pull request as ready for review March 14, 2022 08:34

@ahmaxed ahmaxed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this PR. it seems like we have been using this component extensively in our code base.

It is interesting that Bootstrap has removed this component in its other versions. Could you please research to see what that is? We might consider doing the same later on.

Here are a few minor considerations.

Comment on lines +21 to +24
export const LightGray = Template.bind({});
LightGray.args = {
className: 'block mt-5 mb-10 text-[color:var(--gray15)]'
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
export const LightGray = Template.bind({});
LightGray.args = {
className: 'block mt-5 mb-10 text-[color:var(--gray15)]'
};

There is nothing visible for the help block as story so we should be fine with just keeping the Default Variation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure if we need make it wrap another component. Could look up if there are similar storybook instances where a component is not visible?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the classes you could use the Alert or Button component as a reference.


describe('Render the helpblock component', () => {
it('sould render the helpblock component', () => {
render(<HelpBlock className='block mt-5 mb-10 text-[#737373]' />);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The classes names should be handled within the component by default and we could check if they exist here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The color should be set to --quaternary-color. I belive it is called text-default-foreground-quaternary

@Ismailtlem
Ismailtlem force-pushed the feat/add-helpblock-component branch 2 times, most recently from 2e842bc to cc9f2b9 Compare March 17, 2022 22:18
@ahmaxed ahmaxed mentioned this pull request Mar 18, 2022
37 of 49 tasks
@Ismailtlem
Ismailtlem dismissed a stale review via 7b67ee1 March 18, 2022 21:38
@Ismailtlem
Ismailtlem force-pushed the feat/add-helpblock-component branch from cc9f2b9 to 7b67ee1 Compare March 18, 2022 21:38
@Ismailtlem

Copy link
Copy Markdown
Member Author

help-block class was removed from bootstrap 4 and replaced with form-text https://getbootstrap.com/docs/4.0/components/forms/#help-text
In react-bootstrap, the corresponding component from the latest versions we can use is <Form.Text>. We will have I think to fix some styling (fix margin top and bottom) to make it exactly like in bootstrap 3.

@raisedadead raisedadead added the status: waiting update Is awaiting update, after feedback or request for changes label Mar 22, 2022
import './helpblock.css';

const classes = [
'block mt-5 mb-10 text-[color:var(--default-foreground-quaternary)]'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
'block mt-5 mb-10 text-[color:var(--default-foreground-quaternary)]'
'block mt-5 mb-10 text-default-foreground-quaternary'

'block mt-5 mb-10 text-[color:var(--default-foreground-quaternary)]'
].join('');

export const HelpBlock = (): JSX.Element => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use React.forwardRef similar to the image component.

@Ismailtlem
Ismailtlem dismissed a stale review via 608c230 March 24, 2022 19:44
@Ismailtlem
Ismailtlem force-pushed the feat/add-helpblock-component branch 2 times, most recently from 608c230 to 3c7794e Compare March 24, 2022 19:52
@Ismailtlem
Ismailtlem dismissed a stale review via 9ccfd12 March 25, 2022 07:49
@Ismailtlem
Ismailtlem force-pushed the feat/add-helpblock-component branch from 3c7794e to 9ccfd12 Compare March 25, 2022 07:49
@@ -0,0 +1 @@
@import '../colors.css';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The colors are handled through tailwind, we don't need to import them separately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the helpBlock does not have styles that cannot be replicated using tailwind classes, having a cdd file is not necessary.

@Ismailtlem
Ismailtlem force-pushed the feat/add-helpblock-component branch 2 times, most recently from 896cc4a to 1ae23fd Compare March 26, 2022 09:08
@Ismailtlem Ismailtlem added status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending. and removed status: waiting update Is awaiting update, after feedback or request for changes labels Mar 30, 2022
@ahmaxed
ahmaxed force-pushed the feat/add-helpblock-component branch from 1ae23fd to a1359a3 Compare March 31, 2022 11:09
@ahmaxed

ahmaxed commented Mar 31, 2022 •

Copy link
Copy Markdown
Member

I went ahead and made a few changes to finalize the component that I encourage you to take a look at.

Here are a few takes:

  • The used tailwind rem classes are based on learn's html font size (18px) and should be calculated accordingly.
  • Types should be passed to the component.
  • HelpBlock component is used with children; therefore, its children should be passed as props.

For the upcoming PRs, I highly recommend using the newly added docs that includes commands to generate a template component.

Thank you for working on the HelpBlock component and cannot wait to see this in production. 🙏 🙏 🙏

@ahmaxed
ahmaxed merged commit ed66e5d into freeCodeCamp:main Mar 31, 2022
@ahmaxed

ahmaxed commented Apr 1, 2022 •

Copy link
Copy Markdown
Member

Here is a little more clarification.

  • Tailwind uses different units for their default margin classes and we need to find a one close to what we have in the codebase. Our learn's html has 18px font-size. If the desired margin top is 5px, we need to find the closes rem value as a replacement. 5/18 = 0.27 . From the tailwind documentation we know mt-1 ===> margin-top: 0.25rem;
  • the classname props was added for flexibility, it might be removed when the css is migrated from learn to ui-components.

@Ismailtlem
Ismailtlem deleted the feat/add-helpblock-component branch April 2, 2022 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: tools/scripts Scripts for supporting dev work, generating config and build artifacts, etc. status: waiting review To be applied to PR's that are ready for QA, especially when additional review is pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants