Tabs.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <div class="l-flex--row l-flex__none c-status-bar">
  3. <div
  4. v-for="tab in items"
  5. :key="tab.key"
  6. class="l-flex__none c-status-bar__item u-pointer"
  7. :class="{ active: tab.key === active }"
  8. @click="onClick(tab)"
  9. >
  10. {{ tab.name }}
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'Tabs',
  17. props: {
  18. active: {
  19. type: String,
  20. default: ''
  21. },
  22. items: {
  23. type: Array,
  24. default () {
  25. return []
  26. }
  27. }
  28. },
  29. methods: {
  30. onClick (tab) {
  31. this.$emit('update:active', tab.key)
  32. }
  33. }
  34. }
  35. </script>
  36. <style lang="scss" scoped>
  37. .c-status-bar {
  38. align-self: flex-start;
  39. padding: 4px;
  40. margin-bottom: $spacing;
  41. border-radius: 2px;
  42. background-color: #f4f7fb;
  43. overflow-x: auto;
  44. &__item {
  45. padding: 4px 10px;
  46. color: $info--dark;
  47. font-size: 16px;
  48. line-height: 1;
  49. & + & {
  50. margin-left: $spacing;
  51. }
  52. &.active {
  53. color: $blue;
  54. background-color: #fff;
  55. border-radius: inherit;
  56. }
  57. }
  58. }
  59. </style>