Sha256: b96a7a52c210992a3db6dc26ee91fcb50405875f9da257db8f88777858604824

Contents?: true

Size: 1.64 KB

Versions: 37

Compression:

Stored size: 1.64 KB

Contents

/* @flow */

import React from 'react'
import classnames from 'classnames'
import { buildCss } from '../utilities/props'
import { globalProps } from '../utilities/globalProps.js'
type FlexProps = {
  children: array<React.ReactNode> | React.ReactNode,
  className?: string,
  horizontal?: "left" | "center" | "right" | "stretch",
  id?: string,
  inline?: boolean,
  orientation?: "row" | "column",
  spacing?: "around" | "between" | "evenly" | "none",
  reverse?: boolean,
  vertical?: "top" | "center" | "bottom" | "stretch",
  wrap?: boolean,
}

const Flex = (props: FlexProps) => {
  const {
    children,
    className,
    inline = false,
    horizontal = 'left',
    orientation = 'row',
    spacing = 'none',
    reverse = false,
    vertical = 'top',
    wrap = false,
  } = props
  const orientationClass =
    orientation !== undefined ? `orientation_${orientation}` : ''
  const horizontalClass =
    horizontal !== undefined ? `justify_content_${horizontal}` : ''
  const verticalClass = vertical !== undefined ? `align_items_${vertical}` : ''
  const inlineClass = inline === true ? 'inline' : ''
  const spacingClass = spacing !== undefined ? `spacing_${spacing}` : ''
  const wrapClass = wrap === true ? 'wrap' : ''
  const reverseClass = reverse === true ? 'reverse' : ''
  return (
    <div
        className={classnames(
        buildCss(
          'pb_flex_kit',
          orientationClass,
          horizontalClass,
          verticalClass,
          inlineClass,
          spacingClass,
          reverseClass,
          wrapClass
        ),
        className,
        globalProps(props)
      )}
    >
      {children}
    </div>
  )
}

export default Flex

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
playbook_ui-7.3.0.pre.alpha2 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-6.7.0.pre.alpha1 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-6.7.0 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-6.6.1 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.0.pre.alpha10 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-6.6.0 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-6.5.2 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha12 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha11 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha10 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha9 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-6.5.1 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-6.5.0 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha8 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha7 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha6 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha5 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha4 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha3 app/pb_kits/playbook/pb_flex/_flex.jsx
playbook_ui-7.0.1.pre.alpha2 app/pb_kits/playbook/pb_flex/_flex.jsx