Sha256: c70c9706316f13809d68a5a4f9e69bce1c2526db7d37a4c31043a06e1af71357

Contents?: true

Size: 1.58 KB

Versions: 24

Compression:

Stored size: 1.58 KB

Contents

/* @flow */

import React, { useState } from 'react'
import classnames from 'classnames'
import { Icon, Title } from '../'
import { globalProps } from '../utilities/globalProps.js'

const iconMap = {
  success: 'check',
  error: 'exclamation-triangle',
  neutral: 'info-circle',
  tip: 'info-circle',
}

type FixedConfirmationToastProps = {
  className?: string,
  closeable?: boolean,
  data?: string,
  id?: string,
  multiLine?: boolean,
  status?: 'success' | 'error' | 'neutral' | 'tip',
  text: string,
}

const FixedConfirmationToast = (props: FixedConfirmationToastProps) => {
  const [showToast, toggleToast] = useState(true)
  const { className, closeable = false, multiLine = false, status = 'neutral', text } = props
  const css = classnames(
    `pb_fixed_confirmation_toast_kit_${status}`,
    { '_multi_line': multiLine },
    globalProps(props),
    className
  )
  const icon = iconMap[status]

  const handleClick = () => {
    toggleToast(!closeable)
  }

  return (
    <If condition={showToast}>
      <div
          className={css}
          onClick={handleClick}
      >
        <If condition={icon}>
          <Icon
              className="pb_icon"
              fixedWidth
              icon={icon}
          />
        </If>
        <Title
            className="pb_fixed_confirmation_toast_text"
            size={4}
            text={text}
        />
        <If condition={closeable}>
          <Icon
              className="pb_icon"
              fixedWidth={false}
              icon="times"
          />
        </If>
      </div>
    </If>
  )
}

export default FixedConfirmationToast

Version data entries

24 entries across 24 versions & 1 rubygems

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