Skip to content

Commit ce64f16

Browse files
committed
clean classNames
1 parent 185de49 commit ce64f16

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

src/Header.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import moment from 'moment';
4+
import classNames from 'classnames';
45

56
class Header extends Component {
67
static propTypes = {
@@ -162,7 +163,7 @@ class Header extends Component {
162163
const invalidClass = invalid ? `${prefixCls}-input-invalid` : '';
163164
return (
164165
<input
165-
className={`${prefixCls}-input ${invalidClass}`}
166+
className={classNames(`${prefixCls}-input`, invalidClass)}
166167
ref={ref => {
167168
this.refInput = ref;
168169
}}

src/Panel.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,7 @@ class Panel extends Component {
185185
);
186186

187187
return (
188-
<div
189-
className={classNames({
190-
[`${prefixCls}-inner`]: true,
191-
[className]: !!className,
192-
})}
193-
>
188+
<div className={classNames(className, `${prefixCls}-inner`)}>
194189
<Header
195190
clearText={clearText}
196191
prefixCls={prefixCls}

src/Select.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, { Component } from 'react';
33
import PropTypes from 'prop-types';
44
import ReactDom from 'react-dom';
5-
import classnames from 'classnames';
5+
import classNames from 'classnames';
66

77
const scrollTo = (element, to, duration) => {
88
const requestAnimationFrame =
@@ -60,7 +60,7 @@ class Select extends Component {
6060
getOptions() {
6161
const { options, selectedIndex, prefixCls } = this.props;
6262
return options.map((item, index) => {
63-
const cls = classnames({
63+
const cls = classNames({
6464
[`${prefixCls}-select-option-selected`]: selectedIndex === index,
6565
[`${prefixCls}-select-option-disabled`]: item.disabled,
6666
});
@@ -114,7 +114,7 @@ class Select extends Component {
114114
if (options.length === 0) {
115115
return null;
116116
}
117-
const cls = classnames(`${prefixCls}-select`, {
117+
const cls = classNames(`${prefixCls}-select`, {
118118
[`${prefixCls}-select-active`]: active,
119119
});
120120
return (

src/TimePicker.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { Component } from 'react';
33
import PropTypes from 'prop-types';
44
import Trigger from 'rc-trigger';
55
import moment from 'moment';
6+
import classNames from 'classnames';
67
import Panel from './Panel';
78
import placements from './placements';
89

@@ -235,11 +236,6 @@ export default class Picker extends Component {
235236

236237
getPopupClassName() {
237238
const { showHour, showMinute, showSecond, use12Hours, prefixCls, popupClassName } = this.props;
238-
let className = popupClassName;
239-
// Keep it for old compatibility
240-
if ((!showHour || !showMinute || !showSecond) && !use12Hours) {
241-
className += ` ${prefixCls}-panel-narrow`;
242-
}
243239
let selectColumnCount = 0;
244240
if (showHour) {
245241
selectColumnCount += 1;
@@ -253,8 +249,14 @@ export default class Picker extends Component {
253249
if (use12Hours) {
254250
selectColumnCount += 1;
255251
}
256-
className += ` ${prefixCls}-panel-column-${selectColumnCount}`;
257-
return className;
252+
// Keep it for old compatibility
253+
return classNames(
254+
popupClassName,
255+
{
256+
[`${prefixCls}-panel-narrow`]: (!showHour || !showMinute || !showSecond) && !use12Hours,
257+
},
258+
`${prefixCls}-panel-column-${selectColumnCount}`,
259+
);
258260
}
259261

260262
setOpen(open) {
@@ -349,7 +351,7 @@ export default class Picker extends Component {
349351
popupVisible={open}
350352
onPopupVisibleChange={this.onVisibleChange}
351353
>
352-
<span className={`${prefixCls} ${className}`} style={style}>
354+
<span className={classNames(prefixCls, className)} style={style}>
353355
<input
354356
className={`${prefixCls}-input`}
355357
ref={this.saveInputRef}

tests/__snapshots__/TimePicker.spec.jsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`TimePicker allowEmpty cannot allow clear when disabled 1`] = `
44
<span
5-
class="rc-time-picker "
5+
class="rc-time-picker"
66
>
77
<input
88
class="rc-time-picker-input"
@@ -19,7 +19,7 @@ exports[`TimePicker allowEmpty cannot allow clear when disabled 1`] = `
1919

2020
exports[`TimePicker allowEmpty should allow clear 1`] = `
2121
<span
22-
class="rc-time-picker "
22+
class="rc-time-picker"
2323
>
2424
<input
2525
class="rc-time-picker-input"

0 commit comments

Comments
 (0)