-
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.
Add SSR to weather block - ready to launch
- Loading branch information
1 parent
a3b0c90
commit 0c4265f
Showing
10 changed files
with
866 additions
and
197 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,63 +1,21 @@ | ||
import { useBlockProps, InspectorControls } from "@wordpress/block-editor"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import ServerSideRender from "@wordpress/server-side-render"; | ||
import { PanelBody } from "@wordpress/components"; | ||
import { useWeatherData } from "./utils"; | ||
import { Waves, Wind } from "./icons"; | ||
import "./editor.scss"; | ||
import React from "react"; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
function TheEdit({ attributes, setAttributes }) { | ||
export default function Edit({ attributes, setAttributes }) { | ||
const blockProps = useBlockProps(); | ||
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 /> | ||
{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 water"> | ||
<Waves /> | ||
{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> | ||
<ServerSideRender block="spearfishing-stuff/weather" /> | ||
</div> | ||
<InspectorControls> | ||
<PanelBody title='Block Settings' initialOpen={true}></PanelBody> | ||
<PanelBody title="Block Settings" initialOpen={true}></PanelBody> | ||
{/* Add settings in the future here */} | ||
</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 was deleted.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.