项目原始demo,不改动
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
Questo repository è archiviato. Puoi vedere i file e clonarli, ma non puoi effettuare richieste di pushj o aprire problemi/richieste di pull.
 
 
 
 

152 righe
4.2 KiB

  1. // Styles
  2. import "../../../src/components/VToolbar/VToolbar.sass"; // Extensions
  3. import VSheet from '../VSheet/VSheet'; // Components
  4. import VImg from '../VImg/VImg'; // Utilities
  5. import { convertToUnit, getSlot } from '../../util/helpers';
  6. import { breaking } from '../../util/console';
  7. /* @vue/component */
  8. export default VSheet.extend({
  9. name: 'v-toolbar',
  10. props: {
  11. absolute: Boolean,
  12. bottom: Boolean,
  13. collapse: Boolean,
  14. dense: Boolean,
  15. extended: Boolean,
  16. extensionHeight: {
  17. default: 48,
  18. type: [Number, String]
  19. },
  20. flat: Boolean,
  21. floating: Boolean,
  22. prominent: Boolean,
  23. short: Boolean,
  24. src: {
  25. type: [String, Object],
  26. default: ''
  27. },
  28. tag: {
  29. type: String,
  30. default: 'header'
  31. },
  32. tile: {
  33. type: Boolean,
  34. default: true
  35. }
  36. },
  37. data: () => ({
  38. isExtended: false
  39. }),
  40. computed: {
  41. computedHeight() {
  42. const height = this.computedContentHeight;
  43. if (!this.isExtended) return height;
  44. const extensionHeight = parseInt(this.extensionHeight);
  45. return this.isCollapsed ? height : height + (!isNaN(extensionHeight) ? extensionHeight : 0);
  46. },
  47. computedContentHeight() {
  48. if (this.height) return parseInt(this.height);
  49. if (this.isProminent && this.dense) return 96;
  50. if (this.isProminent && this.short) return 112;
  51. if (this.isProminent) return 128;
  52. if (this.dense) return 48;
  53. if (this.short || this.$vuetify.breakpoint.smAndDown) return 56;
  54. return 64;
  55. },
  56. classes() {
  57. return { ...VSheet.options.computed.classes.call(this),
  58. 'v-toolbar': true,
  59. 'v-toolbar--absolute': this.absolute,
  60. 'v-toolbar--bottom': this.bottom,
  61. 'v-toolbar--collapse': this.collapse,
  62. 'v-toolbar--collapsed': this.isCollapsed,
  63. 'v-toolbar--dense': this.dense,
  64. 'v-toolbar--extended': this.isExtended,
  65. 'v-toolbar--flat': this.flat,
  66. 'v-toolbar--floating': this.floating,
  67. 'v-toolbar--prominent': this.isProminent
  68. };
  69. },
  70. isCollapsed() {
  71. return this.collapse;
  72. },
  73. isProminent() {
  74. return this.prominent;
  75. },
  76. styles() {
  77. return { ...this.measurableStyles,
  78. height: convertToUnit(this.computedHeight)
  79. };
  80. }
  81. },
  82. created() {
  83. const breakingProps = [['app', '<v-app-bar app>'], ['manual-scroll', '<v-app-bar :value="false">'], ['clipped-left', '<v-app-bar clipped-left>'], ['clipped-right', '<v-app-bar clipped-right>'], ['inverted-scroll', '<v-app-bar inverted-scroll>'], ['scroll-off-screen', '<v-app-bar scroll-off-screen>'], ['scroll-target', '<v-app-bar scroll-target>'], ['scroll-threshold', '<v-app-bar scroll-threshold>'], ['card', '<v-app-bar flat>']];
  84. /* istanbul ignore next */
  85. breakingProps.forEach(([original, replacement]) => {
  86. if (this.$attrs.hasOwnProperty(original)) breaking(original, replacement, this);
  87. });
  88. },
  89. methods: {
  90. genBackground() {
  91. const props = {
  92. height: convertToUnit(this.computedHeight),
  93. src: this.src
  94. };
  95. const image = this.$scopedSlots.img ? this.$scopedSlots.img({
  96. props
  97. }) : this.$createElement(VImg, {
  98. props
  99. });
  100. return this.$createElement('div', {
  101. staticClass: 'v-toolbar__image'
  102. }, [image]);
  103. },
  104. genContent() {
  105. return this.$createElement('div', {
  106. staticClass: 'v-toolbar__content',
  107. style: {
  108. height: convertToUnit(this.computedContentHeight)
  109. }
  110. }, getSlot(this));
  111. },
  112. genExtension() {
  113. return this.$createElement('div', {
  114. staticClass: 'v-toolbar__extension',
  115. style: {
  116. height: convertToUnit(this.extensionHeight)
  117. }
  118. }, getSlot(this, 'extension'));
  119. }
  120. },
  121. render(h) {
  122. this.isExtended = this.extended || !!this.$scopedSlots.extension;
  123. const children = [this.genContent()];
  124. const data = this.setBackgroundColor(this.color, {
  125. class: this.classes,
  126. style: this.styles,
  127. on: this.$listeners
  128. });
  129. if (this.isExtended) children.push(this.genExtension());
  130. if (this.src || this.$scopedSlots.img) children.unshift(this.genBackground());
  131. return h(this.tag, data, children);
  132. }
  133. });
  134. //# sourceMappingURL=VToolbar.js.map