@@ -50,7 +50,14 @@
default: ''
},
showIcon: Boolean,
- center: Boolean
+ center: Boolean,
+ effect: {
+ type: String,
+ default: 'light',
+ validator: function(value) {
+ return ['light', 'dark'].indexOf(value) !== -1;
+ }
+ }
},
data() {
diff --git a/packages/theme-chalk/src/alert.scss b/packages/theme-chalk/src/alert.scss
index 659ac43e6..500560b2b 100644
--- a/packages/theme-chalk/src/alert.scss
+++ b/packages/theme-chalk/src/alert.scss
@@ -15,22 +15,51 @@
align-items: center;
transition: opacity .2s;
+ @include when(light) {
+ .el-alert__closebtn {
+ color: $--color-text-placeholder;
+ }
+ }
+
+ @include when(dark) {
+ .el-alert__closebtn {
+ color: $--color-white;
+ }
+ .el-alert__description {
+ color: $--color-white;
+ }
+ }
+
@include when(center) {
justify-content: center;
}
@include m(success) {
- background-color: $--alert-success-color;
- color: $--color-success;
-
- .el-alert__description {
+ &.is-light {
+ background-color: $--alert-success-color;
color: $--color-success;
+
+ .el-alert__description {
+ color: $--color-success;
+ }
+ }
+
+ &.is-dark {
+ background-color: $--color-success;
+ color: $--color-white;
}
}
@include m(info) {
- background-color: $--alert-info-color;
- color: $--color-info;
+ &.is-light {
+ background-color: $--alert-info-color;
+ color: $--color-info;
+ }
+
+ &.is-dark {
+ background-color: $--color-info;
+ color: $--color-white;
+ }
.el-alert__description {
color: $--color-info;
@@ -38,20 +67,34 @@
}
@include m(warning) {
- background-color: $--alert-warning-color;
- color: $--color-warning;
-
- .el-alert__description {
+ &.is-light {
+ background-color: $--alert-warning-color;
color: $--color-warning;
+
+ .el-alert__description {
+ color: $--color-warning;
+ }
+ }
+
+ &.is-dark {
+ background-color: $--color-warning;
+ color: $--color-white;
}
}
@include m(error) {
- background-color: $--alert-danger-color;
- color: $--color-danger;
-
- .el-alert__description {
+ &.is-light {
+ background-color: $--alert-danger-color;
color: $--color-danger;
+
+ .el-alert__description {
+ color: $--color-danger;
+ }
+ }
+
+ &.is-dark {
+ background-color: $--color-danger;
+ color: $--color-white;
}
}
@@ -84,7 +127,6 @@
@include e(closebtn) {
font-size: $--alert-close-font-size;
- color: $--color-text-placeholder;
opacity: 1;
position: absolute;
top: 12px;
diff --git a/test/unit/specs/alert.spec.js b/test/unit/specs/alert.spec.js
index ee72483b8..5c17d7360 100644
--- a/test/unit/specs/alert.spec.js
+++ b/test/unit/specs/alert.spec.js
@@ -35,6 +35,14 @@ describe('Alert', () => {
.to.equal('Unbowed, Unbent, Unbroken');
});
+ it('theme', () => {
+ vm = createTest(Alert, {
+ title: 'test',
+ effect: 'dark'
+ }, true);
+ expect(vm.$el.classList.contains('is-dark')).to.true;
+ });
+
it('title slot', () => {
vm = createVue(`
diff --git a/types/alert.d.ts b/types/alert.d.ts
index 374a58067..670cee991 100644
--- a/types/alert.d.ts
+++ b/types/alert.d.ts
@@ -1,6 +1,7 @@
import { ElementUIComponent } from './component'
export type AlertType = 'success' | 'warning' | 'info' | 'error'
+export type AlertEffect = 'dark' | 'light'
/** Alert Component */
export declare class ElAlert extends ElementUIComponent {
@@ -24,4 +25,7 @@ export declare class ElAlert extends ElementUIComponent {
/** If a type icon is displayed */
showIcon: boolean
+
+ /** Choose theme */
+ theme: AlertEffect
}