mirror of
https://github.com/plankanban/planka.git
synced 2025-12-26 01:11:58 +03:00
Rename deadline to due date, update dependencies
This commit is contained in:
78
client/src/components/DueDate/DueDate.jsx
Normal file
78
client/src/components/DueDate/DueDate.jsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import styles from './DueDate.module.css';
|
||||
|
||||
const SIZES = {
|
||||
TINY: 'tiny',
|
||||
SMALL: 'small',
|
||||
MEDIUM: 'medium',
|
||||
};
|
||||
|
||||
// TODO: move to styles
|
||||
const STYLES = {
|
||||
tiny: {
|
||||
fontSize: '12px',
|
||||
lineHeight: '20px',
|
||||
padding: '0px 6px',
|
||||
},
|
||||
small: {
|
||||
fontSize: '12px',
|
||||
lineHeight: '20px',
|
||||
padding: '2px 6px',
|
||||
},
|
||||
medium: {
|
||||
lineHeight: '20px',
|
||||
padding: '6px 12px',
|
||||
},
|
||||
};
|
||||
|
||||
const FORMATS = {
|
||||
tiny: 'longDate',
|
||||
small: 'longDate',
|
||||
medium: 'longDateTime',
|
||||
};
|
||||
|
||||
const DueDate = React.memo(({
|
||||
value, size, isDisabled, onClick,
|
||||
}) => {
|
||||
const [t] = useTranslation();
|
||||
|
||||
const style = {
|
||||
...STYLES[size],
|
||||
};
|
||||
|
||||
const contentNode = (
|
||||
<span className={classNames(styles.wrapper, onClick && styles.hoverable)} style={style}>
|
||||
{t(`format:${FORMATS[size]}`, {
|
||||
value,
|
||||
postProcess: 'formatDate',
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
|
||||
return onClick ? (
|
||||
<button type="button" disabled={isDisabled} className={styles.button} onClick={onClick}>
|
||||
{contentNode}
|
||||
</button>
|
||||
) : (
|
||||
contentNode
|
||||
);
|
||||
});
|
||||
|
||||
DueDate.propTypes = {
|
||||
value: PropTypes.instanceOf(Date).isRequired,
|
||||
size: PropTypes.oneOf(Object.values(SIZES)),
|
||||
isDisabled: PropTypes.bool,
|
||||
onClick: PropTypes.func,
|
||||
};
|
||||
|
||||
DueDate.defaultProps = {
|
||||
size: SIZES.MEDIUM,
|
||||
isDisabled: false,
|
||||
onClick: undefined,
|
||||
};
|
||||
|
||||
export default DueDate;
|
||||
25
client/src/components/DueDate/DueDate.module.css
Normal file
25
client/src/components/DueDate/DueDate.module.css
Normal file
@@ -0,0 +1,25 @@
|
||||
.button {
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.hoverable:hover {
|
||||
background: #d2d8dc;
|
||||
color: #17394d;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
background: #dce0e4;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
color: #6a808b;
|
||||
display: inline-block;
|
||||
outline: none;
|
||||
text-align: left;
|
||||
transition: background 0.3s ease;
|
||||
vertical-align: top;
|
||||
}
|
||||
3
client/src/components/DueDate/index.js
Normal file
3
client/src/components/DueDate/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import DueDate from './DueDate';
|
||||
|
||||
export default DueDate;
|
||||
Reference in New Issue
Block a user