How to use the @teleporthq/teleport-types.ReactStyleVariation.StyledComponents function in @teleporthq/teleport-types

To help you get started, we’ve selected a few @teleporthq/teleport-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teleporthq / teleport-code-generators / packages / teleport-component-generator-react / __tests__ / integration / component-style.ts View on Github external
it('should explicitly send prop if style is using one prop variable', async () => {
      const styledComponentsGenerator = createReactComponentGenerator(
        ReactStyleVariation.StyledComponents
      )
      const result = await styledComponentsGenerator.generateComponent(
        ComponentWithValidSingleStlye
      )
      const jsFile = findFileByType(result.files, FileType.JS)

      expect(jsFile).toBeDefined()
      expect(jsFile.content).toContain(' props.height}')
    })
github teleporthq / teleport-code-generators / packages / teleport-component-generator-react / __tests__ / integration / component-style.ts View on Github external
defaultValue: 'red',
        },
      }
      const style: UIDLStyleDefinitions = {
        'background-color': dynamicNode('prop', 'backgroundColor'),
        'border-color': dynamicNode('prop', 'borderColor'),
      }
      const uidl = component(
        'ComponentWithSingleDashCaseStyle',
        elementNode('container', {}, [staticNode('Hello')], null, style),
        propDefnitions,
        {}
      )

      const styledComponentsGenerator = createReactComponentGenerator(
        ReactStyleVariation.StyledComponents
      )
      const result = await styledComponentsGenerator.generateComponent(uidl)

      const jsFile = findFileByType(result.files, FileType.JS)

      expect(jsFile).toBeDefined()
      expect(jsFile.content).toContain(' props.backgroundColor}')
      // tslint:disable-next-line:no-invalid-template-strings
      expect(jsFile.content).toContain('border-color: ${(props) => props.borderColor}')
    })
github teleporthq / teleport-code-generators / packages / teleport-project-generator-gatsby / __tests__ / end2end / index.ts View on Github external
it('throws error when conifg file is not found with custom framework config', async () => {
    const generatorGatsbyStyledComponents = createGatsbyProjectGenerator({
      variation: ReactStyleVariation.StyledComponents,
    })
    const result = generatorGatsbyStyledComponents.generateProject(invalidUidlSample, template)

    await expect(result).rejects.toThrow(Error)
  })
})
github teleporthq / teleport-code-generators / packages / teleport-component-generator-react / __tests__ / end2end / index.ts View on Github external
describe('with StyledComponents', () => {
    const generator = createReactComponentGenerator(ReactStyleVariation.StyledComponents)

    it('should return the files containing the code as string', async () => {
      const result = await generator.generateComponent(uidlSample)
      const jsFile = findFileByType(result.files, JS_FILE)

      expect(jsFile).toBeDefined()
      expect(result.files.length).toBe(1)
      expect(jsFile.content).toContain('import React')
      expect(result.dependencies).toBeDefined()
    })
  })
github teleporthq / teleport-code-generators / packages / teleport-component-generator-react / src / index.ts View on Github external
variation = ReactStyleVariation.CSSModules,
  { mappings = [], plugins = [], postprocessors = [] }: GeneratorFactoryParams = {}
): ComponentGenerator => {
  const cssPlugin = createCSSPlugin({
    templateChunkName: 'jsx-component',
    templateStyle: 'jsx',
    declareDependency: 'import',
    classAttributeName: 'className',
    forceScoping: true,
  })

  const cssModulesPlugin = createCSSModulesPlugin({ moduleExtension: true })

  const stylePlugins = {
    [ReactStyleVariation.InlineStyles]: inlineStylesPlugin,
    [ReactStyleVariation.StyledComponents]: reactStyledComponentsPlugin,
    [ReactStyleVariation.StyledJSX]: reactStyledJSXPlugin,
    [ReactStyleVariation.CSSModules]: cssModulesPlugin,
    [ReactStyleVariation.CSS]: cssPlugin,
    [ReactStyleVariation.ReactJSS]: reactJSSPlugin,
  }

  const stylePlugin = stylePlugins[variation]

  if (!stylePlugin) {
    throw new Error(`Invalid style variation '${variation}'`)
  }

  const generator = createComponentGenerator()

  generator.addMapping(ReactMapping as Mapping)
  mappings.forEach((mapping) => generator.addMapping(mapping))