refactor information widgets

This commit is contained in:
Ben Phelps 2022-08-27 00:55:13 +03:00
parent 1124f55361
commit b61ec9836e
10 changed files with 208 additions and 120 deletions

View file

@ -10,7 +10,7 @@ export default function Weather({ options }) {
if (error) {
return (
<div className="order-last grow flex-none flex flex-row items-center justify-end">
<div className="flex flex-row items-center">
<BiError className="w-8 h-8 text-theme-800 dark:text-theme-200" />
<div className="flex flex-col ml-3 text-left">
<span className="text-theme-800 dark:text-theme-200 text-sm">API</span>
@ -21,22 +21,25 @@ export default function Weather({ options }) {
}
if (!data) {
return <div className="order-last grow flex-none flex flex-row items-center justify-end"></div>;
return <div className="flex flex-row items-center"></div>;
}
if (data.error) {
return <div className="order-last grow flex-none flex flex-row items-center justify-end"></div>;
return <div className="flex flex-row items-center"></div>;
}
return (
<div className="order-last grow flex-none flex flex-row items-center justify-end">
<Icon condition={data.current.condition.code} timeOfDay={data.current.is_day ? "day" : "night"} />
<div className="flex flex-col ml-3 text-left">
<span className="text-theme-800 dark:text-theme-200 text-sm">
{options.units === "metric" ? data.current.temp_c : data.current.temp_f}&deg;
</span>
<span className="text-theme-800 dark:text-theme-200 text-xs">{data.current.condition.text}</span>
<div className=" flex flex-col">
<div className="flex flex-row items-center justify-end">
<Icon condition={data.current.condition.code} timeOfDay={data.current.is_day ? "day" : "night"} />
<div className="flex flex-col ml-3 text-left">
<span className="text-theme-800 dark:text-theme-200 text-sm">
{options.units === "metric" ? data.current.temp_c : data.current.temp_f}&deg;
</span>
<span className="text-theme-800 dark:text-theme-200 text-xs">{data.current.condition.text}</span>
</div>
</div>
{options.label && <div className="text-right text-theme-800 dark:text-theme-200 text-xs">{options.label}</div>}
</div>
);
}