# All files / dialog styles.ts

100% Statements 118/118
100% Branches 7/7
100% Functions 4/4
100% Lines 118/118

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
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    1191x
    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
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    3x
    3x
    3x
    3x
    3x
    3x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    5x
    5x
    5x
    5x
    5x
    5x
    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
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
    10x
     import { cnb } from "cnbuilder";
    import { bem } from "../utils/bem.js";

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

    export type DialogType = "full-page" | "centered" | "custom";

    /** @remarks \@since 6.0.0 */
    export interface DialogClassNameOptions {
      className?: string;

      /**
       * @defaultValue `"centered"`
       */
      type?: DialogType;

      /**
       * @defaultValue `false`
       */
      fixed?: boolean;

      /**
       * @defaultValue `type === "full-page"`
       */
      outline?: boolean;
    }

    /** @remarks \@since 6.0.0 */
    export function dialog(options: DialogClassNameOptions = {}): string {
      const {
        type = "centered",
        fixed = false,
        outline = type === "full-page",
        className,
      } = options;

      return cnb(
        styles({
          fixed,
          outline,
          centered: type === "centered",
          "full-page": type === "full-page",
        }),
        className
      );
    }

    /** @remarks \@since 6.0.0 */
    export interface DialogHeaderClassNameOptions {
      className?: string;
    }

    /** @remarks \@since 6.0.0 */
    export function dialogHeader(
      options: DialogHeaderClassNameOptions = {}
    ): string {
      const { className } = options;

      return cnb(styles("header"), className);
    }

    /** @remarks \@since 6.0.0 */
    export interface DialogContentClassNameOptions {
      className?: string;

      /** @defaultValue `false` */
      disablePadding?: boolean;
    }

    /** @remarks \@since 6.0.0 */
    export function dialogContent(
      options: DialogContentClassNameOptions = {}
    ): string {
      const { className, disablePadding = false } = options;

      return cnb(styles("content", { padded: !disablePadding }), className);
    }

    /**
     * An optional alignment for the content within the footer. Since the majority
     * of dialog footers are used to contain action buttons, the default alignment
     * is near the end.
     *
     * @remarks \@since 3.1.0
     */
    export type DialogFooterAlignment =
      | "none"
      | "start"
      | "end"
      | "between"
      | "stacked-start"
      | "stacked-end";

    /** @remarks \@since 6.0.0 */
    export interface DialogFooterClassNameOptions {
      className?: string;

      /** @defaultValue `"end"` */
      align?: DialogFooterAlignment;
    }

    /** @remarks \@since 6.0.0 */
    export function dialogFooter(
      options: DialogFooterClassNameOptions = {}
    ): string {
      const { align = "end", className } = options;

      return cnb(
        styles("footer", {
          flex: align !== "none",
          "flex-v": align === "stacked-start" || align === "stacked-end",
          start: align === "start" || align === "stacked-start",
          between: align === "between",
          end: align === "end" || align === "stacked-end",
        }),
        className
      );
    }