mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 09:35:54 -08:00
Enhancement: add valueOnly option to block highlighting feature (#6051)
This commit is contained in:
@@ -32,6 +32,8 @@ export default function Block({ value, label, field }) {
|
||||
return getHighlightClass(highlight.level, highlightConfig);
|
||||
}, [highlight, highlightConfig]);
|
||||
|
||||
const applyToValueOnly = highlight?.valueOnly === true;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
@@ -44,7 +46,11 @@ export default function Block({ value, label, field }) {
|
||||
data-highlight-source={highlight?.source}
|
||||
>
|
||||
<div className="font-thin text-sm">{value === undefined || value === null ? "-" : value}</div>
|
||||
<div className="font-bold text-xs uppercase">{t(label)}</div>
|
||||
<div
|
||||
className={classNames("font-bold text-xs uppercase", applyToValueOnly && "text-theme-700 dark:text-theme-200")}
|
||||
>
|
||||
{t(label)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ const ensureArray = (value) => {
|
||||
};
|
||||
|
||||
const findHighlightLevel = (ruleSet, numericValue, stringValue) => {
|
||||
const { numeric, string } = ruleSet;
|
||||
const { numeric, string, valueOnly } = ruleSet;
|
||||
|
||||
if (numeric && numericValue !== undefined) {
|
||||
const numericRules = ensureArray(numeric);
|
||||
@@ -208,7 +208,7 @@ const findHighlightLevel = (ruleSet, numericValue, stringValue) => {
|
||||
for (const candidate of numericCandidates) {
|
||||
for (const rule of numericRules) {
|
||||
if (rule?.level && evaluateNumericRule(candidate, rule)) {
|
||||
return { level: rule.level, source: "numeric", rule };
|
||||
return { level: rule.level, source: "numeric", rule, valueOnly };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ const findHighlightLevel = (ruleSet, numericValue, stringValue) => {
|
||||
const stringRules = ensureArray(string);
|
||||
for (const rule of stringRules) {
|
||||
if (rule?.level && evaluateStringRule(stringValue, rule)) {
|
||||
return { level: rule.level, source: "string", rule };
|
||||
return { level: rule.level, source: "string", rule, valueOnly };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user