diff --git a/public/locales/en/modules/weather.json b/public/locales/en/modules/weather.json
index 791f80897..16b034320 100644
--- a/public/locales/en/modules/weather.json
+++ b/public/locales/en/modules/weather.json
@@ -7,6 +7,9 @@
"displayInFahrenheit": {
"label": "Display in Fahrenheit"
},
+ "displayCityName":{
+ "label":"Display City Name"
+ },
"location": {
"label": "Weather location"
}
diff --git a/src/widgets/weather/WeatherIcon.tsx b/src/widgets/weather/WeatherIcon.tsx
index a32d9ffef..f74175867 100644
--- a/src/widgets/weather/WeatherIcon.tsx
+++ b/src/widgets/weather/WeatherIcon.tsx
@@ -11,9 +11,11 @@ import {
IconSun,
} from '@tabler/icons-react';
import { useTranslation } from 'next-i18next';
+import { useElementSize } from '@mantine/hooks';
interface WeatherIconProps {
code: number;
+ size?: number;
}
/**
@@ -21,16 +23,17 @@ interface WeatherIconProps {
* @param code weather code from api
* @returns weather tile component
*/
-export const WeatherIcon = ({ code }: WeatherIconProps) => {
+export const WeatherIcon = ({ code, size=50 }: WeatherIconProps) => {
const { t } = useTranslation('modules/weather');
-
+ const { width, ref } = useElementSize();
+
const { icon: Icon, name } =
weatherDefinitions.find((wd) => wd.codes.includes(code)) ?? unknownWeather;
return (
-
+
);
diff --git a/src/widgets/weather/WeatherTile.tsx b/src/widgets/weather/WeatherTile.tsx
index 9d257d819..a4443d7cd 100644
--- a/src/widgets/weather/WeatherTile.tsx
+++ b/src/widgets/weather/WeatherTile.tsx
@@ -1,6 +1,12 @@
-import { Center, Group, Skeleton, Stack, Text, Title } from '@mantine/core';
+import { Center, Flex, Group, Skeleton, Stack, Text, Title } from '@mantine/core';
import { useElementSize } from '@mantine/hooks';
-import { IconArrowDownRight, IconArrowUpRight, IconCloudRain } from '@tabler/icons-react';
+import {
+ IconArrowDownRight,
+ IconArrowUpRight,
+ IconCloudRain,
+ IconCurrentLocation,
+ IconMapPin,
+} from '@tabler/icons-react';
import { api } from '~/utils/api';
import { defineWidget } from '../helper';
@@ -15,6 +21,10 @@ const definition = defineWidget({
type: 'switch',
defaultValue: false,
},
+ displayCityName: {
+ type: 'switch',
+ defaultValue: false,
+ },
location: {
type: 'location',
defaultValue: {
@@ -75,21 +85,27 @@ function WeatherTile({ widget }: WeatherTileProps) {
// TODO: add widgetWrapper that is generic and uses the definition
return (
-
-
-
+
+
+
{getPerferedUnit(
weather.current_weather.temperature,
widget.properties.displayInFahrenheit
)}
-
+
+
{width > 200 && (
@@ -104,6 +120,13 @@ function WeatherTile({ widget }: WeatherTileProps) {
)}
)}
+
+ {widget.properties.displayCityName && (
+
+
+ {widget.properties.location.name}
+
+ )}
);
}