git.iko.soy/rowtype-yoga/ry-blocks
on main help sign in
Sheeeeeeet
commit5b149c0fe9cb670d38291e75c919597a73040deb authorMark Eibes <mark.eibes@gmail.com> dateSat 9 Jul 2022, 00:54 (4 years ago) parent8d2d8dc
3 files changed+16−13
src/Yoga/Block/Molecule/Sheet/Story.purs+4−2 src/Yoga/Block/Molecule/Sheet/Style.purs+3−2 src/Yoga/Block/Molecule/Sheet/View.purs+9−9
src/Yoga/Block/Molecule/Sheet/Story.purs+4−2
@@ -47,7 +47,8 @@ sheet = do
4747 pure
4848 $ fragment
4949 [ R.h2_ [ R.text "No Options" ]
50− , R.div { id: "modal-container" }
50+ , R.div { id: "clickaway-container", style: R.css { userSelect: "none" } }
51+ , R.div { id: "modal-container", style: R.css { userSelect: "none" } }
5152 , element Sheet.component
5253 { header: R.h2_ [ R.text "Would you like us to track you?" ]
5354 , footer: Block.cluster { justify: "flex-end", space: "var(--s-1)" }
@@ -88,6 +89,7 @@ sheet = do
8889 setText "Please answer the question"
8990 setIsOpen true
9091 setIsOpen false
91− , target: "modal-container"
92+ , containerId: "modal-container"
93+ , clickAwayId: "clickaway-container"
9294 }
9395 ]
src/Yoga/Block/Molecule/Sheet/Style.purs+3−2
@@ -2,8 +2,8 @@ module Yoga.Block.Molecule.Sheet.Style where
22
33import Yoga.Prelude.Style
44
5−import Fahrtwind (boxSizingBorderBox, boxSizingContentBox, mL', mR', mT, mX, mX', maxHeight', minHeight, overflowYScroll, pB, pB', pL', pR, pT, pT', pX', pY')
6−import Fahrtwind.Style.ScollBar (scrollBar, scrollBar')
5+import Fahrtwind (maxHeight', overflowYScroll, pX', pY')
6+import Fahrtwind.Style.ScollBar (scrollBar')
77import Yoga.Block.Container.Style (col, colour)
88
99type Props :: forall k. (Type -> k) -> Row k -> Row k
@@ -20,6 +20,7 @@ sheet = styles
2020 { zIndex: str "3"
2121 , position: fixed
2222 , left: str "0"
23+ , pointerEvents: auto
2324 , width: str "100vw"
2425 , background: str colour.backgroundLayer4
2526 , borderRadius: str $ "var(--s1) var(--s1) 0 0"
src/Yoga/Block/Molecule/Sheet/View.purs+9−9
@@ -30,34 +30,35 @@ type Props =
3030 , footer :: JSX
3131 , isOpen ∷ Boolean
3232 , onDismiss ∷ Effect Unit
33− , target ∷ String
33+ , containerId ∷ String
34+ , clickAwayId :: String
3435 | ()
3536 }
3637
3738component ∷ ReactComponent Props
3839component =
3940 unsafePerformEffect
40− $ reactComponent "Sheet Wrapper" \{ header, content, footer, isOpen, onDismiss, target } -> React.do
41− renderInPortal <- useRenderInPortal target
41+ $ reactComponent "Sheet Wrapper" \{ header, content, footer, isOpen, onDismiss, containerId, clickAwayId } -> React.do
42+ renderInPortal <- useRenderInPortal containerId
4243 useKeyDown case _ of
4344 KeyCode.Escape -> onDismiss
4445 _ -> mempty
45− clickAwayRef <- React.useRef Nullable.null
4646 let
4747 toRender ∷ JSX
4848 toRender =
4949 R.div' </ {}
5050 />
51− [ Motion.animatePresence </ {} /> [ guard isOpen $ element clickaway { theRef: clickAwayRef, onDismiss } ]
51+ [ Motion.animatePresence </ {} /> [ guard isOpen $ element clickaway { containerId: clickAwayId, onDismiss } ]
5252 , element window { onDismiss, header, content, footer, isOpen }
5353 ]
5454 pure (renderInPortal toRender)
5555
56−clickaway ∷ ReactComponent { theRef ∷ Ref (Nullable Node), onDismiss ∷ Effect Unit }
56+clickaway ∷ ReactComponent { containerId ∷ String, onDismiss ∷ Effect Unit }
5757clickaway =
5858 unsafePerformEffect
59− $ reactComponent "Sheet Clickaway" \{ theRef, onDismiss } -> React.do
60− pure $ Emotion.elementKeyed Motion.div
59+ $ reactComponent "Sheet Clickaway" \{ containerId, onDismiss } -> React.do
60+ renderInPortal <- useRenderInPortal containerId
61+ pure $ renderInPortal $ Emotion.elementKeyed Motion.div
6162 $
6263 { key: "ry-modal-clickaway"
6364 , onClick: handler_ onDismiss
@@ -66,7 +67,6 @@ clickaway =
6667 , initial: Motion.prop $ css { opacity: 0.0 }
6768 , animate: Motion.prop $ css { opacity: 1.0 }
6869 , exit: Motion.prop $ css { opacity: 0.0 }
69− , ref: theRef
7070 }
7171
7272type WindowProps =