Sha256: d4d0bd2dbc52c25c4f0543f4c84ba14d664f39778a3ec70b2d4aea1a4752ca1a

Contents?: true

Size: 1.51 KB

Versions: 62

Compression:

Stored size: 1.51 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,
  status?: "success" | "error" | "neutral" | "tip",
  text: string,
}

const FixedConfirmationToast = (props: FixedConfirmationToastProps) => {
  const [showToast, toggleToast] = useState(true)
  const { className, closeable = false, status = 'neutral', text } = props
  const css = classnames(
    `pb_fixed_confirmation_toast_kit_${status}`,
    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

62 entries across 62 versions & 1 rubygems

Version Path
playbook_ui-8.2.0.pre.alpha4 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.2.0.pre.alpha3 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.2.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.1.2 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.1.0.pre.alpha1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.0.3 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.2.0.pre.alpha2 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.1.1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.0.2 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.2.0.pre.alpha1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.1.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.0.1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.0.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.0.0.pre.alpha5 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.0.0.pre.alpha4 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-8.0.0.pre.alpha1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-7.16.0.pre.alpha5 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-7.16.0.pre.alpha4 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-7.16.0.pre.alpha3 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx
playbook_ui-7.16.0.pre.alpha2 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.jsx