Skip to content

Commit

Permalink
Merge pull request #72 from rainyLeo/feat/headerSelect
Browse files Browse the repository at this point in the history
Add Calendar Config
  • Loading branch information
veryStarters committed Aug 27, 2020
2 parents 3a3b3ad + 9a75c9d commit 82d5b05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/CalendarFullHeader.jsx
Expand Up @@ -127,8 +127,8 @@ class CalendarHeader extends Component {
}

todayElement() {
const { showToday, locale } = this.props;
const isSuperMini = this.fullHeader ? this.fullHeader.offsetWidth <= 380 : false;
const { showToday, locale, miniOffset } = this.props;
const isSuperMini = this.fullHeader ? this.fullHeader.offsetWidth <= miniOffset : false;
const cls = classnames({
'today-btn': true,
'super-mini': isSuperMini,
Expand Down Expand Up @@ -176,11 +176,11 @@ class CalendarHeader extends Component {
}

renderSwitcher() {
const { showTypeSwitch } = this.props;
const { showTypeSwitch, miniOffset } = this.props;
if (!showTypeSwitch) {
return null;
}
if (this.fullHeader && this.fullHeader.offsetWidth < 380) {
if (this.fullHeader && this.fullHeader.offsetWidth < miniOffset) {
return this.getSelectSwitcher();
}
return this.getExpandedSwitcher();
Expand All @@ -206,6 +206,7 @@ class CalendarHeader extends Component {
CalendarHeader.propTypes = {
yearSelectOffset: PropTypes.number,
yearSelectTotal: PropTypes.number,
miniOffset: PropTypes.number,
onValueChange: PropTypes.func,
typeChange: PropTypes.func,
prefixCls: PropTypes.string,
Expand All @@ -216,6 +217,7 @@ CalendarHeader.propTypes = {
CalendarHeader.defaultProps = {
yearSelectOffset: 10,
yearSelectTotal: 20,
miniOffset: 380,
onValueChange: null,
showToday: true,
type: 'time',
Expand Down
12 changes: 6 additions & 6 deletions src/calendarFullUtil.js
Expand Up @@ -852,7 +852,7 @@ function getVisibleEvent(events, maxCount, opts, callback = () => {}) {
}}
>
<div
className="kuma-calendar-content-wraper"
className={classnames('kuma-calendar-content-wraper', { [originEvt.contentWrapperClass]: originEvt.contentWrapperClass })}
data-event-name={originEvt.name}
onMouseEnter={(e) => {
const eventName = e.currentTarget.getAttribute("data-event-name");
Expand All @@ -869,8 +869,8 @@ function getVisibleEvent(events, maxCount, opts, callback = () => {}) {
}}
>
<div
className="kuma-calendar-content-detail"
title={typeof content !== "object" ? content : ""}
className={classnames('kuma-calendar-content-detail', { [originEvt.contentDetailClass]: originEvt.contentDetailClass })}
title={typeof content !== 'object' ? content : ''}
style={originEvt.style || {}}
>
{!!important && (
Expand Down Expand Up @@ -942,7 +942,7 @@ function sortEventsByCount(evets) {
* render: function(){}
* })
*/
const generateScheduleContent = (events, callback) =>
const generateScheduleContent = (events, callback, defaultMaxCount) =>
function scheduleRender(evts, opts, tableHeight) {
if (!evts || !evts.length) {
return;
Expand Down Expand Up @@ -1009,8 +1009,8 @@ const generateScheduleContent = (events, callback) =>

resultScheduleHtml.push(
<div className={containerCls} key={i} style={containerStyle}>
{getVisibleEvent(newRangeEvents, monthMaxCount, opts, callback)}
</div>
{getVisibleEvent(rangeEvents, defaultMaxCount || monthMaxCount, opts, callback)}
</div>,
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/date/DateTable.jsx
Expand Up @@ -44,12 +44,12 @@ export default class DateTable extends React.Component {
}

render() {
const { prefixCls } = this.props;
const { prefixCls, defaultCellHeight } = this.props;
const fullTableHeight = this.fullTable ? this.fullTable.offsetHeight : 0;
const cellHeight = 0.8 * (fullTableHeight - 32) / 6;
const tableCls = classnames({
[`${prefixCls}-table`]: true,
'super-mini': cellHeight <= 42 && cellHeight > 0,
'super-mini': cellHeight <= (defaultCellHeight || 42) && cellHeight > 0,

});
return (
Expand Down

0 comments on commit 82d5b05

Please sign in to comment.