Table New

Installation

  yarn add @chewy/kib-table-new-styles

Import

  @use '~@chewy/kib-table-new-styles/src/styles' as kib-table-new;

Mixins

container

@mixin container() { ... }@mixin container() { 
  @include typography.style-as('paragraph-2');

  background-color: settings.$background-color;
  color: settings.$text-color;
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  border: settings.$border-width solid settings.$border-color;
 }
Description

Generic container styles

Parameters

None.

Requires

caption

@mixin caption() { ... }@mixin caption() { 
  @include typography.style-as('paragraph-2');

  padding: 0;
  text-align: center;
  font-style: normal;
  color: settings.$caption-text-color;
 }
Description

Generic caption styles

Parameters

None.

Requires

caption-hidden

@mixin caption-hidden() { ... }@mixin caption-hidden() { 
  overflow: hidden;
  clip: rect(0 0 0 0);
  height: 1px;
  width: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
 }
Description

Caption styles when hidden

Parameters

None.

caption-top

@mixin caption-top() { ... }@mixin caption-top() { 
  caption-side: top;
  padding-bottom: settings.$spacing-vertical;
 }
Description

Caption styles when position to the top of the table

Parameters

None.

Requires

caption-bottom

@mixin caption-bottom() { ... }@mixin caption-bottom() { 
  caption-side: bottom;
  padding-top: settings.$spacing-vertical;
 }
Description

Caption styles when position to the bottom of the table

Parameters

None.

Requires

header

@mixin header() { ... }@mixin header() { 
  border: none;
 }
Description

Generic header styles

Parameters

None.

body

@mixin body() { ... }@mixin body() { 
  border: none;
 }
Description

Generic body styles

Parameters

None.

@mixin footer() { ... }@mixin footer() { 
  border: none;
 }
Description

Generic footer styles

Parameters

None.

cell-base

@mixin cell-base() { ... }@mixin cell-base() { 
  vertical-align: top;
  text-align: left;
  padding: settings.$spacing-vertical settings.$spacing-horizontal;
  border: settings.$border-width solid settings.$border-color;
 }
Description

Common cell styles

Parameters

None.

Requires

cell

@mixin cell() { ... }@mixin cell() { 
  @include cell-base;
  @include typography.style-as('paragraph-1');
 }
Description

Generic cell styles

Parameters

None.

Requires

cell-condensed

@mixin cell-condensed() { ... }@mixin cell-condensed() { 
  padding: settings.$spacing-vertical-condensed settings.$spacing-horizontal-condensed;
 }
Description

Condensed cell styles

Parameters

None.

cell-striped

@mixin cell-striped() { ... }@mixin cell-striped() { 
  background-color: settings.$striped-background-color;

  > th,
  > td {
    @include cell-striped-hcm('row');
  }
 }
Description

Cell styles when striped

Parameters

None.

Requires
Used by

cell-striped-hcm

@mixin cell-striped-hcm() { ... }@mixin cell-striped-hcm() { 
  @media (forced-colors: active) {
    border-style: solid;

    @if $direction == 'row' {
      border-left-width: calc(settings.$border-width * 4);
      border-right-width: calc(settings.$border-width * 4);
    } @else if $direction == 'column' {
      border-top-width: calc(settings.$border-width * 4);
      border-bottom-width: calc(settings.$border-width * 4);
    }
  }
 }
Description

Cell styles when striped in HCM

Parameters

None.

Requires

heading

@mixin heading() { ... }@mixin heading() { 
  @include cell-base;
  @include typography.style-as('section-2');

  background-color: transparent;
 }
Description

Generic heading styles

Parameters

None.

Requires

heading-emphasized

@mixin heading-emphasized() { ... }@mixin heading-emphasized() { 
  background-color: settings.$emphasis-background-color;

  &,
  th,
  td {
    @include cell-striped-hcm('row');
    @include cell-striped-hcm('column');
  }
 }
Description

Heading styles when emphasized

Parameters

None.

heading-striped-emphasized

@mixin heading-striped-emphasized() { ... }@mixin heading-striped-emphasized() { 
  background-color: settings.$striped-emphasis-heading-background-color;
 }
Description

Heading styles when emphasized

Parameters

None.

Used by

horizontal-stripe

@mixin horizontal-stripe($cell, $heading, $emphasize: false) { ... }@mixin horizontal-stripe($cell, $heading, $emphasize: false) { 
  // no heading
  #{$cell}:nth-child(even) {
    @if $emphasize {
      @include heading-striped-emphasized;
    } @else {
      @include cell-striped;
      @include cell-striped-hcm('column');
    }
  }

  // with heading
  #{$heading} ~ #{$cell} {
    &:nth-child(odd) {
      @if $emphasize {
        @include heading-striped-emphasized;
      } @else {
        @include cell-striped;
      }
    }

    &:nth-child(even) {
      background-color: transparent;
    }
  }
 }
Description

Utility to apply heading and cell styles when striped

Parameters
Parameters
parameter Nameparameter Descriptionparameter Typeparameter Default value
$cell

The class selector for a row's columns

String none
$heading

The class selector for a row's heading

String none
$emphasize

Applies an emphasized heading style

Booleanfalse

Variables

text-color

$text-color: color.get('text', 'primary') !default;
Description

General text color

Type

Color

background-color

$background-color: color.get('ui-bg', 'primary') !default;
Description

General background color

Type

Color

spacing-vertical

$spacing-vertical: spacing.get('s4') !default;
Description

General table vertical spacing

Type

Number

spacing-horizontal

$spacing-horizontal: spacing.get('s4') !default;
Description

General table horizontal spacing

Type

Number

Used by

spacing-vertical-condensed

$spacing-vertical-condensed: spacing.get('s2') !default;
Description

Condensed table vertical spacing

Type

Number

Used by

spacing-horizontal-condensed

$spacing-horizontal-condensed: spacing.get('s2') !default;
Description

Condensed table horizontal spacing

Type

Number

Used by

border-width

$border-width: unit.rem(1px) !default;
Description

General table border width

Type

Number

border-color

$border-color: color.get('ui-bg', '05') !default;
Description

General border color

Type

Color

caption-text-color

$caption-text-color: color.get('text', 'tertiary') !default;
Description

Caption text color

Type

Color

Used by

emphasis-background-color

$emphasis-background-color: color.get('ui-bg', '04') !default;
Description

Table emphasis background color

Type

Color

Used by

striped-background-color

$striped-background-color: color.get('ui-bg', '04') !default;
Description

Table striped background color

Type

Color

Used by

striped-emphasis-heading-background-color

$striped-emphasis-heading-background-color: color.get('ui-bg', '07') !default;
Description

Table emphasis background color

Type

Color