theaterpedia / crearis-nuxt

2 stars 1 forks source link

N-34 component-spec #34

Open crearis opened 3 months ago

crearis commented 3 months ago

The component-spec is a great place to set the basic definitions of the components

But I am still having troubles with it ... I keep getting typing- errors based on the split in Singletons and Parents. I think we have things to discuss and clarify here.

  1. For the moment I added allowsProse: boolean to singleton which takes away the difference here.
  2. As much as 'prose' is a component in the technical meaning now ... I would not say that a component needs to be a 'parent' or 'nestable' because it wants to accept prose on the default slot > so that Alert and Heading are not Parents but can process prose > what are your thoughts on that?
murisceman commented 3 months ago

Here is an example usage of the allowsProse prop (before your changes):

const spec: ComponentSpec = {} as any

spec.allowsProse // error

if (spec.isParent) {
  spec.allowsProse // no error
}

I would not say that a component needs to be a 'parent' or 'nestable' because it wants to accept prose on the default slot > so that Alert and Heading are not Parents but can process prose > what are your thoughts on that?

A component that has a <slot /> is a parent/nestable component, and other components are singletons. Technically, a Prose component can only be placed inside a component with a <slot />.