-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Long lines in code blocks should not wrap issue (#7497) is fixed #8790
Changes from 13 commits
51d50ef
df73cb6
06ea7d4
feab630
9320a72
44a7e7d
f3ab154
f0b3163
6ad7c2b
b08e731
0adeded
3772dba
e670bc0
b52d0e0
883eb79
2d885fa
1ac6aef
5c13765
32de902
afecb5d
9f2ce1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, {forwardRef} from 'react'; | ||
import {ScrollView} from 'react-native-gesture-handler'; | ||
import {View} from 'react-native'; | ||
import _ from 'underscore'; | ||
import htmlRendererPropTypes from '../htmlRendererPropTypes'; | ||
|
||
class BasePreRenderer extends React.Component { | ||
render() { | ||
const TDefaultRenderer = this.props.TDefaultRenderer; | ||
const defaultRendererProps = _.omit(this.props, ['TDefaultRenderer']); | ||
return ( | ||
<ScrollView ref={this.props.innerRef} horizontal> | ||
<View onStartShouldSetResponder={() => true}> | ||
<TDefaultRenderer | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...defaultRendererProps} | ||
/> | ||
</View> | ||
</ScrollView> | ||
); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a perfect candidate for the functional components. Please read the style guide and correct all style issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@parasharrajat i refactored. Please re-check |
||
|
||
BasePreRenderer.propTypes = htmlRendererPropTypes; | ||
NikkiWines marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default forwardRef((props, ref) => ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<BasePreRenderer {...props} innerRef={ref} /> | ||
)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import withLocalize from '../../../withLocalize'; | ||
import htmlRendererPropTypes from '../htmlRendererPropTypes'; | ||
import BasePreRenderer from './BasePreRenderer'; | ||
|
||
class PreRenderer extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.wheelEvent = this.wheelEvent.bind(this); | ||
this.ref = React.createRef(null); | ||
orkunkarakus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
componentDidMount() { | ||
this.ref.current | ||
.getScrollableNode() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactored |
||
.addEventListener('wheel', this.wheelEvent); | ||
} | ||
|
||
componentWillUnmount() { | ||
this.ref.getScrollableNode() | ||
.removeEventListener('wheel', this.wheelEvent); | ||
} | ||
|
||
wheelEvent(event) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename this function. The function name should define what it does instead of where it used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @parasharrajat I changed the function name to scrollNode |
||
const node = this.ref.current.getScrollableNode(); | ||
const checkOverflow = (node.scrollHeight / node.scrollWidth) !== (node.offsetHeight / node.offsetWidth); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does not seem correct. scrollWidth is used for horizontal scrolling and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @parasharrajat i changed it like this |
||
|
||
if ((event.currentTarget === node) && checkOverflow) { | ||
node.scrollLeft += event.deltaX; | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<BasePreRenderer | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...this.props} | ||
ref={this.ref} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
PreRenderer.propTypes = htmlRendererPropTypes; | ||
PreRenderer.displayName = 'PreRenderer'; | ||
|
||
export default withLocalize(PreRenderer); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import withLocalize from '../../../withLocalize'; | ||
import htmlRendererPropTypes from '../htmlRendererPropTypes'; | ||
import BasePreRenderer from './BasePreRenderer'; | ||
|
||
const PreRenderer = props => ( | ||
<BasePreRenderer | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Props can be inline: // eslint-disable-next-line react/jsx-props-no-spreading
<BasePreRenderer {...props} /> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactored. |
||
/> | ||
); | ||
|
||
PreRenderer.propTypes = htmlRendererPropTypes; | ||
PreRenderer.displayName = 'PreRenderer'; | ||
|
||
export default withLocalize(PreRenderer); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Allows us to identify whether the platform is hoverable. | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
|
||
import * as Browser from '../Browser'; | ||
|
||
const hasHoverSupport = () => !Browser.isMobile(); | ||
|
||
export default hasHoverSupport; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Allows us to identify whether the platform is hoverable. | ||
* | ||
* @returns {Boolean} | ||
*/ | ||
|
||
const hasHoverSupport = () => false; | ||
|
||
export default hasHoverSupport; |
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.
this is still class component. 😕
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.
@parasharrajat I interpreted your sentence as this style is very good for functional components but not good for classes.
And it was functional before and we converted it to class, so I never looked in that direction and looked at the styling guide again and again to see where is a mistake 😃
i converted and committed Pr is ready.