@@ -18,6 +18,7 @@ import React.Basic (JSX, ReactComponent, element, elementKeyed, fragment)
18import React.Basic.DOM (CSS, css)
18import React.Basic.DOM (CSS, css)
19import React.Basic.DOM as R
19import React.Basic.DOM as R
20import React.Basic.DOM.Events (targetValue)
20import React.Basic.DOM.Events (targetValue)
21+import React.Basic.Emotion (str)
21import React.Basic.Emotion as E
22import React.Basic.Emotion as E
22import React.Basic.Events (handler, handler_)
23import React.Basic.Events (handler, handler_)
23import React.Basic.Hooks (reactComponent)
24import React.Basic.Hooks (reactComponent)
@@ -27,11 +28,16 @@ import React.Basic.Popper.Placement.Types as Placement
27import React.Basic.Popper.Types (nullRef)
28import React.Basic.Popper.Types (nullRef)
28import Unsafe.Coerce (unsafeCoerce)
29import Unsafe.Coerce (unsafeCoerce)
29import Yoga ((/>), (</), (</>))
30import Yoga ((/>), (</), (</>))
31+import Yoga.Block as Block
32+import Yoga.Block.Atom.Icon as Icon
30import Yoga.Block.Atom.Input as Input
33import Yoga.Block.Atom.Input as Input
31import Yoga.Block.Atom.Input.Types as HTMLInput
34import Yoga.Block.Atom.Input.Types as HTMLInput
32import Yoga.Block.Atom.Popover as Popover
35import Yoga.Block.Atom.Popover as Popover
36+import Yoga.Block.Container.Style (colour)
33import Yoga.Block.Container.Style as Styles
37import Yoga.Block.Container.Style as Styles
38+import Yoga.Block.Icon.SVG as Icons
34import Yoga.Block.Layout.Box as Box
39import Yoga.Block.Layout.Box as Box
40+import Yoga.Block.Layout.Cluster as Cluster
35import Yoga.Block.Layout.Stack as Stack
41import Yoga.Block.Layout.Stack as Stack
@@ -67,20 +73,47 @@ popover = do
67 reactComponent "PopoverExample" \props -> React.do
73 reactComponent "PopoverExample" \props -> React.do
68 referenceElement /\ setReferenceElement <- React.useState' nullRef
74 referenceElement /\ setReferenceElement <- React.useState' nullRef
69 text /\ setText <- React.useState' ""
75 text /\ setText <- React.useState' ""
70− visible /\ setVisible <- React.useState' false
76+ visible /\ setVisible <- React.useState' true
77+ selectedAuthors /\ modSelectedAuthors <-
78+ React.useState [ "William Shakespeare", "Agatha Christie" ]
72 matchingAuthors =
80 matchingAuthors =
82+ # (_ Array.\\ selectedAuthors)
74 # Array.filter
83 # Array.filter
76 String.contains (String.Pattern (String.toLower text))
85 String.contains (String.Pattern (String.toLower text))
77 (String.toLower a)
86 (String.toLower a)
82− </ { ref: unsafeCoerce (mkEffectFn1 setReferenceElement)
89+ inputWrapper = R.div' </ { ref: unsafeCoerce (mkEffectFn1 setReferenceElement) }
91+ Block.box </ { padding: str "var(--s-3)" }
95+ { background: colour.highlight
96+ , fontSize: "var(--s-1)"
97+ , space: "var(--s-5)"
98+ , borderRadius: "var(--s-2)"
105+ { background: "hotpink"
110+ </> { icon: Icons.cross, size: str "var(--s-1)"
115+ pills = pill <$> selectedAuthors
116+ leading = Block.cluster </ {} /> pills
85 Input.component
118 Input.component
86 </> { id: "author"
119 </> { id: "author"
@@ -92,19 +125,20 @@ popover = do
92 , onChange: handler targetValue $ traverse_ setText
125 , onChange: handler targetValue $ traverse_ setText
93 , onBlur: handler_ (setVisible false)
126 , onBlur: handler_ (setVisible false)
94 , onFocus: handler_ (setVisible true)
127 , onFocus: handler_ (setVisible true)
95− , trailing: R.text "▼"
128+ , leading
96 , autoComplete: "off"
129 , autoComplete: "off"
98 pop children =
131 pop children =
99 elementKeyed motionPopover
132 elementKeyed motionPopover
100 $ Motion.motion
133 $ Motion.motion
101 { initial:
134 { initial:
102− css { clipPath: "polygon(0% 0%, 100% 0%, 100% 0%, 0% 0%)" }
135+ css { maxHeight: 30, opacity: 0.0 }
104− css { clipPath: "polygon(0% 0%, 100% 0%, 100% 0%, 0% 0%)" }
137+ css { maxHeight: 30, opacity: 0.0 }
105 , animate:
138 , animate:
107− { clipPath: "polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"
140+ { maxHeight: 400
109 , transition:
143 , transition:
110 Motion.transition
144 Motion.transition
@@ -120,9 +154,10 @@ popover = do
122 { boxShadow: "0px 9px 12px rgba(40,40,40,0.5)"
156 { boxShadow: "0px 9px 12px rgba(40,40,40,0.5)"
123− , background: "rgba(50,50,70, 0.7)"
157+ , background: colour.interfaceBackground
124 , borderRadius: "9px"
158 , borderRadius: "9px"
125− , borderTop: "solid 1px rgba(80,80,100,1.0)"
159+ , borderTop: "solid 1px " <> colour.interfaceBackgroundHighlight
160+ , borderBottom: "solid 1px " <> colour.interfaceBackgroundShadow
126 , overflowY: "scroll"
161 , overflowY: "scroll"
127 , maxHeight: "400px"
162 , maxHeight: "400px"
128 , width: "300px"
163 , width: "300px"
@@ -149,6 +184,7 @@ popover = do
149 </ { key: a
184 </ { key: a
150 -- , layout: Motion.layout true
185 -- , layout: Motion.layout true
151 -- , variants: Motion.variants itemVariants
186 -- , variants: Motion.variants itemVariants
187+ , onClick: handler_ (modSelectedAuthors (_ `Array.snoc` a))
153 /> [ R.text a ]
189 /> [ R.text a ]