Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Implement no-* attributes
Browse files Browse the repository at this point in the history
Implement positive attribute higher priority

Remove redundant icon type

Update code based on comments
  • Loading branch information
nbriannl committed Feb 26, 2020
1 parent 69c5667 commit 76b8e7f
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions src/TipBox.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="alert container" :class="[boxStyle, addClass, lightStyle, seamlessStyle]" :style="customStyle">
<div v-if="!isDefault" class="icon-wrapper" :class="[iconStyle]">
<div class="alert container" :class="[boxStyle, addClass, lightStyle, seamlessStyle, noBackgroundStyle, noBorderStyle]" :style="customStyle">
<div v-if="hasIcon" class="icon-wrapper" :class="[iconStyle]">
<slot name="_icon">
<span v-html="iconType"></span>
</slot>
Expand Down Expand Up @@ -74,11 +74,20 @@
type: Boolean,
default: false,
},
noIcon: {
type: Boolean,
default: false,
},
noBackground: {
type: Boolean,
default: false,
},
noBorder: {
type: Boolean,
default: false,
}
},
computed: {
isDefault() {
return this.type === 'none'
},
isSeamless() {
return toBoolean(this.seamless);
},
Expand Down Expand Up @@ -129,7 +138,7 @@
style.borderColor = this.backgroundColor;
}
if (this.borderColor) {
style.borderColor = this.borderColor;
style.border = `1px solid ${this.borderColor}`;
}
if (this.borderLeftColor) {
style.borderLeft = `5px solid ${this.borderLeftColor}`;
Expand All @@ -151,6 +160,11 @@
}
return '';
},
hasIcon() {
// this.$slots._icon is either undefined or an object
const isIconSlotFilled = !!this.$slots._icon;
return !this.noIcon || isIconSlotFilled;
},
iconType() {
switch (this.type) {
case 'wrong':
Expand All @@ -168,14 +182,26 @@
case 'definition':
return '<i class="fas fa-atlas"></i>';
default:
return '<i class="fas fa-exclamation"></i>';
return '';
}
},
iconStyle() {
if (this.iconSize) {
return `fa-${this.iconSize}`;
}
return '';
},
noBackgroundStyle() {
if (this.noBackground) {
return 'no-background';
}
return '';
},
noBorderStyle() {
if (this.noBorder) {
return 'no-border';
}
return '';
}
}
}
Expand Down Expand Up @@ -250,4 +276,12 @@
.vertical-divider {
width: 4px;
}
.no-background {
background: none;
}
.no-border {
border: none;
}
</style>

0 comments on commit 76b8e7f

Please sign in to comment.