Sha256: 54d53115eea9d054d9f194e682e3432de1d2bb5695a13f021070e7d463133d10

Contents?: true

Size: 1.83 KB

Versions: 100

Compression:

Stored size: 1.83 KB

Contents

import React, { useEffect, useState } from "react";
import classnames from "classnames";

import { globalProps } from "../utilities/globalProps";

import Icon from "../pb_icon/_icon";
import Title from "../pb_title/_title";

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

type FixedConfirmationToastProps = {
  className?: string;
  closeable?: boolean;
  data?: string;
  horizontal?: "right" | "left" | "center";
  id?: string;
  multiLine?: boolean;
  onClose?: () => void;
  open?: boolean;
  status?: "success" | "error" | "neutral" | "tip";
  text: string;
  vertical?: "top" | "bottom";
};

const FixedConfirmationToast = (props: FixedConfirmationToastProps) => {
  const [showToast, toggleToast] = useState(true);
  const {
    className,
    closeable = false,
    horizontal,
    multiLine = false,
    onClose = () => {},
    open = true,
    status = "neutral",
    text,
    vertical,
  } = props;
  const css = classnames(
    `pb_fixed_confirmation_toast_kit_${status}`,
    { _multi_line: multiLine },
    { [`positioned_toast ${vertical} ${horizontal}`]: vertical && horizontal },
    globalProps(props),
    className
  );
  const icon = iconMap[status];

  useEffect(() => {
    toggleToast(open);
  }, [open]);

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

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

export default FixedConfirmationToast;

Version data entries

100 entries across 100 versions & 1 rubygems

Version Path
playbook_ui-12.7.1.pre.alpha.rubyandnpmalpharelease291 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.7.1.pre.alpha.alpharubyrelease281 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.7.1.pre.alpha.menu2 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.7.1.pre.alpha.menu1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.7.1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.7.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.6.0.pre.alpha.sectionseparator1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.6.0.pre.alpha.menuyml1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.6.0.pre.alpha.collapsible1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.6.0.pre.alpha.cssphone1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.6.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.5.0.pre.alpha.datepickerinput1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.5.0.pre.alpha.phonerails1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.5.0.pre.alpha.datepicker1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.5.0.pre.alpha.filter1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.5.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.4.0.pre.alpha.map1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.4.0.pre.alpha.devdocstest1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.4.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx
playbook_ui-12.3.1.pre.alpha.phone1 app/pb_kits/playbook/pb_fixed_confirmation_toast/_fixed_confirmation_toast.tsx