|
| 1 | +mergeDOMbySlots (parentDomSink, childrenDomSinks, settings) { |
| 2 | + // @type {Array<String>} slots |
| 3 | + const {slots} = settings; |
| 4 | + |
| 5 | + // deal with null sinks etc. |
| 6 | + $.combineLatest(flatten(parentDomSink, childrenDomSinks)) |
| 7 | + .map(vNodeTreeArray => { |
| 8 | + // reorder according to slots (use ramda sort) |
| 9 | + return sortBy (vTree => getSlotIndex(getSlot(vTree), slots), vTreeArray) |
| 10 | + }) |
| 11 | + .map(div) // unless only one |
| 12 | +} |
| 13 | + |
| 14 | + |
| 15 | +put the slots in the settings of the child component |
| 16 | + |
| 17 | +# Example |
| 18 | +``` |
| 19 | +m({}, {}, [ |
| 20 | + Navigation({slots : ['', 'navigation-section']}, [Header, [ |
| 21 | + SomeContent, |
| 22 | + InSlot({slot : ''navigation-section'}, [NavigationSection()], |
| 23 | + InSlot({slot : ''navigation-section'}, [NavigationSection()], |
| 24 | + OtherContent |
| 25 | + ]]) |
| 26 | +]) |
| 27 | +``` |
| 28 | + |
| 29 | +# InSlot |
| 30 | +`InSlot` set the `vNode.data.slot` property to `settings.slot` |
| 31 | +`InSlot` should not pass its settings!, at least not its slot settings |
| 32 | + |
| 33 | +# getSlot :: vTree -> String |
| 34 | +`return vNodeTree.data.slot` |
| 35 | +or someting like that, must return undefined is no slot set up |
| 36 | + |
| 37 | +# getSlotIndex :: String -> Slots -> Number |
| 38 | +- `Slots :: Array<String>` |
| 39 | + |
| 40 | +function getSlotIndex(slotToFind, slots){ |
| 41 | + return findIndex(equals(slotToFind || undefined), slots) |
| 42 | +} |
| 43 | + |
0 commit comments