<template>
  <table class="upanapp-table" :class="{'upanapp-table-bordered': fullBordered, 'upanapp-table-no-cell-bordered': !cellBordered, 'upanapp-table-no-content-bordered': !contentBordered}">
    <slot></slot>
  </table>
</template>

<script>
export default {
  name: 'ua-table',
  props: {
    fullBordered: Boolean,
    cellBordered: {
      type: Boolean,
      default: true
    },
    contentBordered: {
      type: Boolean,
      default: true
    }
  }
}
</script>

<style lang="less">
@import '../../styles/1px.less';

.upanapp-table {
  line-height: 40px;
  position: relative;
  width: 100%;
  border-collapse: collapse;
  
  &:after {
    .setTopLine();
  }
  th {
    font-weight: 500
  }
}

.upanapp-table.upanapp-table-bordered {
  &:before {
    .setLeftLine();
  }
}

.upanapp-table td, .upanapp-table th {
  border-bottom: 1px solid #e0e0e0;
  border-right: 1px solid #e0e0e0;
  text-align: center;
}

.upanapp-table td, .upanapp-table th {
  position:relative;
  border-right: 0;
  border-bottom: 0;
}

.upanapp-table td, .upanapp-table th {
  &:before {
    .setBottomLine();
  }
}

.upanapp-table.upanapp-table-no-content-bordered td {
  &:before {
    border-bottom-width: 0;
  }
}

.upanapp-table.upanapp-table-no-content-bordered tr:last-child td {
  &:before {
    border-bottom-width: 1px;
  }
}

.upanapp-table td, .upanapp-table th {
  &:after {
    .setRightLine();
  }
}

.upanapp-table.upanapp-table-no-cell-bordered td, .upanapp-table.upanapp-table-no-cell-bordered th {
  &:after {
    border-right-width: 0;
  }
}

.upanapp-table tr td:last-child, .upanapp-table tr th:last-child {
  &:after {
    border-right-width: 0;
  }
}

.upanapp-table.upanapp-table-bordered tr td:last-child, .upanapp-table.upanapp-table-bordered tr th:last-child {
  &:after {
    border-right-width: 1px;
  }
}
</style>
