Skip to content

Commit 5fd46cb

Browse files
committed
Rename classNames to be more meaningful
1 parent 2093214 commit 5fd46cb

File tree

4 files changed

+64
-63
lines changed

4 files changed

+64
-63
lines changed

src/DatePicker.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ export default class DatePicker extends PureComponent {
111111
const [valueFrom] = [].concat(value);
112112

113113
return (
114-
<div className={`${baseClassName}__button`}>
114+
<div className={`${baseClassName}__wrapper`}>
115115
<DateInput
116-
className={`${baseClassName}__button__input`}
116+
className={`${baseClassName}__inputGroup`}
117117
disabled={disabled}
118118
locale={locale}
119119
isCalendarOpen={isOpen}
@@ -129,7 +129,7 @@ export default class DatePicker extends PureComponent {
129129
/>
130130
{clearIcon !== null && (
131131
<button
132-
className={`${baseClassName}__clear-button ${baseClassName}__button__icon`}
132+
className={`${baseClassName}__clear-button ${baseClassName}__button`}
133133
disabled={disabled}
134134
onClick={this.clear}
135135
onFocus={this.stopPropagation}
@@ -140,7 +140,7 @@ export default class DatePicker extends PureComponent {
140140
)}
141141
{calendarIcon !== null && (
142142
<button
143-
className={`${baseClassName}__calendar-button ${baseClassName}__button__icon`}
143+
className={`${baseClassName}__calendar-button ${baseClassName}__button`}
144144
disabled={disabled}
145145
onClick={this.toggleCalendar}
146146
onFocus={this.stopPropagation}

src/DatePicker.less

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

16-
&__button {
16+
&__wrapper {
1717
display: flex;
1818
border: thin solid gray;
19+
}
20+
21+
&__inputGroup {
22+
@digit-width: .54em;
23+
@dot-width: .217em;
24+
// own padding + inputs padding + digits width + dots width
25+
min-width: calc(~"(4px * 3) + " @digit-width * 8 ~" + " @dot-width * 2);
26+
flex-grow: 1;
27+
display: flex;
28+
padding: 0 2px;
29+
align-items: baseline;
30+
box-sizing: content-box;
31+
32+
&__divider {
33+
padding: 1px 0;
34+
}
1935

2036
&__input {
21-
@digit-width: .54em;
22-
@dot-width: .217em;
23-
// own padding + inputs padding + digits width + dots width
24-
min-width: calc(~"4px + (4px * 3) + " @digit-width * 8 ~" + " @dot-width * 2);
25-
flex-grow: 1;
26-
display: flex;
27-
padding: 0 2px;
28-
align-items: baseline;
29-
30-
&__divider {
31-
padding: 1px 0;
37+
min-width: @digit-width;
38+
height: 100%;
39+
position: relative;
40+
padding: 0 1px;
41+
border: 0;
42+
background: none;
43+
font: inherit;
44+
box-sizing: content-box;
45+
-moz-appearance: textfield;
46+
47+
&::-webkit-outer-spin-button,
48+
&::-webkit-inner-spin-button {
49+
-webkit-appearance: none;
50+
margin: 0;
3251
}
3352

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-
}
50-
51-
&:invalid {
52-
background: fade(red, 10%);
53-
}
53+
&:invalid {
54+
background: fade(red, 10%);
55+
}
5456

55-
&--hasLeadingZero {
56-
margin-left: -@digit-width;
57-
padding-left: calc(~"1px + " @digit-width);
58-
}
57+
&--hasLeadingZero {
58+
margin-left: -@digit-width;
59+
padding-left: calc(~"1px + " @digit-width);
5960
}
6061
}
62+
}
6163

62-
&__icon {
63-
border: 0;
64-
background: transparent;
65-
padding: 4px 6px;
64+
&__button {
65+
border: 0;
66+
background: transparent;
67+
padding: 4px 6px;
6668

67-
&:enabled {
68-
cursor: pointer;
69+
&:enabled {
70+
cursor: pointer;
6971

70-
&:hover, &:focus {
71-
svg {
72-
g {
73-
stroke: rgb(0, 120, 215);
74-
}
75-
}
76-
}
77-
}
78-
79-
&:disabled {
72+
&:hover, &:focus {
8073
svg {
8174
g {
82-
stroke: rgb(109, 109, 109);
75+
stroke: rgb(0, 120, 215);
8376
}
8477
}
8578
}
79+
}
8680

81+
&:disabled {
8782
svg {
88-
display: inherit;
83+
g {
84+
stroke: rgb(109, 109, 109);
85+
}
8986
}
9087
}
88+
89+
svg {
90+
display: inherit;
91+
}
9192
}
9293

9394
&__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-date-picker__button__input__divider">
5+
<span className="react-date-picker__inputGroup__divider">
66
{children}
77
</span>
88
);

src/__tests__/DateInput.jsx

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

2424
describe('DateInput', () => {
2525
const defaultProps = {
26-
className: 'react-date-picker__button__input',
26+
className: 'react-date-picker__inputGroup',
2727
};
2828

2929
it('renders a native input and custom inputs', () => {
@@ -150,7 +150,7 @@ describe('DateInput', () => {
150150
<DateInput {...defaultProps} />
151151
);
152152

153-
const separators = component.find('.react-date-picker__button__input__divider');
153+
const separators = component.find('.react-date-picker__inputGroup__divider');
154154

155155
expect(separators).toHaveLength(2);
156156
expect(separators.at(0).text()).toBe('/');
@@ -164,7 +164,7 @@ describe('DateInput', () => {
164164
/>
165165
);
166166

167-
const separators = component.find('.react-date-picker__button__input__divider');
167+
const separators = component.find('.react-date-picker__inputGroup__divider');
168168
const customInputs = component.find('input[type="number"]');
169169

170170
expect(separators).toHaveLength(customInputs.length - 1);
@@ -201,7 +201,7 @@ describe('DateInput', () => {
201201

202202
expect(document.activeElement).toBe(dayInput.getDOMNode());
203203

204-
const separators = component.find('.react-date-picker__button__input__divider');
204+
const separators = component.find('.react-date-picker__inputGroup__divider');
205205
const separatorKey = separators.at(0).text();
206206
dayInput.simulate('keydown', getKey(separatorKey));
207207

0 commit comments

Comments
 (0)