import { Center, Group, Skeleton, Stack, Text, Title } from '@mantine/core';
import { useElementSize } from '@mantine/hooks';
import { IconArrowDownRight, IconArrowUpRight, IconCloudRain } from '@tabler/icons-react';
import { defineWidget } from '../helper';
import { IWidget } from '../widgets';
import { useWeatherForCity } from './useWeatherForCity';
import { WeatherIcon } from './WeatherIcon';
const definition = defineWidget({
id: 'weather',
icon: IconCloudRain,
options: {
displayInFahrenheit: {
type: 'switch',
defaultValue: false,
},
location: {
type: 'text',
defaultValue: 'Paris',
},
},
gridstack: {
minWidth: 1,
minHeight: 1,
maxWidth: 12,
maxHeight: 12,
},
component: WeatherTile,
});
export type IWeatherWidget = IWidget<(typeof definition)['id'], typeof definition>;
interface WeatherTileProps {
widget: IWeatherWidget;
}
function WeatherTile({ widget }: WeatherTileProps) {
const { data: weather, isLoading, isError } = useWeatherForCity(widget.properties.location);
const { width, height, ref } = useElementSize();
if (isLoading) {
return (