-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86eedcb
commit a3b0c90
Showing
6 changed files
with
143 additions
and
94 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,63 @@ | ||
import { useBlockProps, InspectorControls } from "@wordpress/block-editor"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { PanelBody } from "@wordpress/components"; | ||
|
||
import { useWeatherData } from "./utils"; | ||
import { Waves, Wind, Temperature } from "./icons"; | ||
import { Waves, Wind } from "./icons"; | ||
import "./editor.scss"; | ||
import React, { useEffect } from "react"; | ||
import React from "react"; | ||
|
||
export default function Edit({ attributes, setAttributes }) { | ||
const queryClient = new QueryClient(); | ||
|
||
function TheEdit({ attributes, setAttributes }) { | ||
const blockProps = useBlockProps(); | ||
const { data, isLoading } = useWeatherData(); | ||
const { windData, waveData } = useWeatherData(); | ||
const { data: windDataData, isLoading: windDataIsLoading } = windData; | ||
const { data: waveDataData, isLoading: waveDataIsLoading } = waveData; | ||
|
||
return ( | ||
<> | ||
<div {...blockProps}> | ||
<div className="wp-weather-content"> | ||
<div className="weather-data heading"> | ||
<h2>Current Weather Conditions</h2> | ||
</div> | ||
<div className="weather-data wind"> | ||
<Wind /> | ||
<div className="wind-speed"> | ||
<p>Wind<br />Speed</p> | ||
{isLoading ? ( | ||
<p>Loading...</p> | ||
) : ( | ||
<p>{data.wind.windspeed} m</p> | ||
)} | ||
</div> | ||
{windDataIsLoading ? ( | ||
<h2>Loading...</h2> | ||
) : ( | ||
<div className="data"> | ||
<p>Speed <span className="meters">{windDataData?.windspeed}</span></p> | ||
<p>Temperature <span className="degrees">{windDataData?.temperature}</span></p> | ||
<p>Direction <span className="degrees">{windDataData?.winddir}</span></p> | ||
</div> | ||
)} | ||
</div> | ||
<div className="weather-data waves"> | ||
<div className="weather-data water"> | ||
<Waves /> | ||
<div className="wave-height"> | ||
<p>Wave<br />Height</p> | ||
{isLoading ? ( | ||
<p>Loading...</p> | ||
) : ( | ||
<p>{data.buoy.hm0} m</p> | ||
)} | ||
</div> | ||
</div> | ||
<div className="weather-data temperature"> | ||
<Temperature /> | ||
<div className="water-temperature"> | ||
<p>Water<br />Temperature</p> | ||
{isLoading ? ( | ||
<p>Loading...</p> | ||
) : ( | ||
<p>{data.buoy.watertemp} m</p> | ||
)} | ||
</div> | ||
{waveDataIsLoading ? ( | ||
<h2>Loading...</h2> | ||
) : ( | ||
<div className="data"> | ||
<p>Height <span className="meters">{waveDataData?.hm0}</span></p> | ||
<p>Temperature <span className="degrees">{waveDataData?.watertemp}</span></p> | ||
<p>Direction <span className="degrees">{waveDataData?.meandir}</span></p> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
<InspectorControls> | ||
<PanelBody | ||
title={"Block Settings"} | ||
initialOpen={true} | ||
></PanelBody> | ||
<PanelBody title='Block Settings' initialOpen={true}></PanelBody> | ||
</InspectorControls> | ||
</> | ||
); | ||
} | ||
|
||
export default function Edit({ attributes, setAttributes }) { | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<TheEdit attributes={attributes} setAttributes={setAttributes} /> | ||
</QueryClientProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters