Add skeleton while the meto module is loading

This commit is contained in:
Thomas Camlong
2022-07-07 07:13:11 +00:00
committed by GitHub
parent 2702c9a7cf
commit 0406d6d5ee

View File

@@ -1,4 +1,4 @@
import { Group, Space, Title, Tooltip } from '@mantine/core';
import { Group, Space, Title, Tooltip, Skeleton } from '@mantine/core';
import axios from 'axios';
import { useEffect, useState } from 'react';
import {
@@ -157,7 +157,18 @@ export default function WeatherComponent(props: any) {
});
}, [cityInput]);
if (!weather.current_weather) {
return null;
return (
<>
<Skeleton height={40} width={100} mb="xl" />
<Group noWrap direction="row">
<Skeleton height={50} circle />
<Group>
<Skeleton height={25} width={70} mr="lg" />
<Skeleton height={25} width={70} />
</Group>
</Group>
</>
);
}
function usePerferedUnit(value: number): string {
return isFahrenheit ? `${(value * (9 / 5) + 32).toFixed(1)}°F` : `${value.toFixed(1)}°C`;