@rileybathurst/paddle 0.0.79 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/PaddleTopBar.tsx +49 -0
- package/src/index.tsx +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Markdown from 'react-markdown';
|
|
3
|
+
|
|
4
|
+
// TODO this would be nice to be able to close but I dont have it right yet
|
|
5
|
+
|
|
6
|
+
type PaddleTopBarTypes = {
|
|
7
|
+
strapiLocale: {
|
|
8
|
+
topbar: {
|
|
9
|
+
data: {
|
|
10
|
+
topbar: string;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
allStrapiWeatherDay: {
|
|
15
|
+
nodes: {
|
|
16
|
+
startDate: string;
|
|
17
|
+
startTime: string;
|
|
18
|
+
endDate: string;
|
|
19
|
+
endTime: string;
|
|
20
|
+
closed: boolean;
|
|
21
|
+
condition: {
|
|
22
|
+
excerpt: string;
|
|
23
|
+
}
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export const PaddleTopBar = ({ strapiLocale, allStrapiWeatherDay }: PaddleTopBarTypes) => {
|
|
28
|
+
|
|
29
|
+
let currentWeather = '';
|
|
30
|
+
let currentStatus = false;
|
|
31
|
+
const currentDate = new Date().toISOString().split('T')[0];
|
|
32
|
+
|
|
33
|
+
allStrapiWeatherDay.nodes.map((date) => {
|
|
34
|
+
if (date.startDate === currentDate || currentDate >= date.startDate && currentDate <= date.endDate) {
|
|
35
|
+
currentWeather = date.condition.excerpt;
|
|
36
|
+
currentStatus = date.closed;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className={`top-bar ${currentStatus ? 'closed' : 'open'}`} >
|
|
42
|
+
{currentWeather ? <p>{currentWeather}</p> :
|
|
43
|
+
<Markdown>
|
|
44
|
+
{strapiLocale.topbar.data.topbar}
|
|
45
|
+
</Markdown>
|
|
46
|
+
}
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
package/src/index.tsx
CHANGED