Skip to content

Commit 9c6cffb

Browse files
committed
refact: Change lots of className
1 parent 1d60a7b commit 9c6cffb

File tree

14 files changed

+124
-152
lines changed

14 files changed

+124
-152
lines changed

assets/index.less

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -31,78 +31,78 @@
3131
display: flex;
3232
flex-direction: column;
3333

34-
// Header
35-
&-header {
36-
display: flex;
37-
38-
> * {
39-
flex: none;
40-
}
34+
table {
35+
text-align: center;
36+
}
37+
}
4138

42-
&-view {
43-
flex: auto;
44-
text-align: center;
39+
// Header
40+
&-header {
41+
display: flex;
4542

46-
> button {
47-
border: 0;
48-
padding: 0;
49-
}
50-
}
43+
> * {
44+
flex: none;
5145
}
5246

53-
// Content
54-
&-cell {
55-
color: #aaa;
56-
57-
&-disabled {
58-
opacity: 0.2;
59-
}
47+
&-view {
48+
flex: auto;
49+
text-align: center;
6050

61-
&-inner {
62-
font-size: 12px;
63-
width: 100%;
64-
height: 20px;
65-
line-height: 20px;
66-
display: inline-block;
67-
box-sizing: border-box;
51+
> button {
6852
border: 0;
6953
padding: 0;
70-
margin: 0;
71-
background: transparent;
72-
cursor: pointer;
73-
outline: none;
74-
border: none;
75-
transition: background 0.3s, border 0.3s;
76-
77-
&:hover {
78-
background: fade(blue, 30%) !important;
79-
}
8054
}
55+
}
56+
}
8157

82-
&-in-view {
83-
color: #333;
84-
}
58+
// Content
59+
&-cell {
60+
color: #aaa;
8561

86-
&-in-range > &-inner {
87-
background: fade(blue, 5%);
88-
}
89-
&-today > &-inner {
90-
border: 1px solid blue;
91-
}
92-
&-selected > &-inner {
93-
background: fade(blue, 20%);
62+
&-disabled {
63+
opacity: 0.2;
64+
}
65+
66+
&-inner {
67+
font-size: 12px;
68+
width: 100%;
69+
height: 20px;
70+
line-height: 20px;
71+
display: inline-block;
72+
box-sizing: border-box;
73+
border: 0;
74+
padding: 0;
75+
margin: 0;
76+
background: transparent;
77+
cursor: pointer;
78+
outline: none;
79+
border: none;
80+
transition: background 0.3s, border 0.3s;
81+
82+
&:hover {
83+
background: fade(blue, 30%) !important;
9484
}
9585
}
9686

97-
table {
98-
text-align: center;
87+
&-in-view {
88+
color: #333;
89+
}
90+
91+
&-in-range > &-inner {
92+
background: fade(blue, 5%);
93+
}
94+
&-today > &-inner {
95+
border: 1px solid blue;
96+
}
97+
&-selected > &-inner {
98+
background: fade(blue, 20%);
9999
}
100100
}
101101

102102
// ================== Year & Month Panel ==================
103103
&-year-panel,
104104
&-month-panel {
105-
&-cell-inner {
105+
.@{prefix-cls}-cell-inner {
106106
width: 80px;
107107
}
108108
}
@@ -111,38 +111,38 @@
111111
&-week-panel {
112112
&-row {
113113
&:hover {
114-
.@{prefix-cls}-week-panel-cell {
114+
.@{prefix-cls}-cell {
115115
background: red;
116116
}
117117
}
118118

119119
&-selected {
120-
.@{prefix-cls}-week-panel-cell {
120+
.@{prefix-cls}-cell {
121121
background: rgba(0, 0, 255, 0.3);
122122
}
123123
}
124124
}
125125

126-
&-cell,
127-
&-cell-inner {
126+
.@{prefix-cls}-cell,
127+
.@{prefix-cls}-cell-inner {
128128
width: 20px;
129129
}
130130

131-
&-cell-week {
131+
.@{prefix-cls}-cell-week {
132132
font-size: 12px;
133133
color: #999;
134134
font-weight: bold;
135135
}
136136

137-
&-cell:hover > &-cell-inner,
138-
&-cell-selected > &-cell-inner {
137+
.@{prefix-cls}-cell:hover > .@{prefix-cls}-cell-inner,
138+
.@{prefix-cls}-cell-selected > .@{prefix-cls}-cell-inner {
139139
background: transparent;
140140
}
141141
}
142142

143143
// ====================== Date Panel ======================
144144
&-date-panel {
145-
&-cell-inner {
145+
.@{prefix-cls}-cell-inner {
146146
width: 20px;
147147
}
148148
}
@@ -151,7 +151,7 @@
151151
&-time-panel {
152152
width: auto;
153153

154-
&-content {
154+
.@{prefix-cls}-content {
155155
display: flex;
156156
max-height: 200px;
157157
}
@@ -163,8 +163,10 @@
163163
margin: 0;
164164
padding: 0 0 180px 0;
165165
overflow-y: hidden;
166+
overflow-x: hidden;
166167
width: 50px;
167168
transition: background 0.3s;
169+
font-size: 12px;
168170

169171
&-active {
170172
background: rgba(0, 0, 255, 0.1);

src/panels/DatePanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function DatePanel<DateType>(props: DatePanelProps<DateType>) {
7373
>
7474
<DateHeader
7575
{...props}
76-
prefixCls={panelPrefixCls}
76+
prefixCls={prefixCls}
7777
value={value}
7878
viewDate={viewDate}
7979
// View Operation
@@ -98,7 +98,7 @@ function DatePanel<DateType>(props: DatePanelProps<DateType>) {
9898
/>
9999
<DateBody
100100
{...props}
101-
prefixCls={panelPrefixCls}
101+
prefixCls={prefixCls}
102102
value={value}
103103
viewDate={viewDate}
104104
rowCount={DATE_ROW_COUNT}

src/panels/DecadePanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function DecadePanel<DateType>(props: DecadePanelProps<DateType>) {
6464
<div className={panelPrefixCls}>
6565
<DecadeHeader
6666
{...props}
67-
prefixCls={panelPrefixCls}
67+
prefixCls={prefixCls}
6868
onPrevDecades={() => {
6969
onDecadesChange(-1);
7070
}}
@@ -74,7 +74,7 @@ function DecadePanel<DateType>(props: DecadePanelProps<DateType>) {
7474
/>
7575
<DecadeBody
7676
{...props}
77-
prefixCls={panelPrefixCls}
77+
prefixCls={prefixCls}
7878
onSelect={onInternalSelect}
7979
/>
8080
</div>

src/panels/MonthPanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function MonthPanel<DateType>(props: MonthPanelProps<DateType>) {
5252
<div className={panelPrefixCls}>
5353
<MonthHeader
5454
{...props}
55-
prefixCls={panelPrefixCls}
55+
prefixCls={prefixCls}
5656
onPrevYear={() => {
5757
onYearChange(-1);
5858
}}
@@ -65,7 +65,7 @@ function MonthPanel<DateType>(props: MonthPanelProps<DateType>) {
6565
/>
6666
<MonthBody<DateType>
6767
{...props}
68-
prefixCls={panelPrefixCls}
68+
prefixCls={prefixCls}
6969
onSelect={date => {
7070
onSelect(date);
7171
onPanelChange('date', date);

src/panels/TimePanel/TimeBody.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function TimeBody<DateType>(props: TimeBodyProps<DateType>) {
6464
onSelect: (diff: number) => void;
6565
}[] = [];
6666
const contentPrefixCls = `${prefixCls}-content`;
67+
const columnPrefixCls = `${prefixCls}-time-panel`;
6768

6869
let isPM: boolean | undefined;
6970
let hour = value ? generateConfig.getHour(value) : -1;
@@ -155,6 +156,7 @@ function TimeBody<DateType>(props: TimeBodyProps<DateType>) {
155156
if (condition !== false) {
156157
columns.push({
157158
node: React.cloneElement(node, {
159+
prefixCls: columnPrefixCls,
158160
value: columnValue,
159161
active: activeColumnIndex === columns.length,
160162
onSelect: onColumnSelect,
@@ -169,20 +171,14 @@ function TimeBody<DateType>(props: TimeBodyProps<DateType>) {
169171
}
170172

171173
// Hour
172-
addColumnNode(
173-
showHour,
174-
<TimeUnitColumn key="hour" prefixCls={prefixCls} />,
175-
hour,
176-
hours,
177-
num => {
178-
onSelect(setTime(isPM, num, minute, second));
179-
},
180-
);
174+
addColumnNode(showHour, <TimeUnitColumn key="hour" />, hour, hours, num => {
175+
onSelect(setTime(isPM, num, minute, second));
176+
});
181177

182178
// Minute
183179
addColumnNode(
184180
showMinute,
185-
<TimeUnitColumn key="minute" prefixCls={prefixCls} />,
181+
<TimeUnitColumn key="minute" />,
186182
minute,
187183
minutes,
188184
num => {
@@ -193,7 +189,7 @@ function TimeBody<DateType>(props: TimeBodyProps<DateType>) {
193189
// Second
194190
addColumnNode(
195191
showSecond,
196-
<TimeUnitColumn key="second" prefixCls={prefixCls} />,
192+
<TimeUnitColumn key="second" />,
197193
second,
198194
seconds,
199195
num => {
@@ -209,7 +205,7 @@ function TimeBody<DateType>(props: TimeBodyProps<DateType>) {
209205

210206
addColumnNode(
211207
use12Hours === true,
212-
<TimeUnitColumn key="12hours" prefixCls={prefixCls} />,
208+
<TimeUnitColumn key="12hours" />,
213209
PMIndex,
214210
[{ label: 'AM', value: 0 }, { label: 'PM', value: 1 }],
215211
num => {

src/panels/TimePanel/TimeUnitColumn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface Unit {
99
}
1010

1111
export interface TimeUnitColumnProps {
12-
prefixCls: string;
12+
prefixCls?: string;
1313
units?: Unit[];
1414
value?: number;
1515
active?: boolean;

src/panels/TimePanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ function TimePanel<DateType>(props: TimePanelProps<DateType>) {
8686
[`${panelPrefixCls}-active`]: active,
8787
})}
8888
>
89-
<TimeHeader {...props} format={format} prefixCls={panelPrefixCls} />
89+
<TimeHeader {...props} format={format} prefixCls={prefixCls} />
9090
<TimeBody
9191
{...props}
92-
prefixCls={panelPrefixCls}
92+
prefixCls={prefixCls}
9393
activeColumnIndex={activeColumnIndex}
9494
operationRef={bodyOperationRef}
9595
/>

src/panels/WeekPanel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function WeekPanel<DateType>(props: WeekPanelProps<DateType>) {
1010
const { prefixCls, generateConfig, locale, value } = props;
1111

1212
// Render additional column
13-
const cellPrefixCls = `${prefixCls}-week-panel-cell`;
13+
const cellPrefixCls = `${prefixCls}-cell`;
1414
const prefixColumn = (date: DateType) => (
1515
<td
1616
key="week"

src/panels/YearPanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function YearPanel<DateType>(props: YearPanelProps<DateType>) {
5454
<div className={panelPrefixCls}>
5555
<YearHeader
5656
{...props}
57-
prefixCls={panelPrefixCls}
57+
prefixCls={prefixCls}
5858
onPrevDecade={() => {
5959
onDecadeChange(-1);
6060
}}
@@ -67,7 +67,7 @@ function YearPanel<DateType>(props: YearPanelProps<DateType>) {
6767
/>
6868
<YearBody
6969
{...props}
70-
prefixCls={panelPrefixCls}
70+
prefixCls={prefixCls}
7171
onSelect={date => {
7272
onPanelChange('month', date);
7373
onSelect(date);

tests/__snapshots__/panel.spec.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ exports[`Panel time disabled columns 1`] = `
99
class="rc-picker-time-panel"
1010
>
1111
<div
12-
class="rc-picker-time-panel-header"
12+
class="rc-picker-header"
1313
>
1414
<div
15-
class="rc-picker-time-panel-header-view"
15+
class="rc-picker-header-view"
1616
>
1717
 
1818
</div>
1919
</div>
2020
<div
21-
class="rc-picker-time-panel-content"
21+
class="rc-picker-content"
2222
>
2323
<ul
2424
class="rc-picker-time-panel-column"

0 commit comments

Comments
 (0)