Skip to content

Commit 66771da

Browse files
committed
Rename classNames to be more meaningful
1 parent 975c6c9 commit 66771da

File tree

4 files changed

+66
-66
lines changed

4 files changed

+66
-66
lines changed

src/DateTimePicker.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ export default class DateTimePicker extends PureComponent {
170170
const { isCalendarOpen, isClockOpen } = this.state;
171171

172172
return (
173-
<div className={`${baseClassName}__button`}>
173+
<div className={`${baseClassName}__wrapper`}>
174174
<DateTimeInput
175-
className={`${baseClassName}__button__input`}
175+
className={`${baseClassName}__inputGroup`}
176176
disabled={disabled}
177177
locale={locale}
178178
isWidgetOpen={isCalendarOpen || isClockOpen}
@@ -188,7 +188,7 @@ export default class DateTimePicker extends PureComponent {
188188
/>
189189
{clearIcon !== null && (
190190
<button
191-
className={`${baseClassName}__clear-button ${baseClassName}__button__icon`}
191+
className={`${baseClassName}__clear-button ${baseClassName}__button`}
192192
disabled={disabled}
193193
onClick={this.clear}
194194
onFocus={this.stopPropagation}
@@ -199,7 +199,7 @@ export default class DateTimePicker extends PureComponent {
199199
)}
200200
{calendarIcon !== null && (
201201
<button
202-
className={`${baseClassName}__calendar-button ${baseClassName}__button__icon`}
202+
className={`${baseClassName}__calendar-button ${baseClassName}__button`}
203203
disabled={disabled}
204204
onClick={this.toggleCalendar}
205205
onFocus={this.stopPropagation}

src/DateTimePicker.less

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,86 +13,86 @@
1313
color: rgb(109, 109, 109);
1414
}
1515

16-
&__button {
16+
&__wrapper {
1717
display: flex;
1818
border: thin solid gray;
19+
}
1920

20-
&__input {
21-
@digit-width: .54em;
22-
@colon-width: .217em;
23-
// own padding + inputs padding + digits width + dots width
24-
min-width: calc(~"4px + (4px * 3) + " @digit-width * 6 ~" + " @colon-width * 2);
25-
flex-grow: 1;
26-
display: flex;
27-
padding: 0 2px;
28-
align-items: baseline;
29-
30-
&__divider {
31-
padding: 1px 0;
32-
}
21+
&__inputGroup {
22+
@digit-width: .54em;
23+
@colon-width: .217em;
24+
// own padding + inputs padding + digits width + dots width
25+
min-width: calc(~"4px + (4px * 3) + " @digit-width * 6 ~" + " @colon-width * 2);
26+
flex-grow: 1;
27+
display: flex;
28+
padding: 0 2px;
29+
align-items: baseline;
3330

34-
&__input {
35-
min-width: @digit-width;
36-
height: calc(100% - 2px);
37-
position: relative;
38-
padding: 1px;
39-
border: 0;
40-
background: none;
41-
font: inherit;
42-
box-sizing: content-box;
43-
-moz-appearance: textfield;
44-
45-
&::-webkit-outer-spin-button,
46-
&::-webkit-inner-spin-button {
47-
-webkit-appearance: none;
48-
margin: 0;
49-
}
31+
&__divider {
32+
padding: 1px 0;
33+
}
5034

51-
&:invalid {
52-
background: fade(red, 10%);
53-
}
35+
&__input {
36+
min-width: @digit-width;
37+
height: calc(100% - 2px);
38+
position: relative;
39+
padding: 1px;
40+
border: 0;
41+
background: none;
42+
font: inherit;
43+
box-sizing: content-box;
44+
-moz-appearance: textfield;
45+
46+
&::-webkit-outer-spin-button,
47+
&::-webkit-inner-spin-button {
48+
-webkit-appearance: none;
49+
margin: 0;
50+
}
5451

55-
&--hasLeadingZero {
56-
margin-left: -@digit-width;
57-
padding-left: calc(~"1px + " @digit-width);
58-
}
52+
&:invalid {
53+
background: fade(red, 10%);
5954
}
6055

61-
&__amPm {
62-
font: inherit;
63-
-moz-appearance: menulist;
56+
&--hasLeadingZero {
57+
margin-left: -@digit-width;
58+
padding-left: calc(~"1px + " @digit-width);
6459
}
6560
}
6661

67-
&__icon {
68-
border: 0;
69-
background: transparent;
70-
padding: 4px 6px;
62+
&__amPm {
63+
font: inherit;
64+
-moz-appearance: menulist;
65+
}
66+
}
7167

72-
&:enabled {
73-
cursor: pointer;
68+
&__button {
69+
border: 0;
70+
background: transparent;
71+
padding: 4px 6px;
7472

75-
&:hover, &:focus {
76-
svg {
77-
g {
78-
stroke: rgb(0, 120, 215);
79-
}
80-
}
81-
}
82-
}
73+
&:enabled {
74+
cursor: pointer;
8375

84-
&:disabled {
76+
&:hover, &:focus {
8577
svg {
8678
g {
87-
stroke: rgb(109, 109, 109);
79+
stroke: rgb(0, 120, 215);
8880
}
8981
}
9082
}
83+
}
9184

85+
&:disabled {
9286
svg {
93-
display: inherit;
87+
g {
88+
stroke: rgb(109, 109, 109);
89+
}
9490
}
9591
}
92+
93+
svg {
94+
display: inherit;
95+
}
9696
}
9797

9898
&__calendar,

src/Divider.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33

44
const Divider = ({ children }) => (
5-
<span className="react-datetime-picker__button__input__divider">
5+
<span className="react-datetime-picker__inputGroup__divider">
66
{children}
77
</span>
88
);

src/__tests__/DateTimeInput.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const getKey = key => ({
3535

3636
describe('DateTimeInput', () => {
3737
const defaultProps = {
38-
className: 'react-datetime-picker__button__input',
38+
className: 'react-datetime-picker__inputGroup',
3939
};
4040

4141
it('renders a native input and custom inputs', () => {
@@ -216,7 +216,7 @@ describe('DateTimeInput', () => {
216216
<DateTimeInput {...defaultProps} />
217217
);
218218

219-
const separators = component.find('.react-datetime-picker__button__input__divider');
219+
const separators = component.find('.react-datetime-picker__inputGroup__divider');
220220

221221
expect(separators).toHaveLength(4);
222222
expect(separators.at(0).text()).toBe('/');
@@ -233,7 +233,7 @@ describe('DateTimeInput', () => {
233233
/>
234234
);
235235

236-
const separators = component.find('.react-datetime-picker__button__input__divider');
236+
const separators = component.find('.react-datetime-picker__inputGroup__divider');
237237
const customInputs = component.find('input[type="number"]');
238238

239239
expect(separators).toHaveLength(customInputs.length - 1);
@@ -270,7 +270,7 @@ describe('DateTimeInput', () => {
270270

271271
expect(document.activeElement).toBe(dayInput.getDOMNode());
272272

273-
const separators = component.find('.react-datetime-picker__button__input__divider');
273+
const separators = component.find('.react-datetime-picker__inputGroup__divider');
274274
const separatorKey = separators.at(0).text();
275275
dayInput.simulate('keydown', getKey(separatorKey));
276276

0 commit comments

Comments
 (0)