Sha256: 4d28b1bbf8942450fcbff45663e69b32c83ad50b0a95d2b5cab5e712dabaa8f9

Contents?: true

Size: 1.68 KB

Versions: 14

Compression:

Stored size: 1.68 KB

Contents

<%
break_lines = lambda do |list, spaces = 2, separator = ","|
  list.join("#{separator}\n#{" " * spaces}") + separator
end

type_name = "#{@kit_name_pascal}Props"

props_types = @kit_props.map do |key, val|
  prop_name = key == "classname" ? "className" : key.camelize(:lower)
  prop_type = case val
              when "enum", "one_of" then "'option_1' | 'option_2'"
              when "boolean", "bool" then "Boolean"
              when "object", "obj" then "object"
              else "String"
              end

  "#{prop_name}?: #{prop_type}"
end
puts props_types.inspect

props_names = @kit_props.keys.map do |key|
                  case key
                  when "classname" || "className"
                    "className" 
                  when "aria"
                    "aria = {}"
                  when "data"
                    "data = {}"
                  else 
                    key
                  end
              end

%>

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { spacing } from '../utilities/spacing.js'

type <%= type_name %> = {
  <%= break_lines.call(props_types) %>
}

const <%= @kit_name_pascal %> = (props: <%= type_name %>) => {
  const {
    <%= break_lines.call(props_names) %>
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(buildCss('pb_<%= @kit_name_underscore %>'), className, spacing(props))

  return (
    <div
        {...ariaProps}
        {...dataProps}
        className={classes}
        id={id}
    >
      {className}
    </div>
  )
}

export default <%= @kit_name_pascal %>

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
playbook_ui-6.0.1.pre.alpha5 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-6.0.1.pre.alpha4 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-6.0.1.pre.alpha3 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-6.0.1.pre.alpha2 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-6.0.1 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-6.0.0 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.5.1.pre.alpha4 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.5.1.pre.alpha3 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.5.1.pre.alpha2 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.5.1.pre.alpha1 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.5.1 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.5.0 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.5.0.pre.alpha1 lib/generators/kit/templates/kit_jsx.erb.tt
playbook_ui-5.4.0 lib/generators/kit/templates/kit_jsx.erb.tt