Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ <h2>Event Actions</h2>
<pre
class="config-display"
id="events-display"
style="display: none"
hidden
>
[]</pre
>
Expand Down
19 changes: 19 additions & 0 deletions examples/demo/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,22 @@
.tg-time-grid-container::-webkit-scrollbar-thumb:hover {
background: #333 !important;
}

/* Custom event render (renderEvent hook in main.ts) */
.custom-event-icon {
margin-right: 4px;
font-size: 10px;
opacity: 0.8;
}

.segment-badge {
margin-left: 4px;
font-size: 9px;
opacity: 0.6;
}

.time-badge {
margin-top: 2px;
font-size: 9px;
opacity: 0.7;
}
83 changes: 44 additions & 39 deletions examples/demo/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ function createCalendar(): void {
// Add custom icon based on event color
const icon = document.createElement("span");
icon.className = "custom-event-icon";
icon.style.cssText =
"margin-right: 4px; font-size: 10px; opacity: 0.8;";

// Choose icon based on color
const color = ctx.event.color || "#3b82f6";
Expand Down Expand Up @@ -200,8 +198,6 @@ function createCalendar(): void {
) {
const segmentBadge = document.createElement("span");
segmentBadge.className = "segment-badge";
segmentBadge.style.cssText =
"font-size: 9px; opacity: 0.6; margin-left: 4px;";
segmentBadge.textContent = `(${ctx.segmentIndex + 1}/${ctx.totalSegments})`;
ctx.el.appendChild(segmentBadge);
}
Expand All @@ -210,8 +206,6 @@ function createCalendar(): void {
if (ctx.startTime && ctx.viewType !== "month") {
const timeBadge = document.createElement("div");
timeBadge.className = "time-badge";
timeBadge.style.cssText =
"font-size: 9px; opacity: 0.7; margin-top: 2px;";
timeBadge.textContent = `⏰ ${ctx.startTime}`;
ctx.el.appendChild(timeBadge);
}
Expand Down Expand Up @@ -524,8 +518,13 @@ function log(message: string): void {
minute: "2-digit",
second: "2-digit",
});
const entry = `<div class="log-entry"><span class="log-timestamp">[${timestamp}]</span>${message}</div>`;
logEl.innerHTML = entry + logEl.innerHTML;
const entry = document.createElement("div");
entry.className = "log-entry";
const timestampEl = document.createElement("span");
timestampEl.className = "log-timestamp";
timestampEl.textContent = `[${timestamp}]`;
entry.append(timestampEl, message);
logEl.prepend(entry);

// Limit log entries
const entries = logEl.querySelectorAll(".log-entry");
Expand Down Expand Up @@ -670,18 +669,22 @@ function initDaysSelector(): void {
if (!container) return;

const labels = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
container.innerHTML = labels
.map(
(label, idx) => `
<label class="day-checkbox">
<input type="checkbox" class="checkbox-brutal" data-day="${idx}"
${state.activeDays.includes(idx) ? "checked" : ""}
onchange="toggleDay(${idx})">
<span>${label}</span>
</label>
`,
)
.join("");
container.replaceChildren(
...labels.map((label, idx) => {
const labelEl = document.createElement("label");
labelEl.className = "day-checkbox";
const input = document.createElement("input");
input.type = "checkbox";
input.className = "checkbox-brutal";
input.dataset.day = String(idx);
input.checked = state.activeDays.includes(idx);
input.addEventListener("change", () => (window as any).toggleDay(idx));
const text = document.createElement("span");
text.textContent = label;
labelEl.append(input, text);
return labelEl;
}),
);
}

function updateDayCheckboxes(): void {
Expand Down Expand Up @@ -861,13 +864,13 @@ let eventCounter = 100;

if (configDisplay && eventsDisplay && actionBtn) {
if (tab === "config") {
configDisplay.style.display = "block";
eventsDisplay.style.display = "none";
configDisplay.hidden = false;
eventsDisplay.hidden = true;
actionBtn.textContent = "Copy";
actionBtn.onclick = () => (window as any).copyConfig();
} else {
configDisplay.style.display = "none";
eventsDisplay.style.display = "block";
configDisplay.hidden = true;
eventsDisplay.hidden = false;
actionBtn.textContent = "Copy";
actionBtn.onclick = () => (window as any).copyConfig();
updateEventsDisplay();
Expand All @@ -888,21 +891,23 @@ function initCustomViewsSection(): void {

const viewsInfo = getCustomViewInfo();

container.innerHTML = viewsInfo
.map(
(view) => `
<button
class="btn-brutal custom-view-btn"
id="btn-${view.type}"
onclick="setView('${view.type}')"
title="${view.description}"
>
<span class="view-label">${view.label}</span>
<span class="view-short">${view.shortLabel}</span>
</button>
`,
)
.join("");
container.replaceChildren(
...viewsInfo.map((view) => {
const button = document.createElement("button");
button.className = "btn-brutal custom-view-btn";
button.id = `btn-${view.type}`;
button.title = view.description;
button.addEventListener("click", () => (window as any).setView(view.type));
const label = document.createElement("span");
label.className = "view-label";
label.textContent = view.label;
const short = document.createElement("span");
short.className = "view-short";
short.textContent = view.shortLabel ?? "";
button.append(label, short);
return button;
}),
);
}

// =============================================================================
Expand Down
Loading