Skip to content

Commit

Permalink
Update log.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-advokate authored Sep 11, 2024
1 parent 250f378 commit 910ab97
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions src/plugins/utils/log.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const log = {
capsule: () => {},
default: () => {},
primary: () => {},
success: () => {},
warning: () => {},
danger: () => {},
};

function typeColor(type = "default") {
let color = "";
switch (type) {
Expand Down Expand Up @@ -38,23 +47,29 @@ function colorful(textArr) {
...textArr.map((t) => `color: ${typeColor(t.type)};`),
);
}
export default {
capsule: (title, info, type = "primary") => {
console.log(`%c ${title} %c ${info} %c`, "background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;", `background:${typeColor(type)}; padding: 1px; border-radius: 0 3px 3px 0; color: #fff;`, "background:transparent");
},
default: (text = "default") => {
colorful([{ text, type: "default" }]);
},
primary: (text = "primary") => {
colorful([{ text, type: "primary" }]);
},
success: (text = "success") => {
colorful([{ text, type: "success" }]);
},
warning: (text = "warning") => {
colorful([{ text, type: "warning" }]);
},
danger: (text = "danger") => {
colorful([{ text, type: "danger" }]);
},

log.capsule = (title = "", info = "", type = "primary") => {
console.log(`%c ${title} %c ${info} %c`, "background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;", `background:${typeColor(type)}; padding: 1px; border-radius: 0 3px 3px 0; color: #fff;`, "background:transparent");
};

log.default = (text = "default") => {
colorful([{ text, type: "default" }]);
};

log.primary = (text = "primary") => {
colorful([{ text, type: "primary" }]);
};

log.success = (text = "success") => {
colorful([{ text, type: "success" }]);
};

log.warning = (text = "warning") => {
colorful([{ text, type: "warning" }]);
};

log.danger = (text = "danger") => {
colorful([{ text, type: "danger" }]);
};

export default log;

0 comments on commit 910ab97

Please sign in to comment.