decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.96k stars 3.05k forks source link

List widget with variable types should allow hints or descriptions for each type #3650

Open boygirl opened 4 years ago

boygirl commented 4 years ago

I'm making extensive use of variable types in the list widget, and it has been extremely useful! One thing I would like to see would be the ability to add a hint or description for the whole type. My current work around is adding a dummy boolean widget and giving it a hint, but that feels kind of hacky. The ideal solution would be to support a hint or description for the entire type that would show at the top of the control for each type.

For example:

label: 'Home Section'
  name: 'sections'
  widget: 'list'
  types:
    - label: 'Carousel'
      name: 'carousel'
      widget: object
      hint: 'this is a description of the carousel type. This description should render above any fields for this type",
      fields:
        - { label: Header, name: header, widget: string, default: 'Image Gallery' }
        ...

Another possibly easier change would be to allow hidden fields to display hints if they have any.

marovargovcik commented 3 years ago

Any hints (pun intended) where to start if I want to take this and contribute to the project? Thanks!

erezrokah commented 3 years ago

Hi @marovargovcik! The hint configuration is accessed here: https://github.com/netlify/netlify-cms/blob/089533683b0483d31da6dc158f3b9bb5f14fb88f/packages/netlify-cms-core/src/components/Editor/EditorControlPane/EditorControl.js#L215

and the List widget is rendered here: https://github.com/netlify/netlify-cms/blob/089533683b0483d31da6dc158f3b9bb5f14fb88f/packages/netlify-cms-widget-list/src/ListControl.js#L500