Skip to content

Commit

Permalink
fix(DatePicker, TimePicker): fix style (#1453)
Browse files Browse the repository at this point in the history
Co-authored-by: ZhaoChen <ittisennsinn@gmail.com>
  • Loading branch information
itiiss and itiisennsinn authored Nov 10, 2021
1 parent 695e2dc commit 9991fad
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 30 deletions.
10 changes: 6 additions & 4 deletions src/date-range-picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ export const DateRangePicker: React.FC<DateRangePickerProps> = (props: DateRange
const prefixCls = usePrefixCls('date-range-picker-new');
const overlayCls = classnames(`${prefixCls}-overlay`, overlayClassName);

const validValue = (val: [NullableDate, NullableDate]) => val?.filter((v) => !!v)?.length === 2;

const [visible, setVisible] = useControlledState(popoverVisible, false);

const [controlledValue, setControlledValue] = useControlledState<[NullableDate, NullableDate] | undefined>(
value,
defaultValue
const [controlledValue, setControlledValue] = useControlledState<[NullableDate, NullableDate]>(
value as [NullableDate, NullableDate],
defaultValue as [NullableDate, NullableDate]
);

const handleVisibleChange = (current: boolean) => {
Expand Down Expand Up @@ -75,7 +77,7 @@ export const DateRangePicker: React.FC<DateRangePickerProps> = (props: DateRange
placeholder={placeholder}
disabled={disabled}
allowClear={allowClear}
value={controlledValue && formatDates(controlledValue)}
value={validValue(controlledValue) ? formatDates(controlledValue) : undefined}
size={size}
suffix={suffix}
hidePrefix={hidePrefix}
Expand Down
37 changes: 16 additions & 21 deletions src/static-date-picker/style/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../stylesheet/index.less';
@import '../../stylesheet/mixin/index.less';
@import '../../stylesheet/variables/index.less';

@new-date-picker-prefix-cls: ~'@{component-prefix}-picker';
@icon-prefix-cls: ~'@{component-prefix}-icon';
Expand All @@ -10,9 +12,9 @@
height: 24px;
.font(@weight: 500);

color: @palette-black-6;
color: @gray-5;
line-height: 22px;
background: @palette-white;
background: @gray-0;
border: none;
border-radius: 4px;
cursor: pointer;
Expand All @@ -31,7 +33,7 @@
&-panel {
width: 280px;
text-align: center;
background: @palette-white;
background: @gray-0;
border-radius: 4px;
filter: drop-shadow(0 8px 24px rgba(36, 46, 89, 0.1));
}
Expand All @@ -53,13 +55,13 @@
height: 24px;
margin: 0 2px;
padding: 4px;
background: @palette-white;
background: @gray-0;
border: none;
border-radius: 4px;
cursor: pointer;

.@{icon-prefix-cls} {
color: @palette-black-6;
color: @gray-5;
}
}
&-super-prev-btn {
Expand All @@ -83,7 +85,7 @@

&-view {
flex-grow: 1;
color: @palette-black-6;
color: @gray-5;
line-height: 24px;
text-align: center;
.font(@weight: 500);
Expand All @@ -93,7 +95,7 @@
&-body {
box-sizing: border-box;
padding: 20px;
background: @palette-white;
background: @gray-0;
border-radius: 0 0 4px 4px;
}
&-decade-panel > &-body {
Expand All @@ -113,7 +115,7 @@
tr > th {
.font();
margin: 5px;
color: @palette-black-6;
color: @gray-5;

line-height: 22px;
text-align: center;
Expand All @@ -123,7 +125,6 @@
&-cell {
box-sizing: border-box;
padding: 4px 0;
color: @palette-black-3;
cursor: pointer;

&::before {
Expand Down Expand Up @@ -152,15 +153,16 @@
}

&-in-view {
color: @palette-black-6;
color: @gray-5;
}

&-today {
font-weight: 500;
}

&-in-view&-today {
color: @palette-blue-4;
color: @blue-3;
font-weight: 400;
}
&-in-view&-today &-inner::before {
position: absolute;
Expand All @@ -169,16 +171,16 @@
bottom: 0;
left: 0;
z-index: 1;
border: 1px solid @palette-blue-4;
border: 1px solid @blue-3;
border-radius: 4px;
content: '';
}

&-in-view&-selected {
color: @palette-white;
color: @gray-0;
}
&-in-view&-selected &-inner {
background: @palette-blue-4;
background: @blue-3;
}

&-disabled {
Expand All @@ -189,13 +191,6 @@
background: @palette-gray-1;
}
}
&-disabled&-in-view,
&-disabled&-today {
color: @palette-black-3;
}
&-disabled&-today &-inner::before {
border-color: @palette-black-3;
}
}

&-date-panel &-cell::before {
Expand Down
4 changes: 3 additions & 1 deletion src/static-date-range-picker/style/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../stylesheet/index.less';
@import '../../stylesheet/mixin/index.less';
@import '../../stylesheet/variables/index.less';

@date-range-picker-prefix-cls: ~'@{component-prefix}-date-range-picker';
@picker-prefix-cls: ~'@{component-prefix}-picker';
Expand All @@ -24,7 +26,7 @@
&-cell {
&-in-view&-range-start,
&-in-view&-range-end {
color: @palette-white;
color: @gray-0;
}
&-in-view&-range-start &-inner,
&-in-view&-range-end &-inner {
Expand Down
10 changes: 6 additions & 4 deletions src/static-time-picker/style/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../stylesheet/index.less';
@import '../../stylesheet/mixin/index.less';
@import '../../stylesheet/variables/index.less';

@new-time-picker-prefix-cls: ~'@{component-prefix}-new-time-picker';

Expand All @@ -9,7 +11,7 @@
width: fit-content;
height: fit-content;
padding-top: 4px;
background-color: @palette-white;
background-color: @gray-0;
filter: drop-shadow(0 8px 24px rgba(36, 46, 89, 0.1));
}
&--three-columns {
Expand Down Expand Up @@ -44,11 +46,11 @@
&-cell {
margin-top: 4px;
padding: 4px 12px;
color: @palette-black-6;
color: @gray-5;
.font();
line-height: 22px;
list-style-type: none;
background-color: @palette-white;
background-color: @gray-0;
border-radius: 4px;
cursor: pointer;

Expand All @@ -58,7 +60,7 @@

&-selected,
&:active {
color: @palette-blue-5;
color: @blue-3;
font-weight: 500;
background-color: @palette-gray-1;
}
Expand Down

1 comment on commit 9991fad

@vercel
Copy link

@vercel vercel bot commented on 9991fad Nov 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.