Skip to content

Commit

Permalink
Merge pull request #162 from adobecom/MWPW-153167
Browse files Browse the repository at this point in the history
feat(mwpw-153167): ability to hide eventStart/endDate
  • Loading branch information
sheridansunier authored Jul 17, 2024
2 parents e3e7f02 + d815168 commit ed2b197
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion dist/app.css

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Chimera UI Libraries - Build 0.14.1 (7/12/2024, 13:27:43)
* Chimera UI Libraries - Build 0.14.2 (7/17/2024, 13:45:06)
*
*/
/******/ (function(modules) { // webpackBootstrap
Expand Down Expand Up @@ -276,7 +276,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getGlobalNavHeight = exports.getLinkTarget = exports.getEventBanner = exports.getCurrentDate = exports.isDateBeforeInterval = exports.isDateWithinInterval = exports.qs = exports.mergeDeep = exports.setByPath = exports.debounce = exports.getSelectedItemsCount = exports.getByPath = exports.template = exports.getEndNumber = exports.getStartNumber = exports.getPageStartEnd = exports.generateRange = exports.stopPropagation = exports.isAtleastOneFilterSelected = exports.isNullish = exports.parseToPrimitive = exports.isObject = exports.mapObject = exports.sanitizeText = exports.sortByKey = exports.intersection = exports.isSuperset = exports.chainFromIterable = exports.chain = exports.removeDuplicatesByKey = exports.truncateList = exports.truncateString = exports.readInclusionsFromLocalStorage = exports.readBookmarksFromLocalStorage = exports.saveBookmarksToLocalStorage = undefined;
exports.getGlobalNavHeight = exports.getLinkTarget = exports.getEventBanner = exports.getCurrentDate = exports.isDateAfterInterval = exports.isDateBeforeInterval = exports.isDateWithinInterval = exports.qs = exports.mergeDeep = exports.setByPath = exports.debounce = exports.getSelectedItemsCount = exports.getByPath = exports.template = exports.getEndNumber = exports.getStartNumber = exports.getPageStartEnd = exports.generateRange = exports.stopPropagation = exports.isAtleastOneFilterSelected = exports.isNullish = exports.parseToPrimitive = exports.isObject = exports.mapObject = exports.sanitizeText = exports.sortByKey = exports.intersection = exports.isSuperset = exports.chainFromIterable = exports.chain = exports.removeDuplicatesByKey = exports.truncateList = exports.truncateString = exports.readInclusionsFromLocalStorage = exports.readBookmarksFromLocalStorage = exports.saveBookmarksToLocalStorage = undefined;

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

Expand Down Expand Up @@ -847,6 +847,13 @@ var isDateBeforeInterval = exports.isDateBeforeInterval = function isDateBeforeI
return curr < start;
};

var isDateAfterInterval = exports.isDateAfterInterval = function isDateAfterInterval(currentDate, endDate) {
var curr = Date.parse(currentDate);
var end = Date.parse(endDate);

return curr > end;
};

var getCurrentDate = exports.getCurrentDate = function getCurrentDate() {
var urlParams = new URLSearchParams(window.location.search);
var servertime = parseInt(urlParams.get('servertime'), 10);
Expand Down Expand Up @@ -46793,6 +46800,7 @@ var Card = function Card(props) {
var detailsTextOption = getConfig('collection', 'detailsTextOption');
var lastModified = getConfig('collection', 'i18n.lastModified');
var registrationUrl = getConfig('collection', 'banner.register.url');
var hideDateInterval = getConfig('collection', 'hideDateInterval');

/**
* Class name for the card:
Expand Down Expand Up @@ -46899,6 +46907,7 @@ var Card = function Card(props) {
var isEventsCard = origin === 'Events';
var hideBanner = false;
var eventBanner = '';
var hideOnDemandDates = hideDateInterval && (0, _general.isDateAfterInterval)((0, _general.getCurrentDate)(), endDate);

if (isHalfHeight && isGated && !isRegistered) {
bannerDescriptionToUse = bannerMap.register.description;
Expand Down Expand Up @@ -47070,7 +47079,7 @@ var Card = function Card(props) {
divider: renderDivider || footerItem.divider,
isFluid: footerItem.isFluid,
key: (0, _cuid2.default)(),
left: showFooterLeft ? extendFooterData(footerItem.left) : [],
left: showFooterLeft && !hideOnDemandDates ? extendFooterData(footerItem.left) : [],
center: showFooterCenter ? extendFooterData(footerItem.center) : [],
right: extendFooterData(footerItem.right),
cardStyle: cardStyle,
Expand Down
28 changes: 14 additions & 14 deletions dist/main.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/main.source.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions react/src/js/components/Consonant/Cards/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CardFooter from './CardFooter/CardFooter';
import prettyFormatDate from '../Helpers/prettyFormat';
import { INFOBIT_TYPE } from '../Helpers/constants';
import { hasTag } from '../Helpers/Helpers';
import { getEventBanner, getLinkTarget, isDateBeforeInterval, getCurrentDate } from '../Helpers/general';
import { getEventBanner, getLinkTarget, isDateBeforeInterval, isDateAfterInterval, getCurrentDate } from '../Helpers/general';
import { useConfig, useRegistered } from '../Helpers/hooks';
import {
stylesType,
Expand Down Expand Up @@ -172,6 +172,7 @@ const Card = (props) => {
const detailsTextOption = getConfig('collection', 'detailsTextOption');
const lastModified = getConfig('collection', 'i18n.lastModified');
const registrationUrl = getConfig('collection', 'banner.register.url');
const hideDateInterval = getConfig('collection', 'hideDateInterval');

/**
* Class name for the card:
Expand Down Expand Up @@ -286,6 +287,7 @@ const Card = (props) => {
const isEventsCard = origin === 'Events';
let hideBanner = false;
let eventBanner = '';
const hideOnDemandDates = hideDateInterval && isDateAfterInterval(getCurrentDate(), endDate);

if (isHalfHeight && isGated && !isRegistered) {
bannerDescriptionToUse = bannerMap.register.description;
Expand Down Expand Up @@ -472,7 +474,8 @@ const Card = (props) => {
divider={renderDivider || footerItem.divider}
isFluid={footerItem.isFluid}
key={cuid()}
left={showFooterLeft ? extendFooterData(footerItem.left) : []}
left={(showFooterLeft && !hideOnDemandDates) ?
extendFooterData(footerItem.left) : []}
center={showFooterCenter ? extendFooterData(footerItem.center) : []}
right={extendFooterData(footerItem.right)}
cardStyle={cardStyle}
Expand Down
7 changes: 7 additions & 0 deletions react/src/js/components/Consonant/Helpers/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@ export const isDateBeforeInterval = (currentDate, startDate) => {
return curr < start;
};

export const isDateAfterInterval = (currentDate, endDate) => {
const curr = Date.parse(currentDate);
const end = Date.parse(endDate);

return curr > end;
};

export const getCurrentDate = () => {
const urlParams = new URLSearchParams(window.location.search);
const servertime = parseInt(urlParams.get('servertime'), 10);
Expand Down

0 comments on commit ed2b197

Please sign in to comment.