Skip to content

Commit 7adc4d8

Browse files
committed
table styling
depends on a fork of ESPUI s00500/ESPUI#335
1 parent 09218a7 commit 7adc4d8

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

WatchTower.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void setup() {
133133
ESPUI.setPanelWide(ui_broadcast, true);
134134
ESPUI.setElementStyle(ui_broadcast, "font-family: monospace");
135135
ESPUI.setCustomJS(customJS);
136+
ESPUI.setCustomCSS(customCSS);
136137

137138
// You may disable the internal webserver by commenting out this line
138139
if( ENABLE_WEB_UI ) {

customJS.h

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const char* customJS = R"(
33
// the table has two rows. the top row are the bit values
44
// and the bottom row is the second within the minute.
55
// the canvas shows the logical high/low pin values.
6-
// TODO rename function
76
/**
87
* Converts a span's text into a visualization containing a Canvas diagram and a Data Table.
98
* @param {HTMLElement} containerSpan - The target DOM element.
@@ -103,4 +102,43 @@ window.addEventListener('load', function() {
103102
characterData: true // Detects text changes inside existing nodes
104103
});
105104
});
105+
)";
106+
107+
108+
109+
const char* const customCSS = R"(
110+
#id1 td {
111+
border: 1px solid #ccc;
112+
padding: 4px 6px;
113+
font-family: monospace;
114+
text-align: center;
115+
background-color: #f9f9f9;
116+
color: #864D0F;
117+
}
118+
#id1 {
119+
border-collapse: collapse;
120+
/* Ensure table fits content when placed directly in the span */
121+
width: auto;
122+
}
123+
/* Style for the index row */
124+
#id1 tfoot th {
125+
background-color: #e0f2f1; /* Light cyan background for index row */
126+
color: #00796b;
127+
font-weight: bold;
128+
text-align: center;
129+
}
130+
/* Style to ensure the original span is a block container for the table/canvas */
131+
.visualized-container {
132+
display: flex;
133+
flex-direction: column;
134+
align-items: flex-start; /* Aligns content to the left for correct scrolling */
135+
width: 100%;
136+
padding: 0;
137+
border: none;
138+
background: none;
139+
text-align: left;
140+
/* Ensure it allows horizontal scrolling */
141+
overflow-x: auto;
142+
}
143+
106144
)";

0 commit comments

Comments
 (0)