Column metadata, closes #942

This commit is contained in:
Simon Willison 2021-08-12 16:53:23 -07:00 committed by GitHub
commit e837095ef3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 88 additions and 2 deletions

View file

@ -784,9 +784,14 @@ svg.dropdown-menu-icon {
font-size: 0.7em;
color: #666;
margin: 0;
padding: 0;
padding: 4px 8px 4px 8px;
}
.dropdown-menu .dropdown-column-description {
margin: 0;
color: #666;
padding: 4px 8px 4px 8px;
max-width: 20em;
}
.dropdown-menu li {
border-bottom: 1px solid #ccc;
}
@ -836,6 +841,16 @@ svg.dropdown-menu-icon {
background-repeat: no-repeat;
}
dl.column-descriptions dt {
font-weight: bold;
}
dl.column-descriptions dd {
padding-left: 1.5em;
white-space: pre-wrap;
line-height: 1.1em;
color: #666;
}
.anim-scale-in {
animation-name: scale-in;
animation-duration: 0.15s;

View file

@ -9,6 +9,7 @@ var DROPDOWN_HTML = `<div class="dropdown-menu">
<li><a class="dropdown-not-blank" href="#">Show not-blank rows</a></li>
</ul>
<p class="dropdown-column-type"></p>
<p class="dropdown-column-description"></p>
</div>`;
var DROPDOWN_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
@ -166,6 +167,14 @@ var DROPDOWN_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="14" heig
} else {
columnTypeP.style.display = "none";
}
var columnDescriptionP = menu.querySelector(".dropdown-column-description");
if (th.dataset.columnDescription) {
columnDescriptionP.innerText = th.dataset.columnDescription;
columnDescriptionP.style.display = "block";
} else {
columnDescriptionP.style.display = "none";
}
menu.style.position = "absolute";
menu.style.top = menuTop + 6 + "px";
menu.style.left = menuLeft + "px";