Architecture Decision Records (ADRs)

← Home

Leverage view modes when rendering entities

Introduction

When rendering entities in layout builder or blocks leverage view mode over fields when possible.

Decision

When possible, render entities within layout builder blocks and reusable blocks using the view modes instead of rendering individual fields.

Context

If fields are rendered as the layout builder blocks, they lose consistent core classes that can be reused for front-end development. When the fields are wrapped in the view mode then front-end developer has access to the view mode template overrides and the fields are rendered consistently regardless of where the entity in this particular view mode is going to be used. It becomes an atomic component that looks styled independently of Layout Builder section or theme region. This promotes front-end code reusability, allows for cleaner themes and reduces effort needed for styling. It also allows to produce predictable results for the editors since components they are placing are semantically and functionally atomic.

Consequences

Exceptions

Additional Resources

None

← See more ADRs