Skip to content

Commit

Permalink
Merge branch 'main' into gl/aspect-ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges-GNM authored Nov 20, 2024
2 parents f1e4ab7 + c7b403b commit b37dc84
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1,027 deletions.
28 changes: 21 additions & 7 deletions common/app/model/CollectionConfig.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package model.pressed

import com.gu.facia.api.{models => fapi}
import com.gu.facia.client.models.{Backfill, CollectionConfigJson, Metadata, CollectionPlatform, Primary, Secondary}
import com.gu.facia.client.models.{Backfill, CollectionConfigJson, Metadata, CollectionPlatform, Secondary}

final case class CollectionConfig(
displayName: Option[String],
Expand Down Expand Up @@ -30,14 +30,28 @@ object CollectionConfig {

def make(config: fapi.CollectionConfig): CollectionConfig = {

/** Extract `primary` or `secondary` collection level tag from metadata if present. Collection level is a concept
* that allows the platforms to style containers differently based on their "level"
val betaCollections = List(
"flexible/special",
"flexible/general",
"scrollable/highlights",
"scrollable/small",
"scrollable/medium",
"scrollable/feature",
"static/medium/4",
"static/feature/2",
)

/** Collection level is a concept that allows the platforms to style containers differently based on their "level".
* Beta collections are "Secondary" if tagged as such or "Primary" otherwise. Legacy containers have no container
* level set.
*/
val collectionLevel: Option[String] = config.metadata.flatMap { metadataList =>
metadataList.collectFirst {
case Primary => "Primary"
case Secondary => "Secondary"
val collectionLevel: Option[String] = if (betaCollections.contains(config.collectionType)) {
config.metadata.getOrElse(List.empty).find(_ == Secondary) match {
case Some(_) => Some("Secondary")
case None => Some("Primary")
}
} else {
None
}

val aspectRatio: String = fapi.CollectionConfig.AspectRatio.getAspectRatio(config.collectionType).label
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@emotion/react": "11.11.1",
"@emotion/styled": "^10.0.27",
"@guardian/ab-core": "8.0.0",
"@guardian/commercial": "23.6.0",
"@guardian/commercial": "23.7.0",
"@guardian/core-web-vitals": "6.0.0",
"@guardian/eslint-config-typescript": "9.0.1",
"@guardian/identity-auth": "3.0.0",
Expand Down
Loading

0 comments on commit b37dc84

Please sign in to comment.