Byteclaw/visage

Add static createComponent helper

Opened this issue · 0 comments

Basically following is too verbose:

const Wrapper = createComponent(Flex, {
  styles: {
    alignItems: 'flex-start',
    width: '100%',
    ...variantStyles('parameterType', {
      [TaskParameterType.LABEL]: {
        mb: 2,
      },
      [TaskParameterType.SINGLECHOICE]: {
        mt: 4,
      },
    }),
  },
  variants: [
    variant('parameterType', true, [
      TaskParameterType.LABEL,
      TaskParameterType.SINGLECHOICE,
    ] as const),
  ],
})

I'd like to create variants by simple variants: {} but in this case I don't know how to create boolean variants. Something like react-stitches.

Also it could create new version of visage component that has style generated on create and not on mount. In this case maybe it could offer extensibility but primitive usage should be as fast as possible (pregenerated CSS). The problem can be theme access through context, in this case we can render styles only on render.

Also we need to think about variant and prop stripping.