Skip to content

Commit

Permalink
Merge pull request #173 from adobecom/MWPW-157435
Browse files Browse the repository at this point in the history
feat(mwpw-157435): alternative cta links/text for live & upcoming
  • Loading branch information
sheridansunier authored Sep 9, 2024
2 parents 11f1e66 + 39ab8db commit 741f196
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/app.css

Large diffs are not rendered by default.

44 changes: 38 additions & 6 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Chimera UI Libraries - Build 0.19.0 (9/6/2024, 12:44:32)
* Chimera UI Libraries - Build 0.20.0 (9/9/2024, 13:21:45)
*
*/
/******/ (function(modules) { // webpackBootstrap
Expand Down Expand Up @@ -47244,6 +47244,7 @@ var CardFooter = function CardFooter(props) {
*/

var isLive = (0, _general.isDateWithinInterval)((0, _general.getCurrentDate)(), startDate, endDate);
var isUpcoming = (0, _general.isDateBeforeInterval)((0, _general.getCurrentDate)(), startDate);

/**
* Class name for the card footer:
Expand Down Expand Up @@ -47290,13 +47291,38 @@ var CardFooter = function CardFooter(props) {
* Whether the right footer infobits should render
* @type {Boolean}
*/
var shouldRenderRight = right && right.length > 0 && (!isLive || altRight.length === 0);
var shouldRenderRight = right && right.length > 0 && (!isLive || altRight.length === 0) && (!isUpcoming || altRight.length === 0);

/**
* Whether an alternate right footer infobits should render
* Whether an alternate right footer infobits should render for upcoming
* @type {Boolean}
*/
var shouldRenderAltRight = altRight && altRight.length > 0 && isLive;
var shouldRenderAltRightUpcoming = altRight && altRight.length > 0 && isUpcoming;

/**
* Whether an alternate right footer infobets should render for live events
*/
var shouldRenderAltRightLive = altRight && altRight.length > 0 && isLive;

/**
* This is some franken logic to make one alt cta space work for two different card states
*/
var altRightUpcoming = []; // isUpcoming
var altRightLive = []; // isLive
if (altRight && altRight.length > 0 && right && right.length > 0) {
var upcoming = {
href: right[0].href,
text: altRight[0].text,
type: right[0].type
};
var live = {
href: altRight[0].href,
text: right[0].text,
type: altRight[0].type
};
altRightUpcoming.push(upcoming);
altRightLive.push(live);
}

return _react2.default.createElement(
'div',
Expand Down Expand Up @@ -47326,11 +47352,17 @@ var CardFooter = function CardFooter(props) {
className: 'consonant-CardFooter-cell consonant-CardFooter-cell--right' },
_react2.default.createElement(_Group2.default, { renderList: right, onFocus: onFocus })
),
shouldRenderAltRight && _react2.default.createElement(
shouldRenderAltRightUpcoming && _react2.default.createElement(
'div',
{
className: 'consonant-CardFooter-cell consonant-CardFooter-cell--right' },
_react2.default.createElement(_Group2.default, { renderList: altRightUpcoming, onFocus: onFocus })
),
shouldRenderAltRightLive && _react2.default.createElement(
'div',
{
className: 'consonant-CardFooter-cell consonant-CardFooter-cell--right' },
_react2.default.createElement(_Group2.default, { renderList: altRight, onFocus: onFocus })
_react2.default.createElement(_Group2.default, { renderList: altRightLive, onFocus: onFocus })
)
)
);
Expand Down
4 changes: 2 additions & 2 deletions dist/main.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main.source.js

Large diffs are not rendered by default.

44 changes: 38 additions & 6 deletions react/src/js/components/Consonant/Cards/CardFooter/CardFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import Group from '../../Infobit/Group';
import { footerType } from '../../types/card';
import { INFOBIT_TYPE } from '../../Helpers/constants';
import { isDateWithinInterval, getCurrentDate } from '../../Helpers/general';
import { isDateWithinInterval, getCurrentDate, isDateBeforeInterval } from '../../Helpers/general';

const defaultProps = {
left: [],
Expand Down Expand Up @@ -49,6 +49,7 @@ const CardFooter = (props) => {
* @type {Boolean}
*/
const isLive = isDateWithinInterval(getCurrentDate(), startDate, endDate);
const isUpcoming = isDateBeforeInterval(getCurrentDate(), startDate);

/**
* Class name for the card footer:
Expand Down Expand Up @@ -93,13 +94,38 @@ const CardFooter = (props) => {
* @type {Boolean}
*/
const shouldRenderRight = right && right.length > 0 &&
(!isLive || altRight.length === 0);
(!isLive || altRight.length === 0) && (!isUpcoming || altRight.length === 0);

/**
* Whether an alternate right footer infobits should render
* Whether an alternate right footer infobits should render for upcoming
* @type {Boolean}
*/
const shouldRenderAltRight = altRight && altRight.length > 0 && isLive;
const shouldRenderAltRightUpcoming = altRight && altRight.length > 0 && isUpcoming;

/**
* Whether an alternate right footer infobets should render for live events
*/
const shouldRenderAltRightLive = altRight && altRight.length > 0 && isLive;

/**
* This is some franken logic to make one alt cta space work for two different card states
*/
const altRightUpcoming = []; // isUpcoming
const altRightLive = []; // isLive
if (altRight && altRight.length > 0 && right && right.length > 0) {
const upcoming = {
href: right[0].href,
text: altRight[0].text,
type: right[0].type,
};
const live = {
href: altRight[0].href,
text: right[0].text,
type: altRight[0].type,
};
altRightUpcoming.push(upcoming);
altRightLive.push(live);
}

return (
<div
Expand All @@ -126,10 +152,16 @@ const CardFooter = (props) => {
<Group renderList={right} onFocus={onFocus} />
</div>
}
{shouldRenderAltRight &&
{shouldRenderAltRightUpcoming &&
<div
className="consonant-CardFooter-cell consonant-CardFooter-cell--right">
<Group renderList={altRightUpcoming} onFocus={onFocus} />
</div>
}
{shouldRenderAltRightLive &&
<div
className="consonant-CardFooter-cell consonant-CardFooter-cell--right">
<Group renderList={altRight} onFocus={onFocus} />
<Group renderList={altRightLive} onFocus={onFocus} />
</div>
}
</div>
Expand Down

0 comments on commit 741f196

Please sign in to comment.