# `IO.ANSI.Table.Style`
[🔗](https://github.com/RaymondLoranger/io_ansi_table/blob/main/lib/io/ansi/table/style.ex#L1)

Defines functions returning various aspects of the configured table styles.

# `attr`

```elixir
@type attr() :: atom() | [atom()]
```

Style attribute

# `border`

```elixir
@type border() :: String.t()
```

Table border

# `t`

```elixir
@type t() :: atom()
```

Table style

# `border_attr`

```elixir
@spec border_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
```

Returns the "border attribute" of a given table `style` and line `type`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.border_attr(:green, :top)
    [:light_white, :green_background]

    iex> alias IO.ANSI.Table.Style
    iex> Style.border_attr(:cyan_alt, :odd_row)
    [:chartreuse_yellow, :chartreuse_yellow_background]

# `border_spreads`

```elixir
@spec border_spreads(t(), IO.ANSI.Table.LineType.t()) :: [
  IO.ANSI.Table.Column.spread()
]
```

Returns the "border spreads" of a given table `style` and line `type`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.border_spreads(:plain, :bottom)
    [[0, 2, 0], [0, 3, 0], [0, 2, 0]] # borders: "└─", "─┴─", "─┘"

    iex> alias IO.ANSI.Table.Style
    iex> Style.border_spreads(:plain, :header)
    [[0, 1, 1], [1, 1, 1], [1, 1, 0]] # borders: "│" ,  "│" ,  "│"

# `borders`

```elixir
@spec borders(t(), IO.ANSI.Table.LineType.t()) :: [border()]
```

Returns the borders of a given table `style` and line `type`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.borders(:cyan, :bottom)
    ["╚═", "═╩═", "═╝"]

# `dash`

```elixir
@spec dash(t(), IO.ANSI.Table.LineType.t()) :: String.t() | nil
```

Returns the dash of a given table `style` and line `type`.

## Examples

    iex> IO.ANSI.Table.Style
    iex> Style.dash(:dark, :top)
    "═"

    iex> IO.ANSI.Table.Style
    iex> Style.dash(:dark, :row)
    nil

# `filler_attr`

```elixir
@spec filler_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
```

Returns the "filler attribute" of a given table `style` and line `type`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.filler_attr(:mixed, :row)
    :green_background

    iex> alias IO.ANSI.Table.Style
    iex> Style.filler_attr(:cyan_alt, :odd_row)
    :chartreuse_yellow_background

# `from_switch_arg`

```elixir
@spec from_switch_arg(String.t()) :: {:ok, t()} | :error
```

Converts a switch `argument` into a table style.
E.g. `green-alt` in: `no tx -blt green-alt 11`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.from_switch_arg("green-alt")
    {:ok, :green_alt}

    iex> alias IO.ANSI.Table.Style
    iex> Style.from_switch_arg("lite")
    :error

# `key_attr`

```elixir
@spec key_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
```

Returns the "key attribute" of a given table `style` and line `type`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.key_attr(:light, :row)
    :chartreuse

    iex> alias IO.ANSI.Table.Style
    iex> Style.key_attr(:light, :header)
    [:gold, :underline]

# `line_types`

```elixir
@spec line_types(t()) :: [IO.ANSI.Table.LineType.t()]
```

Returns the "line types" of a given table `style`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.line_types(:light)
    [:top, :header, :separator, [:row], :bottom]

    iex> alias IO.ANSI.Table.Style
    iex> Style.line_types(:green_alt)
    [:top, :header, :separator, [:even_row, :odd_row]]

# `non_key_attr`

```elixir
@spec non_key_attr(t(), IO.ANSI.Table.LineType.t()) :: attr() | nil
```

Returns the "non-key attribute" of a given table `style` and line `type`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.non_key_attr(:cyan, :row)
    [:black, :cyan_background]

# `styles`

```elixir
@spec styles() :: [t()]
```

Returns the sorted list of all style IDs.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> length Style.styles
    36

    iex> alias IO.ANSI.Table.Style
    iex> Enum.take Style.styles, 7
    [:bare, :barish, :cyan, :cyan_alt, :cyan_border, :cyan_mult, :dark]

# `table_styles`

```elixir
@spec table_styles() :: keyword()
```

Lists all the table styles alphabetically.

# `texts`

```elixir
@spec texts(String.t()) :: [String.t()]
```

Returns a list of interpolated texts (for all styles) based on `template`.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.texts("  - `&style`&filler - &note\n") |> Enum.slice(16..18)
    ["  - `:green_border`          - light green border\n",
     "  - `:green_border_padded`   - light green border with extra padding\n",
     "  - `:green_border_unpadded` - light green border without padding\n"]

## Interpolation placeholders

  - `&style`  - table style (e.g. ":light_alt")
  - `&arg`    - table style switch arg (e.g. "light-alt")
  - `&filler` - padding after &style or &arg
  - `&note`   - table style note
  - `&rank`   - table style rank (3 digits)

# `to_switch_arg`

```elixir
@spec to_switch_arg(t()) :: String.t() | nil
```

Converts a table `style` into a switch argument.

## Examples

    iex> alias IO.ANSI.Table.Style
    iex> Style.to_switch_arg(:green_alt)
    "green-alt"

    iex> alias IO.ANSI.Table.Style
    iex> Style.to_switch_arg(:lite)
    nil

---

*Consult [api-reference.md](api-reference.md) for complete listing*
