fix(board-v2): icon and tiny text fix (#6704)
This commit is contained in:
1 parent
6548da3772
commit
40e34181e7
48 files changed
+368
-172
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
import { IconDroplets, IconMapPin, IconSunHigh, IconSunrise, IconSunset, IconWind } from "@tabler/icons-react";
|
||||
|
||||
import { useCurrentIntlLocale, useI18n } from "@homarr/translation/client";
|
||||
import { iconSizes, zoomCompensatedSize } from "@homarr/ui";
|
||||
|
||||
import type { WidgetProps } from "../definition";
|
||||
import { AnimatedWeatherIcon } from "./animated-icon";
|
||||
@@ -206,7 +207,7 @@ export const AdvancedWeather = ({ height, options, weather, width }: AdvancedWea
|
||||
|
||||
<SimpleGrid cols={layout.metricColumns} spacing="xs">
|
||||
<MetricCard
|
||||
icon={<IconDroplets size={18} aria-hidden />}
|
||||
icon={<IconDroplets style={iconSizes.lg} aria-hidden />}
|
||||
label={t("advanced.nextHourPrecipitation")}
|
||||
value={t("advanced.precipitationValue", {
|
||||
amount: nextHour?.precipitation?.toFixed(1) ?? "?",
|
||||
@@ -215,13 +216,13 @@ export const AdvancedWeather = ({ height, options, weather, width }: AdvancedWea
|
||||
/>
|
||||
{options.showHumidity && (
|
||||
<MetricCard
|
||||
icon={<IconDroplets size={18} aria-hidden />}
|
||||
icon={<IconDroplets style={iconSizes.lg} aria-hidden />}
|
||||
label={t("advanced.currentHumidity")}
|
||||
value={`${weather.current.relativeHumidity}%`}
|
||||
/>
|
||||
)}
|
||||
<MetricCard
|
||||
icon={<IconWind size={18} aria-hidden />}
|
||||
icon={<IconWind style={iconSizes.lg} aria-hidden />}
|
||||
label={t("advanced.currentWind")}
|
||||
value={t("advanced.windValue", {
|
||||
gusts: getPreferredWindSpeed(weather.current.windGusts, options.useImperialSpeed),
|
||||
@@ -230,17 +231,17 @@ export const AdvancedWeather = ({ height, options, weather, width }: AdvancedWea
|
||||
})}
|
||||
/>
|
||||
<MetricCard
|
||||
icon={<IconSunHigh size={18} aria-hidden />}
|
||||
icon={<IconSunHigh style={iconSizes.lg} aria-hidden />}
|
||||
label={t("advanced.todayUv")}
|
||||
value={today?.uvIndex?.toFixed(1) ?? "?"}
|
||||
/>
|
||||
<MetricCard
|
||||
icon={<IconSunrise size={18} aria-hidden />}
|
||||
icon={<IconSunrise style={iconSizes.lg} aria-hidden />}
|
||||
label={t("dailyForecast.sunrise")}
|
||||
value={getPreferredTime(today?.sunriseAt, locale, weather.timezone)}
|
||||
/>
|
||||
<MetricCard
|
||||
icon={<IconSunset size={18} aria-hidden />}
|
||||
icon={<IconSunset style={iconSizes.lg} aria-hidden />}
|
||||
label={t("dailyForecast.sunset")}
|
||||
value={getPreferredTime(today?.sunsetAt, locale, weather.timezone)}
|
||||
/>
|
||||
@@ -322,7 +323,11 @@ export const AdvancedWeather = ({ height, options, weather, width }: AdvancedWea
|
||||
{getPreferredDate(day.date, locale, { month: "short", day: "numeric" })}
|
||||
</Text>
|
||||
</Stack>
|
||||
<AnimatedWeatherIcon animated={options.animateIcons} code={day.weatherCode} size={28} />
|
||||
<AnimatedWeatherIcon
|
||||
animated={options.animateIcons}
|
||||
code={day.weatherCode}
|
||||
style={zoomCompensatedSize(28)}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
<Text size="sm" fw={500} lineClamp={1}>
|
||||
@@ -348,13 +353,13 @@ export const AdvancedWeather = ({ height, options, weather, width }: AdvancedWea
|
||||
|
||||
<Group className={classes.dailyCardFacts} justify="space-between" gap={4} wrap="nowrap">
|
||||
<Group gap={3} wrap="nowrap">
|
||||
<IconDroplets size={14} aria-hidden />
|
||||
<IconDroplets style={iconSizes.sm} aria-hidden />
|
||||
<Text className={classes.dailyCardFact} fz={11}>
|
||||
{day.precipitationProbability ?? "?"}%
|
||||
</Text>
|
||||
</Group>
|
||||
<Group gap={3} wrap="nowrap">
|
||||
<IconWind size={14} aria-hidden />
|
||||
<IconWind style={iconSizes.sm} aria-hidden />
|
||||
<Text className={classes.dailyCardFact} fz={11}>
|
||||
{getPreferredWindSpeed(day.maxWindSpeed, options.useImperialSpeed)} {speedUnit}
|
||||
</Text>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
import "../widgets-common.css";
|
||||
|
||||
import { WeatherIcon } from "./icon";
|
||||
@@ -7,6 +9,7 @@ interface AnimatedWeatherIconProps {
|
||||
code: number;
|
||||
isDay?: boolean;
|
||||
size?: string | number;
|
||||
style?: CSSProperties;
|
||||
}
|
||||
|
||||
const getAnimationClass = (code: number): string => {
|
||||
@@ -19,12 +22,12 @@ const getAnimationClass = (code: number): string => {
|
||||
return "";
|
||||
};
|
||||
|
||||
export const AnimatedWeatherIcon = ({ animated = false, code, isDay, size = 26 }: AnimatedWeatherIconProps) => {
|
||||
export const AnimatedWeatherIcon = ({ animated = false, code, isDay, size = 26, style }: AnimatedWeatherIconProps) => {
|
||||
let animationClass = "";
|
||||
if (animated && (code !== 0 || isDay !== false)) animationClass = getAnimationClass(code);
|
||||
return (
|
||||
<span className={`weather-anim-wrapper ${animationClass}`}>
|
||||
<WeatherIcon code={code} isDay={isDay} size={size} />
|
||||
<WeatherIcon code={code} isDay={isDay} size={size} style={style} />
|
||||
</span>
|
||||
);
|
||||
};
|
||||
@@ -3,6 +3,7 @@ import { Group, Popover, Stack, Text, UnstyledButton } from "@mantine/core";
|
||||
import { IconArrowDownRight, IconArrowUpRight, IconDroplets, IconMapPin, IconWind } from "@tabler/icons-react";
|
||||
|
||||
import { useCurrentIntlLocale, useI18n } from "@homarr/translation/client";
|
||||
import { zoomCompensatedSize } from "@homarr/ui";
|
||||
|
||||
import type { WidgetProps } from "../definition";
|
||||
import { AnimatedWeatherIcon } from "./animated-icon";
|
||||
@@ -55,7 +56,7 @@ export const CompactWeather = ({ height, isEditMode, options, weather, width }:
|
||||
animated={options.animateIcons}
|
||||
code={weather.current.weatherCode}
|
||||
isDay={weather.current.isDay}
|
||||
size={layout.tier === "micro" ? 18 : 32}
|
||||
style={zoomCompensatedSize(layout.tier === "micro" ? 18 : 32)}
|
||||
/>
|
||||
</UnstyledButton>
|
||||
</Popover.Target>
|
||||
@@ -132,7 +133,11 @@ export const CompactWeather = ({ height, isEditMode, options, weather, width }:
|
||||
<Text component="span" size="sm" fw={600} tt="capitalize">
|
||||
{getPreferredDate(day.date, locale, { weekday: "short" })}
|
||||
</Text>
|
||||
<AnimatedWeatherIcon animated={options.animateIcons} code={day.weatherCode} size={18} />
|
||||
<AnimatedWeatherIcon
|
||||
animated={options.animateIcons}
|
||||
code={day.weatherCode}
|
||||
style={zoomCompensatedSize(18)}
|
||||
/>
|
||||
<Text component="span" size="sm">
|
||||
{getPreferredUnit(
|
||||
day.maxTemperature,
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
} from "@tabler/icons-react";
|
||||
|
||||
import { useCurrentIntlLocale, useI18n } from "@homarr/translation/client";
|
||||
import { iconSizes, zoomCompensatedSize } from "@homarr/ui";
|
||||
|
||||
import type { WidgetProps } from "../definition";
|
||||
import { AnimatedWeatherIcon } from "./animated-icon";
|
||||
@@ -88,7 +89,7 @@ export const DailyWeatherDetails = ({
|
||||
<Group justify="space-between" align="center" gap="md" wrap="nowrap">
|
||||
<Group gap="sm" wrap="nowrap" miw={0}>
|
||||
<ThemeIcon variant="light" size={46} radius="xl">
|
||||
<AnimatedWeatherIcon animated={animateIcons} code={day.weatherCode} size={28} />
|
||||
<AnimatedWeatherIcon animated={animateIcons} code={day.weatherCode} style={zoomCompensatedSize(28)} />
|
||||
</ThemeIcon>
|
||||
<Stack gap={0} miw={0}>
|
||||
<Text fw={700} truncate>
|
||||
@@ -109,29 +110,29 @@ export const DailyWeatherDetails = ({
|
||||
|
||||
<SimpleGrid cols={2} spacing={6}>
|
||||
<DetailMetric
|
||||
icon={<IconTemperature size={16} aria-hidden />}
|
||||
icon={<IconTemperature style={iconSizes.md} aria-hidden />}
|
||||
label={t("advanced.detailLabel.feelsLike")}
|
||||
value={`${getPreferredUnit(day.maxApparentTemperature, isFahrenheit, disableTemperatureDecimals)} / ${getPreferredUnit(day.minApparentTemperature, isFahrenheit, disableTemperatureDecimals)}`}
|
||||
/>
|
||||
<DetailMetric
|
||||
icon={<IconDroplets size={16} aria-hidden />}
|
||||
icon={<IconDroplets style={iconSizes.md} aria-hidden />}
|
||||
label={t("advanced.detailLabel.precipitation")}
|
||||
value={`${day.precipitationProbability ?? "?"}% · ${day.precipitation?.toFixed(1) ?? "?"} mm`}
|
||||
/>
|
||||
{showHumidity && (
|
||||
<DetailMetric
|
||||
icon={<IconGauge size={16} aria-hidden />}
|
||||
icon={<IconGauge style={iconSizes.md} aria-hidden />}
|
||||
label={t("advanced.detailLabel.humidity")}
|
||||
value={`${day.averageHumidity ?? "?"}%`}
|
||||
/>
|
||||
)}
|
||||
<DetailMetric
|
||||
icon={<IconWind size={16} aria-hidden />}
|
||||
icon={<IconWind style={iconSizes.md} aria-hidden />}
|
||||
label={t("advanced.detailLabel.wind")}
|
||||
value={`${getPreferredWindSpeed(day.maxWindSpeed, useImperialSpeed)} / ${getPreferredWindSpeed(day.maxWindGusts, useImperialSpeed)} ${speedUnit}`}
|
||||
/>
|
||||
<DetailMetric
|
||||
icon={<IconSunHigh size={16} aria-hidden />}
|
||||
icon={<IconSunHigh style={iconSizes.md} aria-hidden />}
|
||||
label={t("advanced.detailLabel.uv")}
|
||||
value={day.uvIndex?.toFixed(1) ?? "?"}
|
||||
/>
|
||||
@@ -140,17 +141,17 @@ export const DailyWeatherDetails = ({
|
||||
<Paper className={classes.solarDetails} p="xs" radius="md">
|
||||
<SimpleGrid cols={3} spacing="xs">
|
||||
<SolarMetric
|
||||
icon={<IconSunrise size={17} aria-hidden />}
|
||||
icon={<IconSunrise style={iconSizes.md} aria-hidden />}
|
||||
label={t("dailyForecast.sunrise")}
|
||||
value={getPreferredTime(day.sunriseAt, locale, timeZone)}
|
||||
/>
|
||||
<SolarMetric
|
||||
icon={<IconSunset size={17} aria-hidden />}
|
||||
icon={<IconSunset style={iconSizes.md} aria-hidden />}
|
||||
label={t("dailyForecast.sunset")}
|
||||
value={getPreferredTime(day.sunsetAt, locale, timeZone)}
|
||||
/>
|
||||
<SolarMetric
|
||||
icon={<IconSunHigh size={17} aria-hidden />}
|
||||
icon={<IconSunHigh style={iconSizes.md} aria-hidden />}
|
||||
label={t("advanced.detailLabel.daylight")}
|
||||
value={getPreferredDaylightDuration(day.daylightDuration)}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { CSSProperties } from "react";
|
||||
import { List, Stack, Text } from "@mantine/core";
|
||||
import {
|
||||
IconCloud,
|
||||
@@ -25,19 +26,23 @@ interface WeatherIconProps {
|
||||
code: number;
|
||||
isDay?: boolean;
|
||||
size?: string | number;
|
||||
style?: CSSProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon which should be displayed when specific code is defined
|
||||
* @param code weather code from api
|
||||
* @param size size of the icon, accepts relative sizes too
|
||||
* @param style CSS overrides (e.g. from `zoomCompensatedSize`) - prefer this over `size` for a
|
||||
* board-zoom-safe size, since `size` becomes a raw SVG width/height attribute that `var()` isn't
|
||||
* guaranteed to resolve inside (see `iconSizes` in @homarr/ui).
|
||||
* @returns Icon corresponding to the weather code
|
||||
*/
|
||||
export const WeatherIcon = ({ code, isDay = true, size = 50 }: WeatherIconProps) => {
|
||||
if (code === 0 && !isDay) return <IconMoon style={{ float: "left" }} size={size} />;
|
||||
export const WeatherIcon = ({ code, isDay = true, size = 50, style }: WeatherIconProps) => {
|
||||
if (code === 0 && !isDay) return <IconMoon style={{ float: "left", ...style }} size={size} />;
|
||||
const { icon: Icon } = weatherDefinitions.find((definition) => definition.codes.includes(code)) ?? unknownWeather;
|
||||
|
||||
return <Icon style={{ float: "left" }} size={size} />;
|
||||
return <Icon style={{ float: "left", ...style }} size={size} />;
|
||||
};
|
||||
|
||||
export const getWeatherKind = (code: number) =>
|
||||
|
||||
Reference in new issue
Block a user