Skip to content

Commit

Permalink
Make user-supplied resizerClassName prop additive (#208)
Browse files Browse the repository at this point in the history
* If a resizerClassName prop is supplied by the user, make it addditive to the default class name (instead of completely replacing it).

* Obey eslint. No string concat, wow.

* Add test to verify the existance of the default class.
  • Loading branch information
dfsp-spirit authored and tomkp committed Jun 28, 2017
1 parent 7c88eec commit 16caf26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Prefixer from 'inline-style-prefixer';
import stylePropType from 'react-style-proptype';

const USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Safari/537.2';
export const RESIZER_DEFAULT_CLASSNAME = 'Resizer';

class Resizer extends React.Component {
render() {
Expand Down Expand Up @@ -56,7 +57,7 @@ Resizer.propTypes = {

Resizer.defaultProps = {
prefixer: new Prefixer({ userAgent: USER_AGENT }),
resizerClassName: 'Resizer',
resizerClassName: RESIZER_DEFAULT_CLASSNAME,
};

export default Resizer;
6 changes: 4 additions & 2 deletions src/SplitPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Prefixer from 'inline-style-prefixer';
import stylePropType from 'react-style-proptype';

import Pane from './Pane';
import Resizer from './Resizer';
import Resizer, { RESIZER_DEFAULT_CLASSNAME } from './Resizer';

const USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Safari/537.2';

Expand Down Expand Up @@ -167,6 +167,8 @@ class SplitPane extends React.Component {
pane1Style: pane1StyleProps, pane2Style: pane2StyleProps, primary, prefixer, resizerClassName,
resizerStyle, size, split, style: styleProps } = this.props;
const disabledClass = allowResize ? '' : 'disabled';
const resizerClassNamesIncludingDefault = (resizerClassName ?
`${resizerClassName} ${RESIZER_DEFAULT_CLASSNAME}` : resizerClassName);

const style = Object.assign({},
styleProps || {}, {
Expand Down Expand Up @@ -227,7 +229,7 @@ class SplitPane extends React.Component {
onTouchEnd={this.onMouseUp}
key="resizer"
ref={(node) => { this.resizer = node; }}
resizerClassName={resizerClassName}
resizerClassName={resizerClassNamesIncludingDefault}
split={split}
style={resizerStyle || {}}
/>
Expand Down
4 changes: 4 additions & 0 deletions test/default-split-pane-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,9 @@ describe('Internal Resizer have class', () => {
it('should have the specified classname', () => {
asserter(splitPane).assertResizerClasses('some-class');
});

it('should have the default classname', () => {
asserter(splitPane).assertResizerClasses('Resizer');
});

});

0 comments on commit 16caf26

Please sign in to comment.