dotcom-rendering icon indicating copy to clipboard operation
dotcom-rendering copied to clipboard

Encapsulate logic for dark card backgrounds in libs

Open cemms1 opened this issue 8 months ago • 4 comments

What does this change?

Follow-up PR for https://github.com/guardian/dotcom-rendering/pull/11772

  • Moves the logic for whether a card has a "dark" background into a central libs location rather than living directly in the decideLogo directory
  • Renames long, complicated isUnsupportedFormatForCardWithoutBackground in cardHelpers.ts to simply isMediaCard since this is what it really represents.
  • Adds more tests to cardHelpers file since the introduction of containerPalette into the decision of whether the card has a "dark" background or not
  • Renames decideLogo in two places to better indicate what they are designed for (articles and cards) with todo comment to hint at future improvement

Why?

Avoids duplication of logic and centralises it so that other areas in the codebase can rely on consistent decision making.

cemms1 avatar Jul 01 '24 10:07 cemms1