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