Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / @skava/ui   js

Repository URL to install this package:

Version: 4.2.0-a11y.0 

/ src / components / molecules / List / renderProps.tsx

import React from 'react'
import { ListProps, ItemProps } from './typings'
import { ListWrapper, ItemPanel, StyledText } from './styled'

/**
 *
 * @param item each item from map function
 * @param props list props which shared through the list function
 */
function renderItem(item: ItemProps) {
  const textContent = item.label || 'undefined'
  return <StyledText content={textContent} />
}

/**
 * rendering the list
 */
function renderList(props: ListProps) {
  const { list } = props
  return list.map((item) => (
    <ItemPanel>{props.renderItem(item, props)}</ItemPanel>
  ))
}

/**
 * rendering the wrapper
 */
function renderWrapper(props: ListProps) {
  const { className, children, isHorizontalView } = props
  return (
    <ListWrapper className={className} isHorizontalView={isHorizontalView}>
      {children}
    </ListWrapper>
  )
}

export { renderList, renderItem, renderWrapper }