Browse code

Refactor and rewrite as contao bundle

Benjamin Roth authored on04/11/2022 22:32:32
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,36 @@
1
+import React from 'react';
2
+
3
+function getChildren(children) {
4
+  var slides = [];
5
+  var slots = {
6
+    'container-start': [],
7
+    'container-end': [],
8
+    'wrapper-start': [],
9
+    'wrapper-end': []
10
+  };
11
+
12
+  function processChildren(c) {
13
+    React.Children.toArray(c).forEach(function (child) {
14
+      if (child.type === React.Fragment && child.props.children) {
15
+        processChildren(child.props.children);
16
+        return;
17
+      }
18
+
19
+      if (child.type && child.type.displayName === 'SwiperSlide') {
20
+        slides.push(child);
21
+      } else if (child.props && child.props.slot && slots[child.props.slot]) {
22
+        slots[child.props.slot].push(child);
23
+      } else {
24
+        slots['container-end'].push(child);
25
+      }
26
+    });
27
+  }
28
+
29
+  processChildren(children);
30
+  return {
31
+    slides: slides,
32
+    slots: slots
33
+  };
34
+}
35
+
36
+export { getChildren };
0 37
\ No newline at end of file