Sha256: 7c107c6c856c78828076b0f93900c8782eacb5924eca20bb23c37cb41d03e3c1

Contents?: true

Size: 1.59 KB

Versions: 143

Compression:

Stored size: 1.59 KB

Contents

/* @flow */

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

type BackgroundProps = {
  aria?: object,
  backgroundColor?: 'gradient' | 'dark' | 'light' | 'white',
  children?: array<React.ReactNode> | React.ReactNode,
  className?: string,
  data?: object,
  id?: string,
  imageUrl?: string,
  padding?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl',
  tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
}

const Background = (props: BackgroundProps) => {
  const {
    aria = {},
    backgroundColor = 'light',
    children,
    className,
    data = {},
    id,
    imageUrl = '',
    tag = 'div',
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const classes = classnames(buildCss('pb_background_kit'), globalProps(props), `pb_background_color_${backgroundColor}`, className)
  const Tag = `${tag}`
  const backgroundStyle = {
    backgroundImage: `url(${imageUrl})`,
    backgroundSize: 'cover',
  }

  return (
    <>
      <If condition={imageUrl}>
        <Tag
            className={classes + 'lazyload blur_up'}
            style={backgroundStyle}
            {...ariaProps}
            {...dataProps}
            id={id}
        >
          { children }
        </Tag>
        <Else />
        <Tag
            className={classes}
            {...ariaProps}
            {...dataProps}
            id={id}
        >
          { children }
        </Tag>
      </If>
    </>
  )
}

export default Background

Version data entries

143 entries across 143 versions & 1 rubygems

Version Path
playbook_ui-10.2.1 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.2.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.1.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.3.pre.alpha.walkthrough2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.3.pre.alpha.walkthrough app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.1.alpha.railscusticon app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.2.pre.alpha.pre.iconfix app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.1.alpha.rtflexfix app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.0.pre.alphafonts app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.1 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-10.0.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.19.0.pre.alpha.pre.fonts2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.19.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.19.0.pre.alphafonts app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.18.0.flow.bin.alpha app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.18.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.17.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.17.0.pre.decouple.website2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.16.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.15.0 app/pb_kits/playbook/pb_background/_background.jsx