@vonaffenfels/contentful-teasermanager 1.0.26 → 1.0.27
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonaffenfels/contentful-teasermanager",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepublish": "yarn run build",
|
|
6
6
|
"dev": "yarn run start",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@vonaffenfels/slate-editor": "^1.0.26",
|
|
100
100
|
"webpack": "5.73.0"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "148d5745884b9e253e56a2389662fc4f7ecf4254",
|
|
103
103
|
"publishConfig": {
|
|
104
104
|
"access": "public"
|
|
105
105
|
}
|
|
@@ -36,16 +36,21 @@ export const Timeline = ({
|
|
|
36
36
|
setCurrentDate(newDate);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
const handleTimeChange = e => {
|
|
39
|
+
const handleTimeChange = (e, type) => {
|
|
40
40
|
if (!e.target.value) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
let newDate = new Date(currentDate);
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
switch (type) {
|
|
47
|
+
case "hour":
|
|
48
|
+
newDate.setHours(e.target.value);
|
|
49
|
+
break;
|
|
50
|
+
case "minute":
|
|
51
|
+
newDate.setMinutes(e.target.value);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
49
54
|
|
|
50
55
|
setCurrentDate(newDate);
|
|
51
56
|
};
|
|
@@ -56,7 +61,7 @@ export const Timeline = ({
|
|
|
56
61
|
{!!currentDate && (
|
|
57
62
|
<>
|
|
58
63
|
<input type="date" value={format(currentDate, "yyyy-MM-dd")} onChange={handleDateChange} className="mr-2 w-auto" />
|
|
59
|
-
<
|
|
64
|
+
<TimeSelect className="inline w-auto" currentDate={currentDate} onChange={handleTimeChange} />
|
|
60
65
|
</>
|
|
61
66
|
)}
|
|
62
67
|
</div>
|
|
@@ -80,4 +85,44 @@ export const Timeline = ({
|
|
|
80
85
|
</div>
|
|
81
86
|
</div>
|
|
82
87
|
</div>;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const TimeSelect = ({
|
|
91
|
+
onChange,
|
|
92
|
+
currentDate,
|
|
93
|
+
...props
|
|
94
|
+
}) => {
|
|
95
|
+
const renderHourSelectOptions = () => {
|
|
96
|
+
let options = [];
|
|
97
|
+
|
|
98
|
+
for (let i = 1; i <= 24; i++) {
|
|
99
|
+
console.log(i);
|
|
100
|
+
options.push(<option value={i} style={{padding: "8px"}}>{i < 10 ? `0${i}` : i}</option>);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return options;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const renderMinuteSelectOptions = () => {
|
|
107
|
+
let options = [];
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i <= 60; i += 15) {
|
|
110
|
+
console.log(i);
|
|
111
|
+
options.push(<option value={i} style={{padding: "8px"}}>{i < 10 ? `0${i}` : i}</option>);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return options;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div {...props}>
|
|
119
|
+
<select value={format(currentDate, "H")} onChange={e => onChange(e, "hour")} className="w-auto">
|
|
120
|
+
{renderHourSelectOptions()}
|
|
121
|
+
</select>
|
|
122
|
+
<select value={format(currentDate, "m")} onChange={e => onChange(e, "minute")} className="mr-1 w-auto">
|
|
123
|
+
{renderMinuteSelectOptions()}
|
|
124
|
+
</select>
|
|
125
|
+
Uhr
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
83
128
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useRef, useState,
|
|
3
|
+
} from "react";
|
|
2
4
|
|
|
3
5
|
import {getContentfulClient} from "../lib/contentfulClient";
|
|
4
6
|
import Renderer from "@vonaffenfels/slate-editor/dist/Renderer";
|
|
5
7
|
import componentLoader from "@vonaffenfels/slate-editor/componentLoader";
|
|
6
8
|
import {Timeline} from "./Teasermanager/Timeline";
|
|
7
9
|
import styles from "./Teasermanager.module.css";
|
|
8
|
-
import {runLoaders} from "../lib/runLoaders"
|
|
10
|
+
import {runLoaders} from "../lib/runLoaders";
|
|
9
11
|
|
|
10
12
|
export const Teasermanager = ({
|
|
11
13
|
entryId,
|
|
@@ -43,12 +45,12 @@ export const Teasermanager = ({
|
|
|
43
45
|
});
|
|
44
46
|
|
|
45
47
|
node.appendChild(managementNode);
|
|
46
|
-
}
|
|
48
|
+
};
|
|
47
49
|
|
|
48
50
|
const updateSlots = (mutationList) => {
|
|
49
51
|
const slots = wrapperRef.current.querySelectorAll(`*[data-teasermanager-slot]`);
|
|
50
52
|
slots.forEach(initSlot);
|
|
51
|
-
}
|
|
53
|
+
};
|
|
52
54
|
|
|
53
55
|
useEffect(() => {
|
|
54
56
|
if (!entryId && entry) {
|
|
@@ -67,11 +69,15 @@ export const Teasermanager = ({
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
const observer = new MutationObserver(updateSlots);
|
|
70
|
-
observer.observe(wrapperRef.current, {
|
|
72
|
+
observer.observe(wrapperRef.current, {
|
|
73
|
+
attributes: false,
|
|
74
|
+
childList: true,
|
|
75
|
+
subtree: true,
|
|
76
|
+
});
|
|
71
77
|
|
|
72
78
|
return () => {
|
|
73
79
|
observer.disconnect();
|
|
74
|
-
}
|
|
80
|
+
};
|
|
75
81
|
}, [wrapperRef, currentDate]);
|
|
76
82
|
|
|
77
83
|
useEffect(() => {
|
|
@@ -90,7 +96,7 @@ export const Teasermanager = ({
|
|
|
90
96
|
});
|
|
91
97
|
}, [contentFieldName, locale, entry, reloadTrigger]);
|
|
92
98
|
|
|
93
|
-
return <div className="w-full flex
|
|
99
|
+
return <div className="flex w-full flex-col">
|
|
94
100
|
<div className="w-full">
|
|
95
101
|
<Timeline currentDate={currentDate} setCurrentDate={setCurrentDate}/>
|
|
96
102
|
</div>
|
|
@@ -103,5 +109,5 @@ export const Teasermanager = ({
|
|
|
103
109
|
/>
|
|
104
110
|
}
|
|
105
111
|
</div>
|
|
106
|
-
</div
|
|
107
|
-
}
|
|
112
|
+
</div>;
|
|
113
|
+
};
|