# All files / src/snackbar toastStyles.ts

100% Statements 61/61
40% Branches 2/5
100% Functions 1/1
100% Lines 61/61

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    621x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
    272x
     import { cnb } from "cnbuilder";
    import { cssUtils, type BackgroundColor } from "../cssUtils.js";
    import { bem } from "../utils/bem.js";

    declare module "react" {
      interface CSSProperties {
        "--rmd-toast-color"?: string;
        "--rmd-toast-background-color"?: string;
        "--rmd-toast-offset"?: string | number;
      }
    }

    const styles = bem("rmd-toast");

    /** @remarks \@since 6.0.0 */
    export interface ToastClassNameOptions {
      className?: string;
      /** @defaultValue `"surface"` */
      theme?: BackgroundColor;
      /** @defaultValue `false` */
      action?: boolean;
      /** @defaultValue `false` */
      paused?: boolean;
      /** @defaultValue `false` */
      stacked?: boolean;
      /** @defaultValue `false` */
      reordered?: boolean;
      /** @defaultValue `false` */
      closeButton?: boolean;
    }

    /**
     * @remarks \@since 6.0.0
     */
    export function toast(options: ToastClassNameOptions = {}): string {
      const {
        className,
        theme = "surface",
        action,
        paused,
        stacked,
        reordered,
        closeButton,
      } = options;

      return cnb(
        styles({
          x: closeButton,
          action,
          paused,
          "small-gap": closeButton && action,
          stacked,
          reordered: stacked && reordered,
        }),
        cssUtils({
          backgroundColor:
            theme !== "surface" && theme !== "current-color" ? theme : undefined,
        }),
        className
      );
    }