zois-core 2.0.4 → 2.0.5

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.
@@ -107,24 +107,30 @@ function showChangelogModal() {
107
107
  modal.appendChild(content);
108
108
  overlay.appendChild(modal);
109
109
  document.body.appendChild(overlay);
110
- overlay.onclick = (e) => {
111
- if (e.target === overlay) document.body.removeChild(overlay);
110
+ const exitHandler = () => {
111
+ document.removeEventListener("keydown", keyDownHandler, { capture: true });
112
+ document.body.removeChild(overlay);
112
113
  };
113
- closeBtn.onclick = () => document.body.removeChild(overlay);
114
- document.addEventListener("keydown", function handler(e) {
114
+ const keyDownHandler = (e) => {
115
115
  if (e.key === "Escape") {
116
- document.body.removeChild(overlay);
117
- document.removeEventListener("keydown", handler);
116
+ e.preventDefault();
117
+ e.stopPropagation();
118
+ exitHandler();
118
119
  }
119
- });
120
+ };
121
+ overlay.onclick = (e) => {
122
+ if (e.target === overlay) exitHandler();
123
+ };
124
+ closeBtn.onclick = exitHandler;
125
+ document.addEventListener("keydown", keyDownHandler, { capture: true });
120
126
  }
121
127
  function createCommitElement(changelogCommit) {
122
128
  try {
123
129
  const commitDiv = document.createElement("div");
124
130
  commitDiv.style.cssText = `
125
131
  display: flex;
132
+ flex-direction: column;
126
133
  gap: 12px;
127
- align-items: center;
128
134
  padding: 12px;
129
135
  border: 1px solid #e5e7eb;
130
136
  border-radius: 8px;
@@ -132,6 +138,13 @@ function createCommitElement(changelogCommit) {
132
138
  `;
133
139
  commitDiv.onmouseover = () => commitDiv.style.borderColor = "#3b82f6";
134
140
  commitDiv.onmouseout = () => commitDiv.style.borderColor = "#e5e7eb";
141
+ const avatarAndInfo = document.createElement("div");
142
+ avatarAndInfo.style.cssText = `
143
+ display: flex;
144
+ gap: 12px;
145
+ align-items: center;
146
+ `;
147
+ commitDiv.append(avatarAndInfo);
135
148
  const avatar = document.createElement("img");
136
149
  avatar.src = changelogCommit.author.avatar_url;
137
150
  avatar.style.cssText = `
@@ -140,18 +153,29 @@ function createCommitElement(changelogCommit) {
140
153
  border-radius: 50%;
141
154
  flex-shrink: 0;
142
155
  `;
156
+ avatarAndInfo.append(avatar);
143
157
  const info = document.createElement("div");
144
158
  info.style.flex = "1";
145
159
  info.style.position = "relative";
160
+ avatarAndInfo.append(info);
146
161
  const author = document.createElement("div");
147
162
  author.textContent = changelogCommit.author.name;
148
163
  author.style.fontWeight = "600";
149
164
  author.style.marginBottom = "4px";
165
+ info.append(author);
150
166
  const message = document.createElement("div");
151
167
  message.textContent = changelogCommit.message;
152
168
  message.style.cssText = "color: #374151; line-height: 1.4;";
169
+ info.append(message);
170
+ if (changelogCommit.note) {
171
+ const note = document.createElement("div");
172
+ note.textContent = changelogCommit.note ?? "";
173
+ note.style.cssText = "color: #374151; line-height: 1; font-size: 0.8em;";
174
+ commitDiv.append(note);
175
+ }
153
176
  const tags = document.createElement("div");
154
177
  tags.style.cssText = "display: flex; gap: 4px; position: absolute; right: 2px; top: 2px;";
178
+ info.append(tags);
155
179
  for (const tag of changelogCommit.tags) {
156
180
  const tagEl = document.createElement("p");
157
181
  tagEl.textContent = TAGS[tag].name;
@@ -169,13 +193,10 @@ function createCommitElement(changelogCommit) {
169
193
  });
170
194
  tags.append(tagEl);
171
195
  }
172
- info.append(author, message, tags);
173
196
  commitDiv.style.cursor = "pointer";
174
197
  commitDiv.onclick = () => {
175
198
  window.open(changelogCommit.commit_url, "_blank");
176
199
  };
177
- commitDiv.appendChild(avatar);
178
- commitDiv.appendChild(info);
179
200
  return commitDiv;
180
201
  } catch (err) {
181
202
  logger.error(`Failed to load commit ${changelogCommit.sha}:`, err);
@@ -107,10 +107,9 @@ class ButtonShard extends Shard {
107
107
  if (text) {
108
108
  textElement = document.createElement("span");
109
109
  textElement.textContent = text;
110
- textElement.style.height = "100%";
111
- textElement.style.display = "grid";
112
- textElement.style.placeContent = "center";
113
- textElement.style.overflow = "scroll";
110
+ textElement.style.overflow = "auto";
111
+ textElement.style.padding = "0.08em";
112
+ textElement.style.maxHeight = "100%";
114
113
  btn.append(textElement);
115
114
  }
116
115
  if (tooltip) {
@@ -23,7 +23,7 @@ class CheckboxShard extends Shard {
23
23
  backgroundColor: "var(--tmd-accent, black)",
24
24
  borderColor: "var(--tmd-accent, black)"
25
25
  },
26
- ":checked > svg": {
26
+ ":checked + svg": {
27
27
  strokeDashoffset: "0"
28
28
  },
29
29
  ":checked:hover": {
@@ -36,8 +36,33 @@ class CheckboxShard extends Shard {
36
36
  },
37
37
  ".pop": {
38
38
  animation: "pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards"
39
- },
40
- "> .tooltip": {
39
+ }
40
+ };
41
+ }
42
+ get dynamicClassCheckmark() {
43
+ return {
44
+ base: {
45
+ position: "absolute",
46
+ top: "50%",
47
+ left: "50%",
48
+ transform: "translate(-50%, -50%)",
49
+ width: "70%",
50
+ height: "70%",
51
+ pointerEvents: "none",
52
+ stroke: "var(--tmd-text, white)",
53
+ strokeWidth: "3.5",
54
+ strokeLinecap: "round",
55
+ strokeLinejoin: "round",
56
+ fill: "none",
57
+ strokeDasharray: "24",
58
+ strokeDashoffset: "24",
59
+ transition: "stroke-dashoffset 0.45s cubic-bezier(0.25, 0.1, 0.25, 1)"
60
+ }
61
+ };
62
+ }
63
+ get dynamicClassTooltip() {
64
+ return {
65
+ base: {
41
66
  position: "absolute",
42
67
  color: "var(--tmd-text, black)",
43
68
  fontSize: "0.65em",
@@ -47,32 +72,29 @@ class CheckboxShard extends Shard {
47
72
  background: "var(--tmd-element-hint, #e6e6e6)",
48
73
  width: "max-content",
49
74
  visibility: "hidden",
50
- zIndex: "10"
75
+ zIndex: "10",
76
+ pointerEvents: "none",
77
+ whiteSpace: "nowrap"
51
78
  },
52
- "> .tooltip[position=left]": {
79
+ "[position=left]": {
53
80
  right: "calc(100% + 1vw)"
54
81
  },
55
- "> .tooltip[position=right]": {
82
+ "[position=right]": {
56
83
  left: "calc(100% + 1vw)"
57
- },
58
- ":hover .tooltip": {
59
- visibility: "visible"
60
84
  }
61
85
  };
62
86
  }
63
- get dynamicClassCheckmark() {
87
+ get dynamicClassBox() {
64
88
  return {
65
89
  base: {
66
- width: "70%",
67
- height: "70%",
68
- stroke: "var(--tmd-text, white)",
69
- strokeWidth: "3.5",
70
- strokeLinecap: "round",
71
- strokeLinejoin: "round",
72
- fill: "none",
73
- strokeDasharray: "24",
74
- strokeDashoffset: "24",
75
- transition: "stroke-dashoffset 0.45s cubic-bezier(0.25, 0.1, 0.25, 1)"
90
+ position: "relative",
91
+ display: "inline-flex",
92
+ alignItems: "center",
93
+ justifyContent: "center",
94
+ flexShrink: "0"
95
+ },
96
+ ":hover .tooltip": {
97
+ visibility: "visible"
76
98
  }
77
99
  };
78
100
  }
@@ -86,6 +108,9 @@ class CheckboxShard extends Shard {
86
108
  wrapper.style.alignItems = "center";
87
109
  wrapper.style.columnGap = "1vw";
88
110
  wrapper.style.padding = "0.25em";
111
+ setFontFamily(wrapper, MOD_DATA.fontFamily);
112
+ const box = document.createElement("div");
113
+ addDynamicClass(box, this.dynamicClassBox);
89
114
  const input = document.createElement("input");
90
115
  input.type = "checkbox";
91
116
  input.checked = isChecked;
@@ -94,12 +119,14 @@ class CheckboxShard extends Shard {
94
119
  const checkmark = document.createElementNS("http://www.w3.org/2000/svg", "svg");
95
120
  checkmark.setAttribute("viewBox", "0 0 24 24");
96
121
  checkmark.setAttribute("class", "checkmark");
97
- checkmark.innerHTML = `<path d="M5 13L9 17L19 7" />`;
122
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
123
+ path.setAttribute("d", "M5 13L9 17L19 7");
124
+ checkmark.appendChild(path);
98
125
  addDynamicClass(checkmark, this.dynamicClassCheckmark);
126
+ box.append(input, checkmark);
99
127
  const label = document.createElement("p");
100
128
  label.textContent = text;
101
129
  label.style.color = this.textColor;
102
- setFontFamily(label, MOD_DATA.fontFamily);
103
130
  if (typeof isDisabled === "function" && isDisabled()) {
104
131
  input.disabled = true;
105
132
  wrapper.classList.add("zcDisabled");
@@ -113,14 +140,14 @@ class CheckboxShard extends Shard {
113
140
  if (input.checked) {
114
141
  }
115
142
  });
116
- input.appendChild(checkmark);
117
- wrapper.append(input, label);
143
+ wrapper.append(box, label);
118
144
  if (tooltip) {
119
145
  const tooltipEl = document.createElement("span");
120
146
  tooltipEl.classList.add("tooltip");
121
147
  tooltipEl.setAttribute("position", tooltip.position);
122
148
  tooltipEl.textContent = tooltip.text;
123
- input.appendChild(tooltipEl);
149
+ addDynamicClass(tooltipEl, this.dynamicClassTooltip);
150
+ box.appendChild(tooltipEl);
124
151
  }
125
152
  return {
126
153
  base: wrapper,
@@ -9,7 +9,8 @@ class TextShard extends Shard {
9
9
  const p = document.createElement("p");
10
10
  p.innerHTML = this.context.text ?? "";
11
11
  p.style.color = this.context.color ?? this.defaultColor;
12
- p.style.overflow = "scroll";
12
+ p.style.overflow = "auto";
13
+ p.style.padding = "0.08em";
13
14
  if (this.context.withBackground) p.style.background = "var(--tmd-element,rgb(239, 239, 239))";
14
15
  if (this.context.withBorder) p.style.border = "2px solid var(--tmd-accent, rgb(236, 236, 236))";
15
16
  setFontFamily(p, MOD_DATA.fontFamily);
@@ -30,6 +30,7 @@ export interface ModData {
30
30
  generated_at: string;
31
31
  changes: {
32
32
  message: string;
33
+ note?: string;
33
34
  sha: string;
34
35
  author: {
35
36
  name: string;
@@ -13,6 +13,8 @@ export interface CheckboxShardContext extends ShardContext<"checkbox" | "label">
13
13
  export declare class CheckboxShard extends Shard<CheckboxShardContext> {
14
14
  protected get dynamicClassInput(): DynamicClassStyles;
15
15
  protected get dynamicClassCheckmark(): DynamicClassStyles;
16
+ protected get dynamicClassTooltip(): DynamicClassStyles;
17
+ protected get dynamicClassBox(): DynamicClassStyles;
16
18
  protected get textColor(): string;
17
19
  generateBody(): Record<keyof NonNullable<CheckboxShardContext["modules"]>, HTMLElement | SVGElement>;
18
20
  update(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "The core for the my mods, which contains a shared code reused in all my mods",
5
5
  "bin": {
6
6
  "zois-core": "scripts/zois-core.mjs"