Braze - #3923
Braze#3923oliverlloyd wants to merge 3 commits into
Braze#3923Conversation
| @@ -1,14 +1,12 @@ | |||
| import React, { useState, useEffect } from 'react'; | |||
| import React, { useEffect } from 'react'; | |||
| if (!switches.slotBodyEnd) return false; | ||
| if (!parse(slotMachineFlags || '').showBodyEnd) return false; |
There was a problem hiding this comment.
Could somebody please check that this code is the same as:
const showBodyEndSlot =
parse(CAPI.slotMachineFlags || '').showBodyEnd ||
CAPI.config.switches.slotBodyEnd;
This parse function is hard to reason about
There was a problem hiding this comment.
The logic looks the same in each case. Your version of splitting into separate conditions is clearer.
bikeshed: A tiny slot-machine-flags.test could be useful.
What is the source of CAPI.slotMachineFlags & CAPI.config.switches?
There was a problem hiding this comment.
What is the source of CAPI.slotMachineFlags & CAPI.config.switches?
I'm honestly not sure. I think switches maybe come from a tool around Composer? slotMachineFlags I know nothing about @sndrs any ideas?
|
Size Change: -79.8 kB (-7%) ✅ Total Size: 1.1 MB
ℹ️ View Unchanged
|
| } | ||
| } | ||
|
|
||
| export const Braze = ({ |
There was a problem hiding this comment.
Pulling this out of App looks great. I'm not sure Braze is the right name here, as SlotBodyEnd and StickyBottomBanner are broader than just Braze (they may also show epics/banners from RRCP and also the CMP banner). Not sure what a good name is that ties those two slots together though (maybe this is what Automat is 😄 )
|
Closing now that we have #4126 🎉 |
What does this change?
This PR introduces
Brazea component designed to hold the shared logic betweenSlotBodyEndandStickyBottomBannerWhy?
Because I think this is the safest refactor in order to make progress towards deleting
App.tsx. It probably is possible to isolate each of these components and remove the global state shared between them but this logic is complex and I decided to take this approach as a stepping stone towards this goal instead of diving in.slot-body-endThis id was previously used by the
Portalcomponent as the marker for where to insert the element. But it has also been picked up as an id that can be used for some css styling. By removing thePortalI would break this styling code so I have added anasidewrapper around the component.bannerWrapperThis css previously existed in the
stickinesslib and was added in the layout files. I've moved it down into the banner component directly as this seemed the more logical location for this code.shouldShowSlotBodyEndPreviously we rendered the
SlotBodyEndandStickyBottomBannercomponents independently but they did not always appear together. ForInteractiveandFullPageInteractivearticlesSlotBodyEndis not included and we also checked some flags. This function encapsulates this logic.