Completes the Bootstrap 4->5 migration now that every jQuery/BS4 widget is React
(navbar, carousel, dropdowns) — plus the feedback toggle here (Feedback.js:
global `$('#feedback-form').toggle()` -> React state).
- Load Bootstrap 5 CSS from the `bootstrap` npm package in client/index.js
(imported first so app + component styles and react-bootstrap override it).
- Remove the `alexwine:bootstrap-4` meteor package (BS4 CSS + jQuery + BS4 JS).
jQuery for jquery-validation still comes from the npm `jquery` dep.
- Utility renames to BS5: ml-auto->ms-auto, float-right->float-end,
btn-block->w-100, data-toggle->data-bs-toggle (FromNow tooltip).
- forms.scss `.form-label` is no longer a shim (BS5 ships it); comment updated.
Full-app build boots clean; server suite 36 passing. Needs a visual staging pass
across all pages (BS4->5 shifts grid gutters/typography); forms should improve
since react-bootstrap v2 already emitted BS5 markup.
61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
/* eslint-disable react/jsx-indent-props */
|
|
/* eslint-disable import/no-absolute-path */
|
|
|
|
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
|
import Chronos from '/imports/ui/components/Chronos/Chronos';
|
|
import { withTranslation } from 'react-i18next';
|
|
import { dateLongFormat } from '/imports/api/Common/dates';
|
|
|
|
import './FromNow.scss';
|
|
|
|
class FromNow extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
when: props.when
|
|
};
|
|
}
|
|
|
|
// state.when just mirrors props.when (was UNSAFE_componentWillReceiveProps)
|
|
static getDerivedStateFromProps(props, state) {
|
|
return props.when !== state.when ? { when: props.when } : null;
|
|
}
|
|
|
|
shouldComponentUpdate(nextProps, nextState) {
|
|
return !(nextState.when === this.state.when);
|
|
}
|
|
|
|
thatIs() {
|
|
return this.props.t('esDecirTalDia', { date: dateLongFormat(this.props.whenDate) });
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<span data-bs-toggle="tooltip" className="from-now" title={this.thatIs()}>{this.state.when}</span>
|
|
);
|
|
}
|
|
}
|
|
|
|
FromNow.propTypes = {
|
|
t: PropTypes.func.isRequired,
|
|
when: PropTypes.string,
|
|
whenDate: PropTypes.instanceOf(Date)
|
|
};
|
|
|
|
/*
|
|
* const FromNowContainer = withTracker((props) => {
|
|
*
|
|
* })(FromNow);
|
|
*
|
|
* export default FromNowContainer;
|
|
* */
|
|
|
|
export default withTranslation()(withTracker((props) => {
|
|
const whenDate = props.when;
|
|
return {
|
|
when: whenDate ? Chronos.moment(whenDate).fromNow() : null,
|
|
whenDate
|
|
};
|
|
})(FromNow));
|