1.0.0 • Published 6 years ago

remark-responsive-tables v1.0.0

Weekly downloads
16
License
MIT
Repository
github
Last release
6 years ago

remark-responsible-tables

Creates a responsibe table by extracting thead titles and injecting them into each tbody row, those are hidded by default on desktop with CSS and displayed on mobile.

Options

classnames (required) Object

Classnames for each element:

  • title: thead titles
  • description: Second column description
  • content: Element that encapsulates description shown on mobile
  • mobile: Media query class for mobile
  • description: Media query class for desktop
{
  'title': 'title',
  'description': 'description',
  'content': 'content',
  'mobile': 'mobile',
  'desktop': 'desktop'
}

Example

Mobile

image

Desktop

image

Code

Options

{
  'classnames': {
    'title': 'title',
    'description': 'description',
    'content': 'content',
    'mobile': 'mobile',
    'desktop': 'desktop'
  }
}
thead {
  display: none;

  /* Mobile */
   {
    display: table-header-group;
  }
}

td {
  display: flex;
  flex-basis: 100%;
  align-self: stretch;

  /* Mobile */
   {
    display: table-cell;
  }
}

.titles {
  display: flex;
  flex-direction: column;
  justify-content: baseline;

  /* Mobile */
   {
    display: none;
  }
}

.content {
  display: flex;
  flex-direction: column;
  justify-content: baseline;
}

.description.desktop {
  display: none;

  /* Mobile */
   {
    display: block;
  }
}

.description.mobile {
  /* Mobile */
   {
    display: none;
  }
}