diff --git a/client/src/modules/pluginapi.js b/client/src/modules/pluginapi.js
index 338476e3..5f7cbfbb 100644
--- a/client/src/modules/pluginapi.js
+++ b/client/src/modules/pluginapi.js
@@ -306,7 +306,7 @@ export default class PluginApi {
}
- /**
+ /**
* Toasts
*/
showToast(message, options = {}) {
@@ -324,6 +324,15 @@ export default class PluginApi {
showWarningToast(message, options = {}) {
return Toasts.warning(message, options);
}
+ get Toasts() {
+ return {
+ push: this.showToast.bind(this),
+ success: this.showSuccessToast.bind(this),
+ error: this.showErrorToast.bind(this),
+ info: this.showInfoToast.bind(this),
+ warning: this.showWarningToast.bind(this)
+ };
+ }
/**
diff --git a/client/src/modules/settings.js b/client/src/modules/settings.js
index 95fc055e..403df8cc 100644
--- a/client/src/modules/settings.js
+++ b/client/src/modules/settings.js
@@ -29,7 +29,7 @@ export default new class Settings {
Logger.log('Settings', [`${set.id}/${category.id}/${setting.id} was changed from`, old_value, 'to', value]);
Events.emit('setting-updated', event);
Events.emit(`setting-updated-${set.id}_${category.id}_${setting.id}`, event);
- Toasts.success(`${set.id}/${category.id}/${setting.id} was changed from ${old_value} to ${value}`); // Just for debugging purposes remove in prod
+ Toasts.success(`${set.id}/${category.id}/${setting.id} was changed from ${old_value} to ${value}`); // Just for debugging purposes remove in prod
});
set.on('settings-updated', async event => {
diff --git a/client/src/styles/partials/toasts.scss b/client/src/styles/partials/toasts.scss
index 99391ad6..0281240b 100644
--- a/client/src/styles/partials/toasts.scss
+++ b/client/src/styles/partials/toasts.scss
@@ -1,5 +1,5 @@
-bd-toasts {
- display: flex;
+.bd-toasts {
+ display: flex;
position: fixed;
top: 0;
width: 700px;
@@ -11,45 +11,44 @@ bd-toasts {
justify-content: flex-end;
pointer-events: none;
z-index: 4000;
-
+
.bd-toast {
position: relative;
animation: bd-toast-up 300ms ease;
- background: #36393F;
- padding: 10px;
- border-radius: 5px;
- box-shadow: 0 0 0 1px rgba(32,34,37,.6), 0 2px 10px 0 rgba(0,0,0,.2);
- font-weight: 500;
- color: #fff;
- user-select: text;
- font-size: 14px;
- margin-top: 10px;
+ background: #36393F;
+ padding: 10px;
+ border-radius: 5px;
+ box-shadow: 0 0 0 1px rgba(32,34,37,.6), 0 2px 10px 0 rgba(0,0,0,.2);
+ font-weight: 500;
+ color: #fff;
+ user-select: text;
+ font-size: 14px;
+ margin-top: 10px;
-
&.bd-toast-error {
background: #f04747;
}
-
+
&.bd-toast-info {
background: #4a90e2;
}
-
+
&.bd-toast-warning {
background: #FFA600;
}
-
+
&.bd-toast-success {
background: #43b581;
}
-
+
&.bd-toast-has-icon {
padding-left: 30px;
}
}
-
+
.bd-toast-icon {
position: absolute;
- left: 5px;
+ left: 5px;
top: 50%;
transform: translateY(-50%);
bottom: 0;
@@ -57,13 +56,13 @@ bd-toasts {
width: 20px;
border-radius: 50%;
overflow: hidden;
-
+
svg {
fill: white;
}
}
-
+
.bd-toast.bd-toast-closing {
- animation: bd-toast-down 300ms ease;
- }
-}
\ No newline at end of file
+ animation: bd-toast-down 300ms ease;
+ }
+}
diff --git a/client/src/ui/bdui.js b/client/src/ui/bdui.js
index 6f6df97d..4cf25833 100644
--- a/client/src/ui/bdui.js
+++ b/client/src/ui/bdui.js
@@ -43,13 +43,13 @@ export default class {
static injectUi() {
DOM.createElement('div', null, 'bd-settings').appendTo(DOM.bdBody);
DOM.createElement('div', null, 'bd-modals').appendTo(DOM.bdModals);
+ DOM.createElement('div', null, 'bd-toasts').appendTo(DOM.bdToasts);
DOM.createElement('bd-tooltips').appendTo(DOM.bdBody);
- DOM.createElement('bd-toasts').appendTo(DOM.bdBody);
- const toasts = new Vue({
- el: 'bd-toasts',
+ this.toasts = new Vue({
+ el: '#bd-toasts',
components: { BdToasts },
- template: ''
+ template: ''
});
this.modals = new Vue({
diff --git a/client/src/ui/components/BdToasts.vue b/client/src/ui/components/BdToasts.vue
index 29e65c42..e66e4ba7 100644
--- a/client/src/ui/components/BdToasts.vue
+++ b/client/src/ui/components/BdToasts.vue
@@ -1,5 +1,5 @@
/**
- * BetterDiscord Modals Component
+ * BetterDiscord Toasts Component
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
@@ -9,9 +9,9 @@
*/
-
+
-
+