mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 04:18:29 +08:00
扩充下datepicker的可选快捷键、样式fix
This commit is contained in:
parent
b66ba7598d
commit
58849b22c7
@ -87,6 +87,7 @@
|
||||
background: $Calendar-shortcuts-bg;
|
||||
padding: ($Calendar-shortcuts-height - $Calendar-fontSize * $lineHeightBase) / 2 $gap-sm;
|
||||
list-style: none;
|
||||
width: px2rem(250px);
|
||||
|
||||
&+.rdt .rdtPicker {
|
||||
padding-top: 0;
|
||||
@ -95,7 +96,7 @@
|
||||
|
||||
.#{$ns}DatePicker-shortcut {
|
||||
display: inline-block;
|
||||
margin-right: $gap-md;
|
||||
margin-right: $gap-sm;
|
||||
|
||||
a {
|
||||
font-size: $Calendar-fontSize;
|
||||
|
@ -17,6 +17,12 @@ import Calendar from './calendar/Calendar';
|
||||
import 'react-datetime/css/react-datetime.css';
|
||||
|
||||
const availableShortcuts: {[propName: string]: any} = {
|
||||
now: {
|
||||
label: '现在',
|
||||
date: (now: moment.Moment) => {
|
||||
return now;
|
||||
}
|
||||
},
|
||||
today: {
|
||||
label: '今天',
|
||||
date: (now: moment.Moment) => {
|
||||
@ -89,6 +95,28 @@ const availableShortcuts: {[propName: string]: any} = {
|
||||
};
|
||||
|
||||
const advancedShortcuts = [
|
||||
{
|
||||
regexp: /^(\d+)hoursago$/,
|
||||
resolve: (_: string, hours: string) => {
|
||||
return {
|
||||
label: `${hours}小时前`,
|
||||
date: (now: moment.Moment) => {
|
||||
return now.subtract(hours, 'hours');
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
regexp: /^(\d+)hourslater$/,
|
||||
resolve: (_: string, hours: string) => {
|
||||
return {
|
||||
label: `${hours}小时后`,
|
||||
date: (now: moment.Moment) => {
|
||||
return now.add(hours, 'hours');
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
regexp: /^(\d+)daysago$/,
|
||||
resolve: (_: string, days: string) => {
|
||||
|
Loading…
Reference in New Issue
Block a user