Sha256: b34f1487055a6339695f99d2c9db55cda0f8a3098e14e37f7bd108c9dfd1b266

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

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

import { CloseIcon } from '../_close_icon'
import { DialogContext } from '../_dialog_context'

import { Flex, SectionSeparator } from 'playbook-ui'

type DialogHeaderProps = {
  aria?: {[key: string]: string},
  children: React.ReactNode[] | React.ReactNode | string,
  className?: string,
  closeable?: boolean,
  data?: {[key: string]: string},
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
  id?: string,
  padding?: string,
  separator?: boolean,
  spacing?: "none" | "between" | "around" | "evenly",
  text?: string,
  title?: string,
} & GlobalProps

const DialogHeader = (props: DialogHeaderProps): React.ReactElement => {
  const {
    aria = {},
    children,
    className,
    data = {},
    htmlOptions = {},
    spacing = "between",
    closeable = true,
    separator = true,
  } = props

  const ariaProps = buildAriaProps(aria)
  const dataProps = buildDataProps(data)
  const htmlProps = buildHtmlProps(htmlOptions)
  const api = useContext(DialogContext)
  const headerCSS = buildCss("dialog_header")
  const headerSpacing = globalProps(props)

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

  return (
    <div className="dialog_sticky_header">
      <Flex
          {...ariaProps}
          {...dataProps}
          {...htmlProps}
          className={classnames(headerCSS, headerSpacing, className)}
          spacing={spacing}
      >
        {children}
        {closeable &&
          <CloseIcon
              onClose={api.onClose}
          />
        }
        
      </Flex>
      {separator &&
        <SectionSeparator />
      }
    </div>
  )
}

export default DialogHeader

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
playbook_ui-13.33.0.pre.alpha.PLAY14143305 app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.tsx