/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
import { cardContextTypes } from "../../Card/types.js";
import { CSSTransition, TransitionGroup } from "react-transition-group";
import { FluentOrText } from "../../FluentOrText/FluentOrText.jsx";
import React from "react";
// Animation time is mirrored in DSContextFooter.scss
const ANIMATION_DURATION = 3000;
export const DSMessageLabel = props => {
const { context, context_type } = props;
const { icon, fluentID } = cardContextTypes[context_type] || {};
if (!context && context_type) {
return (
{sponsored_by_override}
; } else if (sponsored_by_override === "") { // We specifically want to display nothing if the server returns an empty string. // So the server can turn off the label. // This is to support the use cases where the sponsored context is displayed elsewhere. return null; } else if (sponsor) { return (
{context}
; } return null; }; export class DSContextFooter extends React.PureComponent { render() { const { context, context_type, sponsor, sponsored_by_override } = this.props; const sponsorLabel = SponsorLabel({ sponsored_by_override, sponsor, context, }); const dsMessageLabel = DSMessageLabel({ context, context_type, }); if (sponsorLabel || dsMessageLabel) { return (