-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add showAllWeekdayLabels option to show all weekdays. #87
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,7 +297,7 @@ class CalendarHeatmap extends React.Component { | |
const [x, y] = this.getWeekdayLabelCoordinates(dayIndex); | ||
const cssClasses = `${this.latestProps.horizontal ? '' : `${CSS_PSEDUO_NAMESPACE}small-text`} ${CSS_PSEDUO_NAMESPACE}weekday-label`; | ||
// eslint-disable-next-line no-bitwise | ||
return dayIndex & 1 ? ( | ||
return this.latestProps.showAllWeekdayLabels || dayIndex & 1 ? ( | ||
<text key={`${x}${y}`} x={x} y={y} className={cssClasses}> | ||
{weekdayLabel} | ||
</text> | ||
|
@@ -333,6 +333,7 @@ CalendarHeatmap.propTypes = { | |
horizontal: PropTypes.bool, // whether to orient horizontally or vertically | ||
showMonthLabels: PropTypes.bool, // whether to show month labels | ||
showWeekdayLabels: PropTypes.bool, // whether to show weekday labels | ||
showAllWeekdayLabels: PropTypes.bool, // whether to show all weekday labels | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you also document this prop in the readme? |
||
showOutOfRangeDays: PropTypes.bool, // whether to render squares for extra days in week after endDate, and before start date | ||
tooltipDataAttrs: PropTypes.oneOfType([PropTypes.object, PropTypes.func]), // data attributes to add to square for setting 3rd party tooltips, e.g. { 'data-toggle': 'tooltip' } for bootstrap tooltips | ||
titleForValue: PropTypes.func, // function which returns title text for value | ||
|
@@ -352,6 +353,7 @@ CalendarHeatmap.defaultProps = { | |
horizontal: true, | ||
showMonthLabels: true, | ||
showWeekdayLabels: false, | ||
showAllWeekdayLabels: false, | ||
showOutOfRangeDays: false, | ||
monthLabels: MONTH_LABELS, | ||
weekdayLabels: DAY_LABELS, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,28 @@ describe('CalendarHeatmap props', () => { | |
expect(vertical.find('text.react-calendar-heatmap-small-text')).toHaveLength(3); | ||
}); | ||
|
||
it('showAllWeekdayLabels true', () => { | ||
const calendar = shallow(<CalendarHeatmap | ||
startDate={dateNDaysAgo(7)} | ||
values={[]} | ||
showWeekdayLabels={true} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you think folks should have to pass both |
||
showAllWeekdayLabels={true} | ||
/>); | ||
|
||
expect(calendar.find('text').length).toEqual(7); | ||
}); | ||
|
||
it('showAllWeekdayLabels false', () => { | ||
const calendar = shallow(<CalendarHeatmap | ||
startDate={dateNDaysAgo(7)} | ||
values={[]} | ||
showWeekdayLabels={true} | ||
showAllWeekdayLabels={false} | ||
/>); | ||
|
||
expect(calendar.find('text').length).toEqual(3); | ||
}); | ||
|
||
it('transformDayElement', () => { | ||
const transform = rect => React.cloneElement(rect, { 'data-test': 'ok' }); | ||
const today = new Date(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be in
jest.config.js
instead?