Sha256: 87f9137a2389776084c26c01df5286f0e40796971b844e76e9b69daef9724808

Contents?: true

Size: 1.61 KB

Versions: 67

Compression:

Stored size: 1.61 KB

Contents

/* @flow */

import React, { useContext } from 'react'
import classnames from 'classnames'
import { buildAriaProps, buildCss, buildDataProps } from '../../utilities/props'
import { globalProps } from '../../utilities/globalProps.js'
import { Flex, SectionSeparator } from '../../'
import { CloseIcon } from '../_close_icon'
import { DialogContext } from '../_dialog_context'

type DialogHeaderProps = {
  aria?: object,
  children: array<React.ReactNode> | React.ReactNode | string,
  className?: string,
  closeable: boolean,
  data?: object,
  id?: string,
  padding?: string,
  separator: boolean,
  spacing?: string,
  text?: string,
  title?: string,
}

const DialogHeader = (props: DialogHeaderProps) => {
  const {
    aria = {},
    children,
    className,
    data = {},
    padding = 'sm',
    spacing = 'between',
    closeable = true,
    separator = true,
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const api = useContext(DialogContext)
  const headerCSS = buildCss('dialog_header')
  const headerSpacing = globalProps(props, { padding })

  /* eslint-disable react/jsx-handler-names */

  return (
    <>
      <Flex
          {...ariaProps}
          {...dataProps}
          className={classnames(headerCSS, headerSpacing, className)}
          spacing={spacing}
      >
        {children}
        <If condition={closeable}>
          <CloseIcon
              className="close-icon"
              onClose={api.onClose}
          />
        </If>
      </Flex>
      <If condition={separator}>
        <SectionSeparator />
      </If>
    </>
  )
}

export default DialogHeader

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
playbook_ui-9.19.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.19.0.pre.alphafonts app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.18.0.flow.bin.alpha app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.18.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.17.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.17.0.pre.decouple.website2 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.16.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.15.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.15.0.pre.decouple.website1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.14.1.alpha.radio.alignment app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.14.1.alpha.highcharts9 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.14.1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.13.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.12.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.12.0.pre.text.addon app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.11.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.10.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.10.0.pre.date.time.stacked.1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.10.0.pre.alpha2 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-9.10.0.pre.alpha1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx