Sha256: e64122527b7cd099d6db6b436e5e30668718b8674214ab1613bc40bc22361bee

Contents?: true

Size: 1.99 KB

Versions: 290

Compression:

Stored size: 1.99 KB

Contents

import React from "react";
import classnames from "classnames";
import { buildAriaProps, buildCss, buildDataProps } from "../utilities/props";
import { globalProps } from "../utilities/globalProps";

type ListProps = {
  aria?: { [key: string]: string };
  borderless?: boolean;
  className?: string;
  children: React.ReactNode[] | React.ReactNode;
  dark?: boolean;
  data?: object;
  id?: string;
  layout?: "" | "left" | "right";
  ordered?: boolean;
  role?: string;
  tabIndex?: number;
  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: { [key: string]: string } = {
    left: "layout_left",
    right: "layout_right",
    default: "",
  };

  const childrenWithProps = React.Children.map(
    children,
    (child: React.ReactElement) => {
      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}>
      {ordered ? (
        <ol
          {...ariaProps}
          {...dataProps}
          className={className}
          id={id}
          role={role}
          tabIndex={tabIndex}
        >
          {childrenWithProps}
        </ol>
      ) : (
        <ul
          {...ariaProps}
          {...dataProps}
          className={className}
          id={id}
          role={role}
          tabIndex={tabIndex}
        >
          {childrenWithProps}
        </ul>
      )}
    </div>
  );
};

export default List;

Version data entries

290 entries across 290 versions & 1 rubygems

Version Path
playbook_ui-12.24.0.pre.alpha.alphatestforselfhostfak720 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.24.0.pre.alpha.play833boldoptionfortitle2and3719 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.24.0.pre.alpha.play833boldoptionfortitle2and3717 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.24.0 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.23.0.pre.alpha.movemarkdown712 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.23.0.pre.alpha.movemarkdown708 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.23.0.pre.alpha.play698responsivespacingglobalprop703 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.23.0.pre.alpha.play698responsivespacingglobalprop701 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.23.0 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.22.0.pre.alpha.PLAY603datepickerquickpickinputpresetdropdown696 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.22.0.pre.alpha.play698responsivespacingglobalprop690 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.22.0.pre.alpha.PBNTR12checkingemptyfilters686 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.22.0 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.21.0.pre.alpha.PLAY807RTEcustomtoolbar680 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.21.0 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.20.0.pre.alpha.movemarkdown668 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.20.0.pre.alpha.title2667 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.20.0.pre.alpha.title2665 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.20.0 app/pb_kits/playbook/pb_list/_list.tsx
playbook_ui-12.19.0.pre.alpha.PLAY699zindexresponsive650 app/pb_kits/playbook/pb_list/_list.tsx