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

feat: replace style will recover the origin style #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kitayoshi
Copy link

if replace style (handle style) are provided, origin style should be omitted.

Proposed solution

inline style on resizer (handleStyles) could never be covered by style which set byhandleClasses

// style
.myHandle-right {
  width: 20px;
}

// react
<Resizable
  handleClasses={{right: 'myHandle-right'}}
/>

results like:

// inline style set by origin right handle
{
  width: 10px;
}

// will be covered
.myHandle-right {
  width: 20px;
}

Tradeoffs

I should still write like these to make style in myHandle-right work:

<Resizable
  handleStyles={{right: {}}}
  handleClasses={{right: 'myHandle-right'}}
/>

I'm not sure whether I should write like:

style={{
  ...styles.base,
  ...(props.className ? styles[props.direction] : {}),
  ...(props.replaceStyles || {})
}}

Testing Done

yes

if replace style (handle style) are provided, origin style should be omitted.
@kitayoshi
Copy link
Author

And it truly implements document (now is not):

If you specify a value for right it will completely replace the styles for the right resize handle, but other handle will still use the default styles.

@bokuweb
Copy link
Owner

bokuweb commented Sep 13, 2017

@midare Thanks for your PR.

@@ -37,31 +37,27 @@ const styles = {
topRight: {
width: '20px',
height: '20px',
position: 'absolute',
Copy link
Owner

Choose a reason for hiding this comment

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

oops. it' s my mistake. thanks.

@@ -88,8 +84,7 @@ export default (props: Props): React.Element<'div'> => {
className={props.className}
style={{
...styles.base,
...styles[props.direction],
...(props.replaceStyles || {}),
Copy link
Owner

Choose a reason for hiding this comment

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

I prefer the following :)

style={{
  ...styles.base,
  ...(props.className ? styles[props.direction] : {}),
  ...(props.replaceStyles || {})
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants