Sha256: f6e9ef93fcc2bf83fe506b9d3db9f31f347edf0f11fe37fa9ea52867cc58542b

Contents?: true

Size: 1.67 KB

Versions: 12

Compression:

Stored size: 1.67 KB

Contents

/* @flow */

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

import { CloseIcon } from '../_close_icon'
import { DialogContext } from '../_dialog_context'
import Flex from '../../pb_flex/_flex'
import SectionSeparator from '../../pb_section_separator/_section_separator'

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

12 entries across 12 versions & 1 rubygems

Version Path
playbook_ui-11.6.0.pre.alpha.fontawesome app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.5.0.pre.alpha.fontawesome app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.7.0.pre.alpha.pre.guagechart1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.6.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.5.0.pre.alpha.datepicker1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.6.0.pre.alpha.rubocopperf1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.6.1.pre.alpha.rubocop.pre.performance1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.5.0.pre.alpha.pre.rubocop app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.6.0.pre.alpha.momenttz1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.5.0 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.4.0.pre.alpha.rubytheme2 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx
playbook_ui-11.4.0.pre.alpha.rubytheme1 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx