Skip to content

Add ability to specify component Schema in component file #1

@justenh

Description

@justenh

Rough example of component implementation. Heavily influenced by React's PropType implementation (Typechecking With PropTypes)

{% stackrComponent props {
    title: Stackr.string(),
    headline: Stackr.string(),
    bodyHtml: Stackr.string(),
    ctaGroup: Stackr.arrayOf(Stackr.shape({
        label: Stackr.string('Learn More'),
        url: Stackr.string('#'),
        target: Stackr.string('_self'),
    })),
    padding: Stackr.list('default', ['default', 'none']),
} %}

Allow default values

title: Stackr.string('Default Title')

Allow specifying the shapes of objects

ctaGroup: Stackr.shape({
    label: Stackr.string('Learn More'),
    url: Stackr.string('#'),
    target: Stackr.string('_self'),
}),

Allow specifying the shapes of collections

ctaGroup: Stackr.arrayOf(
    Stackr.shape({
        label: Stackr.string('Learn More'),
        url: Stackr.string('#'),
        target: Stackr.string('_self'),
    })
),

Allow specifying enums

padding: Stackr.list('default', ['default', 'none']),

Long term, it would be ideal if the CMS could read these definitions and present a UI to the admin for configuring this block. This might require that the user creates and specifies the "Field Type" that should be presented allowing the CMS to control the settings associated with a field.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions