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-9.6.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.5.0.alpha.rs.downgrade app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.5.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.4.0.alpha.sisense app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.4.0.alpha.user.kit.bug app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.4.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.1.pre.alpha2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.4.0.pre.alpha2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.4.0.pre.alpha1 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.1.pre.alpha1 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.0.alpha.inline3 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.0.pre.alpha.password.strength.2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.0.alpha.inline2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.0.alpha.inline1 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.0.pre.alpha.password.strength.1 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.3.0 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.2.2.pre.alpha.margin app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.2.2 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.2.1 app/pb_kits/playbook/pb_background/_background.jsx
playbook_ui-9.2.0 app/pb_kits/playbook/pb_background/_background.jsx