@minhnd1010/chat-widget 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +23 -26
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -36,29 +36,27 @@ class ChatWidget extends HTMLElement {
36
36
  }
37
37
 
38
38
  render() {
39
- const position = this.getAttribute("position") || "bottom-left";
40
-
41
- let containerStyles = "bottom: 20px; left: 20px;";
42
- let boxStyles = "top: -78vh; left: 42px;";
43
-
44
- switch (position) {
45
- case "bottom-right":
46
- containerStyles = "bottom: 20px; right: 20px; left: auto;";
47
- boxStyles =
48
- "top: -78vh; right: 42px; left: auto; transform: translateX(-100%);";
49
- break;
50
- case "top-left":
51
- containerStyles = "top: 20px; left: 20px; bottom: auto;";
52
- boxStyles =
53
- "bottom: 80px; top: auto; left: 42px; transform: translateY(100%);";
54
- break;
55
- case "top-right":
56
- containerStyles = "top: 20px; right: 20px; left: auto; bottom: auto;";
57
- boxStyles =
58
- "bottom: 80px; top: auto; right: 42px; left: auto; transform: translateX(-100%) translateY(100%);";
59
- break;
60
- default:
61
- // bottom-left
39
+ let position = "";
40
+ const top = this.getAttribute("top");
41
+ const left = this.getAttribute("left");
42
+ const bottom = this.getAttribute("bottom");
43
+ const right = this.getAttribute("right");
44
+
45
+ if (top) {
46
+ position += `top: ${top};`;
47
+ }
48
+ if (left) {
49
+ position += `left: ${left};`;
50
+ }
51
+ if (bottom) {
52
+ position += `bottom: ${bottom};`;
53
+ }
54
+ if (right) {
55
+ position += `right: ${right};`;
56
+ }
57
+
58
+ if (position) {
59
+ position = `bottom: 20px; left: 20px;`;
62
60
  }
63
61
 
64
62
  const template = document.createElement("template");
@@ -76,8 +74,7 @@ class ChatWidget extends HTMLElement {
76
74
  ================================================================================ */
77
75
  .chat-container {
78
76
  position: fixed;
79
- bottom: 20px;
80
- left: 20px;
77
+ ${position}
81
78
  }
82
79
 
83
80
  #chat-icon {
@@ -840,7 +837,7 @@ class ChatWidget extends HTMLElement {
840
837
  // ================== USER INPUT ==================
841
838
  let token = this.getAttribute("token");
842
839
 
843
- let userId = this.getAttribute("ma_doi_tac_nsd");
840
+ let userId = this.getAttribute("ma-doi-tac-nsd");
844
841
 
845
842
  let fullName = this.getAttribute("ten");
846
843
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minhnd1010/chat-widget",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Chat widget hỗ trợ SignalR real-time cho website",
5
5
  "main": "index.js",
6
6
  "type": "module",