Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VAlert.js 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Styles
  2. import '../../../src/stylus/components/_alerts.styl';
  3. // Components
  4. import VIcon from '../VIcon';
  5. // Mixins
  6. import Colorable from '../../mixins/colorable';
  7. import Toggleable from '../../mixins/toggleable';
  8. import Transitionable from '../../mixins/transitionable';
  9. import mixins from '../../util/mixins';
  10. /* @vue/component */
  11. export default mixins(Colorable, Toggleable, Transitionable).extend({
  12. name: 'v-alert',
  13. props: {
  14. dismissible: Boolean,
  15. icon: String,
  16. outline: Boolean,
  17. type: {
  18. type: String,
  19. validator: function validator(val) {
  20. return ['info', 'error', 'success', 'warning'].includes(val);
  21. }
  22. }
  23. },
  24. computed: {
  25. computedColor: function computedColor() {
  26. return this.type && !this.color ? this.type : this.color || 'error';
  27. },
  28. computedIcon: function computedIcon() {
  29. if (this.icon || !this.type) return this.icon;
  30. switch (this.type) {
  31. case 'info':
  32. return '$vuetify.icons.info';
  33. case 'error':
  34. return '$vuetify.icons.error';
  35. case 'success':
  36. return '$vuetify.icons.success';
  37. case 'warning':
  38. return '$vuetify.icons.warning';
  39. }
  40. }
  41. },
  42. methods: {
  43. genIcon: function genIcon() {
  44. if (!this.computedIcon) return null;
  45. return this.$createElement(VIcon, {
  46. 'class': 'v-alert__icon'
  47. }, this.computedIcon);
  48. },
  49. genDismissible: function genDismissible() {
  50. var _this = this;
  51. if (!this.dismissible) return null;
  52. return this.$createElement('a', {
  53. 'class': 'v-alert__dismissible',
  54. on: { click: function click() {
  55. _this.isActive = false;
  56. } }
  57. }, [this.$createElement(VIcon, {
  58. props: {
  59. right: true
  60. }
  61. }, '$vuetify.icons.cancel')]);
  62. }
  63. },
  64. render: function render(h) {
  65. var children = [this.genIcon(), h('div', this.$slots.default), this.genDismissible()];
  66. var setColor = this.outline ? this.setTextColor : this.setBackgroundColor;
  67. var alert = h('div', setColor(this.computedColor, {
  68. staticClass: 'v-alert',
  69. 'class': {
  70. 'v-alert--outline': this.outline
  71. },
  72. directives: [{
  73. name: 'show',
  74. value: this.isActive
  75. }],
  76. on: this.$listeners
  77. }), children);
  78. if (!this.transition) return alert;
  79. return h('transition', {
  80. props: {
  81. name: this.transition,
  82. origin: this.origin,
  83. mode: this.mode
  84. }
  85. }, [alert]);
  86. }
  87. });
  88. //# sourceMappingURL=VAlert.js.map