homepage/src/components/widget.jsx

31 lines
939 B
React
Raw Normal View History

import WeatherApi from "components/widgets/weather/weather";
2022-08-27 13:30:17 +03:00
import OpenWeatherMap from "components/widgets/openweathermap/weather";
2022-08-24 10:44:35 +03:00
import Resources from "components/widgets/resources/resources";
import Search from "components/widgets/search/search";
2022-09-16 10:53:12 +03:00
import Greeting from "components/widgets/greeting/greeting";
import DateTime from "components/widgets/datetime/datetime";
2022-08-24 10:44:35 +03:00
const widgetMappings = {
weather: WeatherApi, // This key will be deprecated in the future
weatherapi: WeatherApi,
2022-08-27 13:30:17 +03:00
openweathermap: OpenWeatherMap,
2022-08-24 10:44:35 +03:00
resources: Resources,
search: Search,
2022-09-16 10:53:12 +03:00
greeting: Greeting,
datetime: DateTime,
2022-08-24 10:44:35 +03:00
};
export default function Widget({ widget }) {
2022-09-16 10:53:12 +03:00
const InfoWidget = widgetMappings[widget.type];
2022-08-24 10:44:35 +03:00
2022-09-16 10:53:12 +03:00
if (InfoWidget) {
return <InfoWidget options={widget.options} />;
2022-08-24 10:44:35 +03:00
}
return (
<div className="flex-none flex flex-row items-center justify-center">
Missing <strong>{widget.type}</strong>
</div>
);
}