@vonaffenfels/contentful-teasermanager 1.2.18 → 1.2.22

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.
Files changed (36) hide show
  1. package/.babelrc +19 -19
  2. package/.nvmrc +1 -1
  3. package/dist/TestStory.js +94 -0
  4. package/dist/TestStory2.js +94 -0
  5. package/dist/TestStory3.js +94 -0
  6. package/dist/index.html +11 -11
  7. package/dist/index.js +99285 -44296
  8. package/package.json +3 -3
  9. package/postcss.config.js +6 -6
  10. package/src/components/Contentful/ConfigScreen.js +154 -154
  11. package/src/components/Contentful/Dialog/LogicEditor.js +602 -533
  12. package/src/components/Contentful/Dialog/NewestArticles.js +198 -198
  13. package/src/components/Contentful/Dialog.js +87 -87
  14. package/src/components/Contentful/EntryEditor.js +196 -196
  15. package/src/components/Contentful/Page.js +9 -9
  16. package/src/components/NoAccess.js +12 -12
  17. package/src/components/Teasermanager/Timeline.js +179 -179
  18. package/src/components/Teasermanager/Timeline.module.css +89 -89
  19. package/src/components/Teasermanager.js +269 -269
  20. package/src/components/Teasermanager.module.css +137 -137
  21. package/src/dev.js +5 -5
  22. package/src/hooks/useDebounce.js +20 -20
  23. package/src/hooks/useOnScreen.js +23 -23
  24. package/src/icons/remove.svg +7 -7
  25. package/src/index.html +11 -11
  26. package/src/index.js +51 -51
  27. package/src/lib/contentfulClient.js +12 -12
  28. package/src/lib/runLoaders.js +46 -46
  29. package/src/queryFromLogic.js +33 -33
  30. package/src/scss/index.scss +11 -11
  31. package/tailwind.config.js +5 -5
  32. package/webpack.config.dev.js +25 -25
  33. package/webpack.config.js +174 -174
  34. package/dist/_base_slate-editor_src_dev_testComponents_TestStory2_js.js +0 -94
  35. package/dist/_base_slate-editor_src_dev_testComponents_TestStory3_js.js +0 -94
  36. package/dist/_base_slate-editor_src_dev_testComponents_TestStory_js.js +0 -94
@@ -1,180 +1,180 @@
1
- import {
2
- useEffect, useState,
3
- } from "react";
4
- import styles from "./Timeline.module.css";
5
- import format from "date-fns/format";
6
- import subtract from "date-fns/sub";
7
- import classNames from "classnames";
8
-
9
- export const Timeline = ({
10
- currentDate,
11
- setCurrentDate,
12
- loadTimelineStateForPage,
13
- }) => {
14
- const [timelineState, setTimelineState] = useState(null);
15
- const stepsInRange = (24 * 60) / 15 + 1; // must be uneven so we have a center ;)
16
-
17
- useEffect(() => {
18
- if (!currentDate) {
19
- const defaultCurrentDate = new Date();
20
- defaultCurrentDate.setMinutes((Math.round(defaultCurrentDate.getMinutes() / 15) * 15) % 60);
21
-
22
- setCurrentDate(defaultCurrentDate);
23
- }
24
- }, [currentDate]);
25
-
26
- const leftDate = currentDate && subtract(currentDate, {minutes: stepsInRange / 2 * 15});
27
- if (leftDate) {
28
- leftDate.setMinutes((Math.round(currentDate.getMinutes() / 15) * 15) % 60);
29
- leftDate.setSeconds(0);
30
- leftDate.setMilliseconds(0);
31
- }
32
-
33
- const handleDateChange = (e) => {
34
- if (!e.target.value) {
35
- return;
36
- }
37
-
38
- let newDate = new Date(e.target.value);
39
-
40
- if (format(currentDate, "yyyy-MM-dd") === format(newDate, "yyyy-MM-dd")) {
41
- return; // nothing changed
42
- }
43
-
44
- newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
45
-
46
- setCurrentDate(newDate);
47
- };
48
-
49
- const handleTimeChange = (e, type) => {
50
- if (!e.target.value) {
51
- return;
52
- }
53
-
54
- let newDate = new Date(currentDate);
55
-
56
- switch (type) {
57
- case "hour":
58
- if (newDate.getHours() === e.target.value) {
59
- return; // nothing changed
60
- }
61
-
62
- newDate.setHours(e.target.value);
63
- break;
64
- case "minute":
65
- if (newDate.getMinutes() === e.target.value) {
66
- return; // nothing changed
67
- }
68
-
69
- newDate.setMinutes(e.target.value);
70
- break;
71
- }
72
-
73
- setCurrentDate(newDate);
74
- };
75
-
76
-
77
- useEffect(() => {
78
- if (!currentDate) {
79
- return;
80
- }
81
-
82
- const leftDate = subtract(currentDate, {minutes: stepsInRange / 2 * 15});
83
- leftDate.setMinutes((Math.round(currentDate.getMinutes() / 15) * 15) % 60);
84
- leftDate.setSeconds(0);
85
-
86
- const rightDate = new Date();
87
- rightDate.setTime(leftDate.getTime() + (15 * 60 * 1000 * stepsInRange));
88
-
89
- loadTimelineStateForPage(leftDate, rightDate).then(setTimelineState);
90
- }, [currentDate])
91
-
92
- return <div className="flex w-full">
93
- <div className={styles.wrapper}>
94
- <div className="w-full h-auto text-center py-2">
95
- {!!currentDate && (
96
- <>
97
- <input
98
- type="date"
99
- value={format(currentDate, "yyyy-MM-dd")}
100
- onChange={handleDateChange}
101
- className="mr-2 w-auto"/>
102
- <TimeSelect className="inline w-auto" currentDate={currentDate} onChange={handleTimeChange}/>
103
- </>
104
- )}
105
- </div>
106
- <div className={styles.timeline}>
107
- {!!leftDate && Array(stepsInRange).fill(0).map((_, index) => {
108
- const dotDate = new Date(leftDate.getTime() + (15 * 60 * 1000 * (index + 1)));
109
- const stateChanged = timelineState?.[dotDate.toISOString()] || 0;
110
- const currentDateCopy = new Date(currentDate);
111
- currentDateCopy.setMilliseconds(0);
112
- currentDateCopy.setSeconds(0);
113
-
114
- return <div
115
- key={index}
116
- className={classNames(styles.timelineDot, {
117
- [styles.timelineDotActive]: dotDate.getTime() === currentDateCopy.getTime(),
118
- [styles.timelineDotChanged]: !!stateChanged,
119
- })}
120
- onClick={e => {
121
- e.preventDefault();
122
- setCurrentDate(dotDate);
123
- return false;
124
- }}
125
- >
126
- <div
127
- className={classNames(styles.timelineDotLabel, {[styles.timelineDotLabelPermanent]: dotDate.getHours() % 6 === 0 && dotDate.getMinutes() === 0})}>
128
- {leftDate && format(dotDate, "dd.MM.yyyy HH:mm")}
129
- {!!stateChanged && ` (${stateChanged})`}
130
- </div>
131
- </div>;
132
- })}
133
- </div>
134
- </div>
135
- </div>;
136
- };
137
-
138
- const TimeSelect = ({
139
- onChange,
140
- currentDate,
141
- ...props
142
- }) => {
143
- const renderHourSelectOptions = () => {
144
- let options = [];
145
-
146
- for (let i = 1; i <= 24; i++) {
147
- options.push(<option
148
- key={`hour-option-${i}`}
149
- value={i}
150
- style={{padding: "8px"}}>{i < 10 ? `0${i}` : i}</option>);
151
- }
152
-
153
- return options;
154
- };
155
-
156
- const renderMinuteSelectOptions = () => {
157
- let options = [];
158
-
159
- for (let i = 0; i <= 60; i += 15) {
160
- options.push(<option
161
- key={`minute-option-${i}`}
162
- value={i}
163
- style={{padding: "8px"}}>{i < 10 ? `0${i}` : i}</option>);
164
- }
165
-
166
- return options;
167
- };
168
-
169
- return (
170
- <div {...props}>
171
- <select value={format(currentDate, "H")} onChange={e => onChange(e, "hour")} className="w-auto">
172
- {renderHourSelectOptions()}
173
- </select>
174
- <select value={format(currentDate, "m")} onChange={e => onChange(e, "minute")} className="mr-1 w-auto">
175
- {renderMinuteSelectOptions()}
176
- </select>
177
- <span className="dark:text-white">Uhr</span>
178
- </div>
179
- );
1
+ import {
2
+ useEffect, useState,
3
+ } from "react";
4
+ import styles from "./Timeline.module.css";
5
+ import format from "date-fns/format";
6
+ import subtract from "date-fns/sub";
7
+ import classNames from "classnames";
8
+
9
+ export const Timeline = ({
10
+ currentDate,
11
+ setCurrentDate,
12
+ loadTimelineStateForPage,
13
+ }) => {
14
+ const [timelineState, setTimelineState] = useState(null);
15
+ const stepsInRange = (24 * 60) / 15 + 1; // must be uneven so we have a center ;)
16
+
17
+ useEffect(() => {
18
+ if (!currentDate) {
19
+ const defaultCurrentDate = new Date();
20
+ defaultCurrentDate.setMinutes((Math.round(defaultCurrentDate.getMinutes() / 15) * 15) % 60);
21
+
22
+ setCurrentDate(defaultCurrentDate);
23
+ }
24
+ }, [currentDate]);
25
+
26
+ const leftDate = currentDate && subtract(currentDate, {minutes: stepsInRange / 2 * 15});
27
+ if (leftDate) {
28
+ leftDate.setMinutes((Math.round(currentDate.getMinutes() / 15) * 15) % 60);
29
+ leftDate.setSeconds(0);
30
+ leftDate.setMilliseconds(0);
31
+ }
32
+
33
+ const handleDateChange = (e) => {
34
+ if (!e.target.value) {
35
+ return;
36
+ }
37
+
38
+ let newDate = new Date(e.target.value);
39
+
40
+ if (format(currentDate, "yyyy-MM-dd") === format(newDate, "yyyy-MM-dd")) {
41
+ return; // nothing changed
42
+ }
43
+
44
+ newDate.setHours(currentDate.getHours(), currentDate.getMinutes());
45
+
46
+ setCurrentDate(newDate);
47
+ };
48
+
49
+ const handleTimeChange = (e, type) => {
50
+ if (!e.target.value) {
51
+ return;
52
+ }
53
+
54
+ let newDate = new Date(currentDate);
55
+
56
+ switch (type) {
57
+ case "hour":
58
+ if (newDate.getHours() === e.target.value) {
59
+ return; // nothing changed
60
+ }
61
+
62
+ newDate.setHours(e.target.value);
63
+ break;
64
+ case "minute":
65
+ if (newDate.getMinutes() === e.target.value) {
66
+ return; // nothing changed
67
+ }
68
+
69
+ newDate.setMinutes(e.target.value);
70
+ break;
71
+ }
72
+
73
+ setCurrentDate(newDate);
74
+ };
75
+
76
+
77
+ useEffect(() => {
78
+ if (!currentDate) {
79
+ return;
80
+ }
81
+
82
+ const leftDate = subtract(currentDate, {minutes: stepsInRange / 2 * 15});
83
+ leftDate.setMinutes((Math.round(currentDate.getMinutes() / 15) * 15) % 60);
84
+ leftDate.setSeconds(0);
85
+
86
+ const rightDate = new Date();
87
+ rightDate.setTime(leftDate.getTime() + (15 * 60 * 1000 * stepsInRange));
88
+
89
+ loadTimelineStateForPage(leftDate, rightDate).then(setTimelineState);
90
+ }, [currentDate])
91
+
92
+ return <div className="flex w-full">
93
+ <div className={styles.wrapper}>
94
+ <div className="w-full h-auto text-center py-2">
95
+ {!!currentDate && (
96
+ <>
97
+ <input
98
+ type="date"
99
+ value={format(currentDate, "yyyy-MM-dd")}
100
+ onChange={handleDateChange}
101
+ className="mr-2 w-auto"/>
102
+ <TimeSelect className="inline w-auto" currentDate={currentDate} onChange={handleTimeChange}/>
103
+ </>
104
+ )}
105
+ </div>
106
+ <div className={styles.timeline}>
107
+ {!!leftDate && Array(stepsInRange).fill(0).map((_, index) => {
108
+ const dotDate = new Date(leftDate.getTime() + (15 * 60 * 1000 * (index + 1)));
109
+ const stateChanged = timelineState?.[dotDate.toISOString()] || 0;
110
+ const currentDateCopy = new Date(currentDate);
111
+ currentDateCopy.setMilliseconds(0);
112
+ currentDateCopy.setSeconds(0);
113
+
114
+ return <div
115
+ key={index}
116
+ className={classNames(styles.timelineDot, {
117
+ [styles.timelineDotActive]: dotDate.getTime() === currentDateCopy.getTime(),
118
+ [styles.timelineDotChanged]: !!stateChanged,
119
+ })}
120
+ onClick={e => {
121
+ e.preventDefault();
122
+ setCurrentDate(dotDate);
123
+ return false;
124
+ }}
125
+ >
126
+ <div
127
+ className={classNames(styles.timelineDotLabel, {[styles.timelineDotLabelPermanent]: dotDate.getHours() % 6 === 0 && dotDate.getMinutes() === 0})}>
128
+ {leftDate && format(dotDate, "dd.MM.yyyy HH:mm")}
129
+ {!!stateChanged && ` (${stateChanged})`}
130
+ </div>
131
+ </div>;
132
+ })}
133
+ </div>
134
+ </div>
135
+ </div>;
136
+ };
137
+
138
+ const TimeSelect = ({
139
+ onChange,
140
+ currentDate,
141
+ ...props
142
+ }) => {
143
+ const renderHourSelectOptions = () => {
144
+ let options = [];
145
+
146
+ for (let i = 1; i <= 24; i++) {
147
+ options.push(<option
148
+ key={`hour-option-${i}`}
149
+ value={i}
150
+ style={{padding: "8px"}}>{i < 10 ? `0${i}` : i}</option>);
151
+ }
152
+
153
+ return options;
154
+ };
155
+
156
+ const renderMinuteSelectOptions = () => {
157
+ let options = [];
158
+
159
+ for (let i = 0; i <= 60; i += 15) {
160
+ options.push(<option
161
+ key={`minute-option-${i}`}
162
+ value={i}
163
+ style={{padding: "8px"}}>{i < 10 ? `0${i}` : i}</option>);
164
+ }
165
+
166
+ return options;
167
+ };
168
+
169
+ return (
170
+ <div {...props}>
171
+ <select value={format(currentDate, "H")} onChange={e => onChange(e, "hour")} className="w-auto">
172
+ {renderHourSelectOptions()}
173
+ </select>
174
+ <select value={format(currentDate, "m")} onChange={e => onChange(e, "minute")} className="mr-1 w-auto">
175
+ {renderMinuteSelectOptions()}
176
+ </select>
177
+ <span className="dark:text-white">Uhr</span>
178
+ </div>
179
+ );
180
180
  };
@@ -1,90 +1,90 @@
1
- .wrapper {
2
- display: flex;
3
- flex-direction: column;
4
- position: relative;
5
- width: 100%;
6
- overflow: hidden;
7
- }
8
-
9
- .timeline {
10
- position: relative;
11
- height: auto;
12
- padding: 30px 0 12px 0;
13
- width: 100%;
14
- display: flex;
15
- font-size: 1em;
16
- justify-content: space-between;
17
- }
18
- .timeline:after {
19
- content: "";
20
- display: block;
21
- background: black;
22
- width: 100%;
23
- height: 2px;
24
- position: absolute;
25
- z-index: 0;
26
- bottom: 16px;
27
- left: 0px;
28
- }
29
-
30
- .timeline:hover .timeline-dot-label {
31
- opacity: 0.2;
32
- }
33
-
34
- .timeline-dot {
35
- display: block;
36
- object-fit: contain;
37
- width: 100%;
38
- max-width: 16px;
39
- aspect-ratio: 1;
40
- border-radius: 9999px;
41
- position: relative;
42
- z-index: 1;
43
- }
44
-
45
- .timeline .timeline-dot:hover .timeline-dot-label {
46
- display: block;
47
- opacity: 1;
48
- z-index: 100;
49
- }
50
-
51
- .timeline-dot-active {
52
- outline: 2px solid green;
53
- cursor: pointer;
54
- background-color: green;
55
- }
56
-
57
- .timeline-dot-changed {
58
- outline: 2px solid blue;
59
- cursor: pointer;
60
- background-color: #004f73;
61
- }
62
-
63
- .timeline-dot-active.timeline-dot-changed {
64
- outline: 2px solid green;
65
- background-color: #004f73;
66
- }
67
-
68
- .timeline-dot-label.timeline-dot-label-permanent {
69
- display: block;
70
- z-index: 10;
71
- }
72
-
73
- .timeline-dot-label {
74
- display: none;
75
- background: white;
76
- position: absolute;
77
- top: -30px;
78
- left: -90px;
79
- width: 180px;
80
- text-align: center;
81
- }
82
-
83
- @media(prefers-color-scheme: dark) {
84
- .timeline:after {
85
- background: white;
86
- }
87
- .timeline-dot-changed {
88
- background-color: #ffffff;
89
- }
1
+ .wrapper {
2
+ display: flex;
3
+ flex-direction: column;
4
+ position: relative;
5
+ width: 100%;
6
+ overflow: hidden;
7
+ }
8
+
9
+ .timeline {
10
+ position: relative;
11
+ height: auto;
12
+ padding: 30px 0 12px 0;
13
+ width: 100%;
14
+ display: flex;
15
+ font-size: 1em;
16
+ justify-content: space-between;
17
+ }
18
+ .timeline:after {
19
+ content: "";
20
+ display: block;
21
+ background: black;
22
+ width: 100%;
23
+ height: 2px;
24
+ position: absolute;
25
+ z-index: 0;
26
+ bottom: 16px;
27
+ left: 0px;
28
+ }
29
+
30
+ .timeline:hover .timeline-dot-label {
31
+ opacity: 0.2;
32
+ }
33
+
34
+ .timeline-dot {
35
+ display: block;
36
+ object-fit: contain;
37
+ width: 100%;
38
+ max-width: 16px;
39
+ aspect-ratio: 1;
40
+ border-radius: 9999px;
41
+ position: relative;
42
+ z-index: 1;
43
+ }
44
+
45
+ .timeline .timeline-dot:hover .timeline-dot-label {
46
+ display: block;
47
+ opacity: 1;
48
+ z-index: 100;
49
+ }
50
+
51
+ .timeline-dot-active {
52
+ outline: 2px solid green;
53
+ cursor: pointer;
54
+ background-color: green;
55
+ }
56
+
57
+ .timeline-dot-changed {
58
+ outline: 2px solid blue;
59
+ cursor: pointer;
60
+ background-color: #004f73;
61
+ }
62
+
63
+ .timeline-dot-active.timeline-dot-changed {
64
+ outline: 2px solid green;
65
+ background-color: #004f73;
66
+ }
67
+
68
+ .timeline-dot-label.timeline-dot-label-permanent {
69
+ display: block;
70
+ z-index: 10;
71
+ }
72
+
73
+ .timeline-dot-label {
74
+ display: none;
75
+ background: white;
76
+ position: absolute;
77
+ top: -30px;
78
+ left: -90px;
79
+ width: 180px;
80
+ text-align: center;
81
+ }
82
+
83
+ @media(prefers-color-scheme: dark) {
84
+ .timeline:after {
85
+ background: white;
86
+ }
87
+ .timeline-dot-changed {
88
+ background-color: #ffffff;
89
+ }
90
90
  }