add color highlights for features

This commit is contained in:
Trent Palmer 2021-08-19 12:01:44 -07:00
parent d03c4b5ef9
commit b1eb51c2ad
2 changed files with 17 additions and 3 deletions

View File

@ -151,7 +151,7 @@ function buildResults() {
sortThemes(filteredThemes, sortedBy);
// from buildThemeTableRow.js
filteredThemes.forEach((theme) =>
addThemeTableRow(theme, selectedColumns, selectedTags)
addThemeTableRow(theme, selectedColumns, selectedTags, selectedFeatures)
);
// from buildSelectionMenu.js

View File

@ -1,4 +1,9 @@
function addThemeTableRow(theme, selectedColumns, selectedTags) {
function addThemeTableRow(
theme,
selectedColumns,
selectedTags,
selectedFeatures
) {
let resultsTable = document.getElementById("resultsTable");
let resultsTableRow = document.createElement("tr");
@ -68,7 +73,16 @@ function addThemeTableRow(theme, selectedColumns, selectedTags) {
let featuresTD = document.createElement("td");
let fL = theme.features.length - 1;
fL += theme.features.map((x) => x.length).reduce((a, b) => a + b, 0);
featuresTD.innerHTML = theme.features;
let sFeatures = theme.features.filter((x) => selectedFeatures.includes(x));
let nsFeatures = theme.features.filter(
(x) => !selectedFeatures.includes(x)
);
if (sFeatures.length > 0 && nsFeatures.length > 0) {
featuresTD.innerHTML = `<span style="color: green">${sFeatures}</span>,${nsFeatures}`;
} else {
featuresTD.innerHTML = `<span style="color: green">${sFeatures}</span>${nsFeatures}`;
}
// featuresTD.innerHTML = theme.features;
featuresTD.style.minWidth = `${fL / 7}rem`;
resultsTableRow.appendChild(featuresTD);
}