-
-
Notifications
You must be signed in to change notification settings - Fork 533
Expand file tree
/
Copy pathDecade.jsx
More file actions
38 lines (32 loc) · 992 Bytes
/
Decade.jsx
File metadata and controls
38 lines (32 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from 'react';
import PropTypes from 'prop-types';
import { getDecadeStart, getDecadeEnd } from '@wojtekmaj/date-utils';
import Tile from '../Tile';
import { getDecadeLabel } from '../shared/dates';
import { formatYear as defaultFormatYear } from '../shared/dateFormatter';
import { tileProps } from '../shared/propTypes';
const className = 'react-calendar__century-view__decades__decade';
export default function Decade({
activeTabDate,
classes,
formatYear = defaultFormatYear,
...otherProps
}) {
const { date, locale } = otherProps;
return (
<Tile
{...otherProps}
classes={[].concat(classes, className)}
isFocusable={activeTabDate <= getDecadeEnd(date) && activeTabDate >= getDecadeStart(date)}
maxDateTransform={getDecadeEnd}
minDateTransform={getDecadeStart}
view="century"
>
{getDecadeLabel(locale, formatYear, date)}
</Tile>
);
}
Decade.propTypes = {
...tileProps,
formatYear: PropTypes.func,
};