Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thought experiment: Fields conditional on structure key #106

Open
bglw opened this issue Apr 13, 2022 · 0 comments
Open

Thought experiment: Fields conditional on structure key #106

bglw opened this issue Apr 13, 2022 · 0 comments
Labels
cms structures Related to the generation of structures for hydrating the CMS enhancement New feature or request

Comments

@bglw
Copy link
Contributor

bglw commented Apr 13, 2022

Workshopping flexible components, picturing a component definition like the following:

# hero.bookshop.yml
spec:
  structures:
    - content_blocks

blueprint:
  title: Hello World
  alignment: Left

Available as a nested component:

# wrapper.bookshop.yml
spec:
  structures:
    - content_blocks

blueprint:
  blocks: ["bookshop:structure:content_blocks"]
  alignment: Left

In this example, the alignment key might not make sense to exist on both components. To resolve this, one could imagine a hypothetical syntax:

# hero.bookshop.yml
spec:
  structures:
    - structure: content_blocks
    - structure: inner_blocks
      ignore_fields:
        - alignment

blueprint:
  title: Hello World
  alignment: Left

Available as a nested component:

# wrapper.bookshop.yml
spec:
  structures:
    - content_blocks

blueprint:
  blocks: ["bookshop:structure:inner_blocks"]
  alignment: Left

In this world, the hero component would have the alignment key when used as a top level component in a content_blocks array, but this key would be absent when used in an inner_blocks array.

Theoretically, something along these lines could be achieved with an input config of type: hidden, assuming a similar capability of defining _inputs per structure key. This would provide a key that exists in the data but is not shown to editors, but that doesn't solve the case where one would like the key to be absent altogether.

Overall this needs more thought, but this puts together some of my current brain-scratchings.

@bglw bglw added enhancement New feature or request cms structures Related to the generation of structures for hydrating the CMS labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cms structures Related to the generation of structures for hydrating the CMS enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant