Sha256: f55b925435a335dc3e4cd533ffbf91ac006f5b00f0fccdbb38bc9d321a11aef2

Contents?: true

Size: 1.96 KB

Versions: 91

Compression:

Stored size: 1.96 KB

Contents

/* @flow */

import React, { type Node } from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps'

type ListProps = {
  aria?: object,
  borderless: boolean,
  className?: string,
  children: array<Node> | Node,
  dark: boolean,
  data?: object,
  id?: string,
  layout: "" | "left" | "right",
  ordered: boolean,
  role?: string,
  tabIndex?: string,
  text?: string,
  size?: string,
  variant?: string,
  xpadding: boolean,
}

const List = (props: ListProps) => {
  const {
    aria = {},
    borderless = false,
    children,
    className,
    dark = false,
    data = {},
    id,
    layout = '',
    ordered = false,
    role,
    size = '',
    tabIndex,
    xpadding = false,
    variant,
    text,
  } = props

  const layoutClass = {
    left: 'layout_left',
    right: 'layout_right',
    default: '',
  }

  const childrenWithProps = React.Children.map(children, (child) => {
    return React.cloneElement(child, { text, variant })
  })
  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(
    buildCss('pb_list_kit', layoutClass[layout], size, {
      dark: dark,
      borderless: borderless,
      ordered: ordered,
      xpadding: xpadding,
    }),
    globalProps(props),
    className
  )

  return (
    <div
        className={classes}
    >
      <If condition={ordered}>
        <ol
            {...ariaProps}
            {...dataProps}
            className={className}
            id={id}
            role={role}
            tabIndex={tabIndex}
        >
          {childrenWithProps}
        </ol>
        <Else />
        <ul
            {...ariaProps}
            {...dataProps}
            className={className}
            id={id}
            role={role}
            tabIndex={tabIndex}
        >
          {childrenWithProps}
        </ul>
      </If>
    </div>
  )
}

export default List

Version data entries

91 entries across 91 versions & 1 rubygems

Version Path
playbook_ui-11.18.0.pre.alpha.pagutility1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.19.0.pre.typeahead1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.18.0 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.17.0 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.15.0.pre.alpha.dependencies1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.16.0.pre.alpha.paginationrails1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.16.0 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.16.0.pre.alpha.reactupgrade1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.15.0.pre.alpha.table1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.16.0.pre.alpha.pagination.rails1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.15.0 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.14.0 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.13.0.pre.alpha.fontawesome1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.13.0 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.12.1.pre.alpha.charts1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.12.1.pre.alpha.passphrase1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.12.1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.13.0.pre.alpha.fileupload1 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.12.0 app/pb_kits/playbook/pb_list/_list.jsx
playbook_ui-11.11.0.pre.alpha.paginate2 app/pb_kits/playbook/pb_list/_list.jsx