-
Notifications
You must be signed in to change notification settings - Fork 70
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
feat: migrates Container to TypeScript; Container without max-width on docs site [FC-0062] #3216
feat: migrates Container to TypeScript; Container without max-width on docs site [FC-0062] #3216
Conversation
Thanks for the pull request, @rpenido! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
✅ Deploy Preview for paragon-openedx ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3216 +/- ##
==========================================
+ Coverage 93.25% 93.27% +0.01%
==========================================
Files 249 249
Lines 4388 4401 +13
Branches 1037 1037
==========================================
+ Hits 4092 4105 +13
Misses 290 290
Partials 6 6 ☔ View full report in Codecov by Sentry. |
9996590
to
98e8bdb
Compare
98e8bdb
to
0dfd9d8
Compare
0dfd9d8
to
4a206ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rpenido Some comments for you -- I still need to test this too.
And in future, could you separate out converting from JSX -> TSX into a separate commit? That would help me see what's changed :)
src/Container/README.md
Outdated
@@ -19,6 +19,10 @@ The base container to contain, pad, and center content in the viewport. This com | |||
```jsx live | |||
<div style={{ overflowX: 'auto' }}> | |||
<div style={{ width: '1500px', border: 'solid 3px red' }}> | |||
<Container size="full" className="bg-danger-300 my-4"> | |||
The content in this container don't have a max width |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
The content in this container don't have a max width | |
The content in this container doesn't have a max width |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: a55d28b
src/Container/index.tsx
Outdated
bsPrefix="container" | ||
fluid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Do we need these lines when these properties are overridden by the prop defaults below?
I'm more concerned with the fluid
one, since I'm unsure how overriding these boolean values works in Typescript, and don't want to break anyone else's UI.
bsPrefix="container" | |
fluid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. We don't need this.
Removed here: a55d28b
As information only, because the spread {...props}
was after these props, the spread would override it. The boolean fluid
is a syntax sugar for fluid={true}
. This is the transpiled JS code:
it('does not add a size class when size is not specified', () => { | ||
const { container } = render(<Container>Content</Container>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather use an explicit size="full"
than assume that omitting the size means "full width".. Omitting a size should make the container fit its contents, just like a <div>
without a max-width
.
I think the bootstrap class mw-100
does this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you and tried this approach first.
The problem is that the current component allows the size
props to be omitted, and it behaves like "full width". You can check it here, removing the size
from one example: https://paragon-openedx.netlify.app/components/container/
We have many containers in our code base without size
that probably rely on this, so I don't think we can change that.
So I pushed back the size={full}
option.
We can add both options, but I think the ambiguity will not help us here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to update the API docs here: 47cbcb1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the current component allows the size props to be omitted, and it behaves like "full width". You can check it here, removing the size from one example: https://paragon-openedx.netlify.app/components/container/
Passing in size=""
gives us the fullscreen behaviour you're adding here.. so do we need this change?
Edit: ah yes, this is what Adam said 😄
Thanks for the contribution! Just as a heads up, I believe the primary change here is the TypeScript migration and adding the docs site example for The first instance of |
@@ -0,0 +1,64 @@ | |||
/* eslint-disable react/require-default-props */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[optional] With a recent update to @edx/eslint-config
, we might be able to upgrade to v4.2.0 in this repo and remove the need for default params in this file without disabling the ESLint rule 👀 openedx/eslint-config#156
While this repo is currently using v3 of @edx/eslint-config
, the v4 breaking changes don't seem to apply to this repo at the moment, per the release notes, so the upgrade should be fairly trivial:
Drops support for
eslint
^6.8.0;@edx/eslint-config
must now be used with at leasteslint
versions ^7.32.0 or ^8.2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adamstankiewicz I tried to update but got the following error on linting (which prevents the commit).
Did you already experienced this error before?
> @openedx/[email protected] lint
> npm run stylelint && eslint --ext .js --ext .jsx --ext .ts --ext .tsx . && npm run lint --workspaces --if-present
> @openedx/[email protected] stylelint
> stylelint "src/**/*.scss" "scss/**/*.scss" "www/src/**/*.scss" --config .stylelintrc.json
Oops! Something went wrong! :(
ESLint: 8.18.0
Error: Error while loading rule '@typescript-eslint/naming-convention': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /home/rpenido/Projects/opencraft/paragon/.eslintrc.js
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I have not. Thanks for flagging. I am able to reproduce the issue on my end as well. Unless you want to investigate the error further, feel free to defer on the upgrade and continue with your existing solution using default props and the disabled ESLint rule. If you do defer on the investigation/resolution, do you mind filing a new Paragon issue to document the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue created: #3230
src/Container/index.tsx
Outdated
size?: ContainerSize; | ||
} | ||
|
||
type ContainerType = ComponentWithAsProp<'div', ContainerProps> & { Deprecated?: any }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the Deprecated
property necessary here? Container
doesn't have a deprecated sub-component (e.g., Container.Deprecated
) as Button.Deprecated
does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's not needed. Thank you for catching this.
Fixed here: 641dd15
src/Container/index.tsx
Outdated
|
||
type ContainerType = ComponentWithAsProp<'div', ContainerProps> & { Deprecated?: any }; | ||
|
||
const Container: ContainerType = React.forwardRef<HTMLDivElement, ContainerProps>(({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could Container
be used with a non-div
element, e.g. with as="span"
? I wonder if this should be more generic, e.g. HTMLElement
or even Element
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I changed it to Element
as our property of interest (className
) exists.
Here: 7e0fb5c
src/Container/index.tsx
Outdated
/** Fill all available space at any breakpoint */ | ||
fluid: PropTypes.bool, | ||
/** Set the maximum width for the container. Omiting the prop will remove the max-width */ | ||
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', undefined]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the undefined
is implied by the lack of .isRequired
on the prop type definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. It was there to show in the docs, but it isn't necessary with the docstring change.
Fixed: 7a03d83
@@ -12,7 +12,7 @@ export interface IDefaultValue { | |||
theme?: string, | |||
direction?: string, | |||
language?: string, | |||
containerWidth?: string, | |||
containerWidth?: ContainerSize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the ContainerSize
type here, too! 🙌
Absolutely. Do you think I should change anything in the PR to make it clear? |
I might just recommend amending your PR title / commit message to more closely reflect the TypeScript migration and the additional example on the docs site, e.g.
Edit: typically we squash+merge when merging PRs, so this refactored commit message can actually be provided at the time the PR merges without you needing to amend/squash the commits yourself! Perhaps just modifying the PR title for now would suffice 😄 |
@rpenido When this merges, to ensure it gets published to NPM via
|
Thank you, @adamstankiewicz! I updated the PR title again. |
LGTM! If either you or @pomegranited don't have the ability to merge, let me know and I'll happily merge it, too :) |
Thanks @adamstankiewicz could you merge? We don't have access. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- I tested this while testing feat: allow full width content in library authoring [FC-0062] frontend-app-authoring#1258 (review)
- I read through the code
-
I checked for accessibility issuesN/A -
Includes documentationN/A -
User-facing strings are extracted for translationN/A
🎉 This PR is included in version 22.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…n docs site [FC-0062] (#3216)
…n docs site [FC-0062] (#3216)
🎉 This PR is included in version 23.0.0-alpha.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR allows the
size
property of theContainer
to beundefined
, removing the maximum width in this caseDeploy Preview
https://deploy-preview-3216--paragon-openedx.netlify.app/components/container/
More information
Part of:
Merge Checklist
example
app?Post-merge Checklist
Private ref: FAL-3820