From 1622069063691bebefb37202d3383ddfe81b67fb Mon Sep 17 00:00:00 2001 From: Denis Papec Date: Mon, 12 Jun 2023 00:23:01 +0100 Subject: [PATCH] Fixes for existing header styles, fix for glances Signed-off-by: Denis Papec --- src/components/widgets/glances/glances.jsx | 2 ++ .../widgets/openweathermap/weather.jsx | 3 +-- src/components/widgets/widget/container.jsx | 22 ++++++++++++++----- src/components/widgets/widget/resource.jsx | 4 ++-- src/components/widgets/widget/resources.jsx | 6 +++-- .../widgets/widget/widget_label.jsx | 2 +- src/pages/index.jsx | 11 ++++++---- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/components/widgets/glances/glances.jsx b/src/components/widgets/glances/glances.jsx index b45dfefe..e5cf3fbd 100644 --- a/src/components/widgets/glances/glances.jsx +++ b/src/components/widgets/glances/glances.jsx @@ -36,6 +36,8 @@ export default function Widget({ options }) { { options.cputemp && } + { options.disk && !Array.isArray(options.disk) && } + { options.disk && Array.isArray(options.disk) && options.disk.map((disk) => )} { options.uptime && } { options.label && } ; diff --git a/src/components/widgets/openweathermap/weather.jsx b/src/components/widgets/openweathermap/weather.jsx index 30531513..a857f13a 100644 --- a/src/components/widgets/openweathermap/weather.jsx +++ b/src/components/widgets/openweathermap/weather.jsx @@ -41,8 +41,7 @@ function Widget({ options }) { }; return - {options.label && `${options.label}, `} - {t("common.number", { value: data.main.temp, style: "unit", unit })} + {options.label && `${options.label}, ` }{t("common.number", { value: data.main.temp, style: "unit", unit })} {data.weather[0].description} ; diff --git a/src/components/widgets/widget/container.jsx b/src/components/widgets/widget/container.jsx index 3a4a9f57..59ea5684 100644 --- a/src/components/widgets/widget/container.jsx +++ b/src/components/widgets/widget/container.jsx @@ -6,10 +6,22 @@ import SecondaryText from "./secondary_text"; import Raw from "./raw"; export function getAllClasses(options, additionalClassNames = '') { + if (options?.style?.header === "boxedWidgets") { + return classNames( + "flex flex-col justify-center first:ml-0 ml-2 mr-2", + "mt-2 m:mb-0 rounded-md shadow-md shadow-theme-900/10 dark:shadow-theme-900/20 bg-theme-100/20 dark:bg-white/5 p-2 pl-3 pr-3", + additionalClassNames + ); + } + + let widgetAlignedClasses = "flex flex-col max-w:full sm:basis-auto self-center grow-0 flex-wrap"; + if (options?.style?.isRightAligned) { + widgetAlignedClasses = "flex flex-col justify-center first:ml-auto ml-2 mr-2 "; + } + return classNames( - "flex flex-col justify-center first:ml-0 ml-4 mr-2", - additionalClassNames, - options?.style === "boxedWidgets" && " ml-4 mt-2 m:mb-0 rounded-md shadow-md shadow-theme-900/10 dark:shadow-theme-900/20 bg-theme-100/20 dark:bg-white/5 p-2 pl-3", + widgetAlignedClasses, + additionalClassNames ); } @@ -18,8 +30,8 @@ export function getInnerBlock(children) { return Array.isArray(children) &&
{children.find(child => child.type === WidgetIcon)}
- {children.find(child => child.type === PrimaryText)} - {children.find(child => child.type === SecondaryText)} + {children.find(child => child.type === PrimaryText)} + {children.find(child => child.type === SecondaryText)}
; } diff --git a/src/components/widgets/widget/resource.jsx b/src/components/widgets/widget/resource.jsx index e77bcb5a..18e7c800 100644 --- a/src/components/widgets/widget/resource.jsx +++ b/src/components/widgets/widget/resource.jsx @@ -1,9 +1,9 @@ import UsageBar from "../resources/usage-bar"; -export default function Resource({ children, icon, value, label, expandedValue, expandedLabel, percentage, key, expanded = false }) { +export default function Resource({ children, icon, value, label, expandedValue = "", expandedLabel = "", percentage, expanded = false }) { const Icon = icon; - return
+ return
diff --git a/src/components/widgets/widget/resources.jsx b/src/components/widgets/widget/resources.jsx index 19fb021d..394a3058 100644 --- a/src/components/widgets/widget/resources.jsx +++ b/src/components/widgets/widget/resources.jsx @@ -4,12 +4,14 @@ import Raw from "./raw"; import WidgetLabel from "./widget_label"; export default function Resources({ options, children, target }) { + const widgetParts = [].concat(...children); + return
- { children.filter(child => child && child.type === Resource) } + { widgetParts.filter(child => child && child.type === Resource) }
- { children.filter(child => child && child.type === WidgetLabel) } + { widgetParts.filter(child => child && child.type === WidgetLabel) }
; } diff --git a/src/components/widgets/widget/widget_label.jsx b/src/components/widgets/widget/widget_label.jsx index dcb9b9e9..5fc6ced0 100644 --- a/src/components/widgets/widget/widget_label.jsx +++ b/src/components/widgets/widget/widget_label.jsx @@ -1,3 +1,3 @@ export default function WidgetLabel({ label = "" }) { - return
{label}
+ return
{label}
} diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 7611aed5..d91a8339 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -274,14 +274,17 @@ function Home({ initialSettings }) { {widgets .filter((widget) => !rightAlignedWidgets.includes(widget.type)) .map((widget, i) => ( - + ))} -
+
{widgets .filter((widget) => rightAlignedWidgets.includes(widget.type)) .map((widget, i) => ( - + ))}
@@ -361,7 +364,7 @@ export default function Wrapper({ initialSettings, fallback }) { style={wrappedStyle} >