globocom/megadraft-table-plugin

View on GitHub
src/styles/plugin.scss

Summary

Maintainability
Test Coverage
/*
 * Copyright (c) 2016, Globo.com <https://github.com/globocom/megadraft-table-plugin>
 *
 * License: MIT
 */

/*
 * YOUR STYLES HERE
 */

$table-border: 1px solid #eeeeee;
$highlight-color: rgb(230, 230, 230);
$highlight-border: 1px solid #eeeeee;

@mixin cell {
  background-color: #fff;
  border-bottom: $table-border;
  border-right: $table-border;
  font-family: "Open Sans", sans-serif;
  font-size: 14px;
  height: 38px;
  line-height: 20px;
  min-height: 32px;
  text-align: start;
  white-space: pre-line;
  box-sizing: border-box;
}

.table-manager-modal {
  z-index: 2700;

  .bs-modal__body {
    padding: 0 !important;
    display: flex;
    height: 100%;
  }

  .bs-modal__footer {
    display: flex;
    justify-content: flex-end;
  }

  &__form {
    background-color: rgb(251, 251, 251);
    border-right: $table-border;
    box-sizing: border-box;
    padding: 1rem 1.5rem;
    width: 286px;
  }

  &__editable-table {
    background-color: rgb(237, 237, 237);
    flex-grow: 1;
    position: relative;
    overflow: auto;
  }

  &__table-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    text-align: center;
    white-space: nowrap;

    &:before {
      content: '';
      display: inline-block;
      height: 100%;
      vertical-align: middle;
      margin-right: -0.25em; /* Adjusts for spacing */
    }

  }

  table {
    display: inline-block;
    vertical-align: middle;
    border-collapse: separate;
    padding: 2rem;
    width: auto;
    border-spacing: 0;
  }

  .table-row {
    background-color: #fff;

  }

  .table-cell {
    @include cell;
    min-width: 128px;
    cursor: text;
    letter-spacing: -0.01562rem;

    &:last-child {
      border-right: 0;
    }

    & input {
      border: 0px;
      font: inherit;
      line-height: inherit;
      width: 100%;
      height: 100%;
      min-height: 38px;
      // margin: -8px 0 -8px -10px;
      padding: 0;

      &:focus { outline: none;}
    }

    &.selected-cell {
      border: 3px solid #4990e2 !important;
      border-radius: 4px;
      box-sizing: border-box;
    }

    &-content {
      padding: 8px 10px;
    }
  }

  .bs-ui-form-control {

    .bs-ui-checkbox {
      display: inline-block;
      margin-right: 14px;

      &:last-child {
        margin-right: 0;
      }

      input {
        margin-left: -2px;
      }

      input:before {
        top: 6px;
        height: 12px;
        width: 12px;
      }

      input:after {
        top: 7px;
        height: 8px;
        left: 5px;
        width: 4px;
      }

      .header-style-icon {
        vertical-align: middle;
        margin-top: 2px;
      }
    }

    .bs-ui-button {
      padding: 0;
      margin-bottom: 10px;

      &.btn-remove {
        margin-left: 50px;
      }
    }
  }


  .header-style {
    &--bottom {
      transform: rotate(180deg);
    }

    &--right {
      transform: rotate(90deg);
    }

    &--left {
      transform: rotate(270deg);
    }

    &__label {
      display: inline-block;
    }

  }

  .add-remove-rows, .add-remove-columns {
    .btn-add svg, .btn-remove svg {
      height: 16px;
      vertical-align: top;
      width: 16px;
    }

    .btn-remove svg path {
      fill: #e83f26;
    }

    .btn-add svg path {
      fill: #0769de;
    }
  }
}

.table-manager-block {
  background-color: #fff;
  padding: 1rem 0;
  overflow: hidden;

  &__wrapper {
    display: inline-block;
  }

  &__title {
    line-height: 32px;
    font-size: 20px;
  }
  &__inner-wrapper {
    display: inline-block;
  }
  table {
    line-height: 32px;
    border-spacing: 0;
    width: auto;
  }

  .table-cell {
    @include cell;

    min-width: 50px;
    border-spacing: 0px;
    padding: 8px 10px;

    &:last-child {
      border-right: 0;
    }
  }

  &__source {
    text-align: left;
    font-size: 13px;
    color: #999;
    line-height: 16px;
    padding-bottom: 1rem;
  }
}

.highlight-left {
  .table-row {
    &:last-child .table-cell:first-child {
      border-bottom: 0;
    }

    .table-cell:first-child {
      font-weight: bold;
      background-color: $highlight-color;
      border-right: 0;
      border-bottom: $highlight-border;

      input {
        background-color: $highlight-color;
      }
    }
  }

  &.highlight-top, &.highlight-bottom {
    .table-row .table-cell:first-child {
      border-right: $highlight-border;
    }
  }
}

.highlight-right {
  .table-row {
    &:last-child .table-cell:last-child {
      border-bottom: $table-border;
    }

    .table-cell:last-child {
      font-weight: bold;
      background-color: $highlight-color;
      border-bottom: $highlight-border;
      border-left: 0;

      input {
        background-color: $highlight-color;
      }
    }
  }

  .table-cell {
    border-right: 0;
    border-left: $table-border;

    &:first-child {
      border-left: 0;
    }
  }

  &.highlight-top {
    .table-row {
      .table-cell:last-child {
        border-left: $highlight-border;
      }
      &:first-child .table-cell {
        border-right: 0;
        border-left: $highlight-border;

        &:first-child { border-left: 0; }
      }
    }
  }

  &.highlight-bottom {
    .table-row {
      &:last-child .table-cell {
        border-right: 0;
        border-left: $highlight-border;

        &:first-child { border-left: 0; }
      }
    }

  }
}

.highlight-top {
  .table-row:first-child {
    font-weight: bold;
    background-color: $highlight-color;

    .table-cell {
      background-color: initial;
      border-bottom: 0;
      border-right: $highlight-border;

      input {
        background-color: $highlight-color;
      }

      &:last-child {
        border-right: 0;
      }
    }
  }
  &.highlight-right, &.highlight-left {
    .table-row:first-child .table-cell { border-bottom: $highlight-border; }
  }
}

.highlight-bottom {
  .table-row {
    &:last-child {
      font-weight: bold;
      background-color: $highlight-color;

      input {
        background-color: $highlight-color;
      }

      .table-cell {
        border-right: $highlight-border;
        background-color: initial;
        border-top: $highlight-border;

        &:last-child {
          border-right: 0;
        }
      }
    }

    &:first-child .table-cell {
      border-top: 0;
    }
  }

  .table-cell {
    border-bottom: 0;
    border-top: $table-border;
  }

  &.highlight-right .table-row {
    &:last-child .table-cell:last-child {
      border-bottom: 0;
    }

    .table-cell:last-child {
      border-left: $highlight-border;
    }
  }
}



.head-tooltip-toggle {
  // based on https://codepen.io/cristina-silva/pen/XXOpga
  cursor: pointer;
  position: relative;
  margin: 4px;
  vertical-align: middle;

  .info-icon {
    color: #666;
    font-size: 14px;
  }
  
  //Tooltip text container
  &::before {
    background: #616161;
    border-radius: 2px;
    color: rgba(255, 255, 255, 1);
    content: attr(aria-label); //This pulls in the text from the element with the tooltip
    font-family: "Roboto", "Open Sans", "Helvetica", "Arial", sans-serif;
    font-size: 12px;
    left: -80px;
    line-height: 16px;
    min-height: 32px;
    opacity: 0;
    padding: 8px;
    position: absolute;
    top: -50px;
    transform: scale(0);
    transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
    width: 160px;
  }

  //Triggering the transition
  &:hover::before {
    opacity: 0.9;
    transform: scale(1);
  }
}