-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Updating demos and hacking fix for responsive container #84
Conversation
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.
Even though this is a hack, I think some comments in the places that hacky elements have been inserted would be helpful for future maintainers.
if (window.requestAnimationFrame) { | ||
window.requestAnimationFrame(runCallbacks); | ||
} else { | ||
setTimeout(runCallbacks, 66); |
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.
Magic number? Where did this come from?
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.
Good call, moving into a constant.
let newWidth = document.querySelector('main').offsetWidth; | ||
|
||
if (cachedWidth !== newWidth) { | ||
cachedWidth = newWidth; |
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.
Would it be better to put this inside the !running
condition?
@@ -48,6 +48,24 @@ const optimizedResize = (function() { | |||
} | |||
}; | |||
|
|||
const resizeMainHorizontal = () => { | |||
let newWidth = document.querySelector('main').offsetWidth; |
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'm not familiar enough with the codebase to know what main
is. Is that something that's always guaranteed to be present?
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.
That's the element of the 'main' section of the documentation.
It is not safe that it will always be there, and I cannot find how to add a class there to make it easier.
adding a comment.
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.
Better now with comments :)
The resizeMainHorizontal was added in the PR britecharts#84 as a hacking fix for the responsive container in the project documentation. This function broke the charts responsiveness outside the docs because it was looking for a `main` tag present in the styleguide docs but not in every other project.
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> The resizeMainHorizontal was added in the PR #84 as a hacking fix for the responsive container in the project documentation. This function broke the charts responsiveness outside the docs because it was looking for a `main` tag present in the **React Styleguidist** docs but not in every other project. This PR removes the problematic function and uses the correct one to fix the problem. The doc's responsiveness was tested using the original function and it work ok with this version of React Styleguidist. This PR also address the issue #144 to make it easier to import the ResponsiveContainer component and the withResponsiveness helper. ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> * The charts' responsiveness is currently broken as described in the issue #105. * At the moment is difficult to import the ResponsiveContainer component and the withResponsiveness helper because you have to do it directly from the ESM bundle. ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> * All the unit tests were ran and all of them passed. * The documentation pages were reviewed to check for any inconsistency with the published one. ## Screenshots (if appropriate): <img width="1676" alt="wide" src="https://user-images.githubusercontent.com/282903/49551467-5007dc80-f8bd-11e8-9611-53de3d8166c9.png"> <img width="1237" alt="narrow" src="https://user-images.githubusercontent.com/282903/49551475-58601780-f8bd-11e8-9fd6-eaf84ecaf96e.png"> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Refactor (changes the way we code something without changing its functionality) - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have read the **CONTRIBUTING** document. - [ ] I have updated the documentation accordingly. - [ ] I have added tests to cover my changes. - [x] All new and existing tests passed.
* Updating demos and hacking fix for responsive container * Amber comments
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> The resizeMainHorizontal was added in the PR #84 as a hacking fix for the responsive container in the project documentation. This function broke the charts responsiveness outside the docs because it was looking for a `main` tag present in the **React Styleguidist** docs but not in every other project. This PR removes the problematic function and uses the correct one to fix the problem. The doc's responsiveness was tested using the original function and it work ok with this version of React Styleguidist. This PR also address the issue #144 to make it easier to import the ResponsiveContainer component and the withResponsiveness helper. ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> * The charts' responsiveness is currently broken as described in the issue #105. * At the moment is difficult to import the ResponsiveContainer component and the withResponsiveness helper because you have to do it directly from the ESM bundle. ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> * All the unit tests were ran and all of them passed. * The documentation pages were reviewed to check for any inconsistency with the published one. ## Screenshots (if appropriate): <img width="1676" alt="wide" src="https://user-images.githubusercontent.com/282903/49551467-5007dc80-f8bd-11e8-9611-53de3d8166c9.png"> <img width="1237" alt="narrow" src="https://user-images.githubusercontent.com/282903/49551475-58601780-f8bd-11e8-9fd6-eaf84ecaf96e.png"> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Refactor (changes the way we code something without changing its functionality) - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] I have read the **CONTRIBUTING** document. - [ ] I have updated the documentation accordingly. - [ ] I have added tests to cover my changes. - [x] All new and existing tests passed.
Description
Patching the layout resizing issue by programmatically trigger a window resize event
Update legend demo to something a bit more nice
Motivation and Context
the overflow hidden trick didn't really work, as it just masked the problem.
I tried to debounce the application of the responsive container, but it breaks the functionality after the first trigger.
How Has This Been Tested?
Ran tests
Types of changes