@@ -4,15 +4,23 @@ import Yoga.Prelude.Style
4import Data.Interpolate (i)
4import Data.Interpolate (i)
5import Yoga.Block.Container.Style (colour)
5import Yoga.Block.Container.Style (colour)
7+data SizeVariant = SizeMedium | SizeSmall
9+sizeVariantToFactor ∷ SizeVariant → String
10+sizeVariantToFactor = case _ of
7type Props :: forall k. (Type -> k) -> Row k -> Row k
14type Props :: forall k. (Type -> k) -> Row k -> Row k
8−type Props f r
15+type Props f r =
9− = ( css ∷ f Style
16+ ( css ∷ f Style
17+ , sizeVariant :: f SizeVariant
10− , background ∷ f String
18+ , background ∷ f String
11− , textColour ∷ f String
19+ , textColour ∷ f String
12− , placeholderColour ∷ f String
20+ , placeholderColour ∷ f String
13− , borderColour ∷ f String
21+ , borderColour ∷ f String
17leftIconSize ∷ StyleProperty
25leftIconSize ∷ StyleProperty
18leftIconSize = var "--left-icon-size"
26leftIconSize = var "--left-icon-size"
@@ -38,9 +46,9 @@ labelAndInputWrapper =
39 { position: relative
47 { position: relative
40 -- , display: inlineBlock
48 -- , display: inlineBlock
41− , "--left-icon-size": var "--s0"
49+ , "--left-icon-size": str "calc(var(--s0) * var(--input-size-factor))"
42− , "--right-icon-size": str "calc(var(--s0) * 1.2)"
50+ , "--right-icon-size": str "calc(var(--s0) * var(--input-size-factor)) * 1.2)"
43− , "--input-border-radius": var "--s-1"
51+ , "--input-border-radius": str "calc(var(--s-1) * var(--input-size-factor))"
44 , "--input-side-padding": var "--s-1"
52 , "--input-side-padding": var "--s-1"
45 , width: inherit
53 , width: inherit
46 , margin: _0
54 , margin: _0
@@ -51,8 +59,8 @@ labelContainer =
52 { position: absolute
60 { position: absolute
53 , overflow: visible
61 , overflow: visible
55 , left: _0
62 , left: _0
56 , display: inlineBlock
64 , display: inlineBlock
57 , zIndex: str "2"
65 , zIndex: str "2"
58 , pointerEvents: none
66 , pointerEvents: none
@@ -62,7 +70,7 @@ labelSmall ∷ String -> String -> Style
62labelSmall background textColour =
70labelSmall background textColour =
64 { fontSize: var "--s-1"
72 { fontSize: var "--s-1"
65− , marginTop: str "calc(var(--s-3) * -1)"
73+ , marginTop: str "calc(var(--s-2) * var(--input-size-factor) * -1)"
66 , marginLeft: var "--s-2"
74 , marginLeft: var "--s-2"
67 , userSelect: none
75 , userSelect: none
68 , """&[data-required="true"] > span:after""":
76 , """&[data-required="true"] > span:after""":
@@ -73,7 +81,7 @@ labelSmall background textColour =
74 { fontWeight: str "500"
82 { fontWeight: str "500"
75 , whiteSpace: str "nowrap"
83 , whiteSpace: str "nowrap"
76− , background: str $ i "linear-gradient(" background " 51%, transparent 51%, transparent)"
84+ , background: str $ i "linear-gradient(" background " 61%, transparent 61%, transparent)"
77 , color: str textColour
85 , color: str textColour
78 , borderRadius: var "--s-4"
86 , borderRadius: var "--s-4"
79 , paddingLeft: var "--s-4"
87 , paddingLeft: var "--s-4"
@@ -109,32 +117,30 @@ labelSmallFocusBackground =
109labelLarge ∷ { left ∷ Number, width ∷ Number } -> Style
117labelLarge ∷ { left ∷ Number, width ∷ Number } -> Style
110labelLarge { left, width } =
118labelLarge { left, width } =
112− { fontSize: str "var(--s0)"
120+ { fontSize: str "calc(var(--input-size-factor) * 16px)"
113 , padding: _0
121 , padding: _0
114 , whiteSpace: nowrap -- force on one line
122 , whiteSpace: nowrap -- force on one line
115− , height: str "calc(var(--s0) * 1.2)"
123+ -- , height: str "calc(var(--s0) * 1.2)"
116 , letterSpacing: em (-0.011)
124 , letterSpacing: em (-0.011)
117 , maxWidth: str $ i "calc(" width "px - 2ch)"
125 , maxWidth: str $ i "calc(" width "px - 2ch)"
118− , marginTop: str "calc(var(--s-1))"
126+ , marginTop: str "calc(var(--s-1) * var(--input-size-factor))"
119 , marginLeft: str $ i left "px"
127 , marginLeft: str $ i left "px"
120 , marginRight: var "--input-side-padding"
128 , marginRight: var "--input-side-padding"
121 , color: str colour.textPaler2
129 , color: str colour.textPaler2
122 , fontWeight: str "400"
130 , fontWeight: str "400"
123 , overflowX: str "hidden"
131 , overflowX: str "hidden"
124 , textOverflow: str "ellipsis"
132 , textOverflow: str "ellipsis"
125− , overflowY: str "visible"
133+ , overflowY: visible
126− , "MsOverflowStyle": none
127 , scrollbarWidth: none
134 , scrollbarWidth: none
128 , "&::-webkit-scrollbar": nested $ css
135 , "&::-webkit-scrollbar": nested $ css
129− { display: none }
136+ { display: none }
130 -- , fontWeight: str "600"
137 -- , fontWeight: str "600"
131 , """&[data-required="true"]:after""":
138 , """&[data-required="true"]:after""":
133 { content: str "'*'"
140 { content: str "'*'"
134 , color: str colour.required
141 , color: str colour.required
135 , fontFamily: str "Helvetica, Arial, Inter, sans-serif"
142 , fontFamily: str "Helvetica, Arial, Inter, sans-serif"
136− , fontSize: str "calc(var(--s0))"
137− , lineHeight: str "calc(var(--s0) * 0.85)"
143+ , lineHeight: str "calc(var(--s0) * 0.85 * var(--input-size-factor))"
@@ -142,31 +148,31 @@ rightIconContainer ∷ Style
142rightIconContainer =
148rightIconContainer =
143 iconContainer
149 iconContainer
145− { display: inlineFlex
151+ { display: inlineFlex
146− , alignItems: center
152+ , alignItems: center
147− , justifyContent: center
153+ , justifyContent: center
148− , "& > *":
154+ , "& > *":
150− { display: inlineFlex
156+ { display: inlineFlex
151− , alignItems: center
157+ , alignItems: center
152− , justifyContent: center
158+ , justifyContent: center
154− , ".ry-icon":
160+ , ".ry-icon":
156− { "--stroke-colour": str colour.text
162+ { "--stroke-colour": str colour.text
160leftIconContainer ∷ Style
166leftIconContainer ∷ Style
161leftIconContainer =
167leftIconContainer =
162 iconContainer
168 iconContainer
164− { borderRadius: str "var(--input-border-radius) 0 0 var(--input-border-radius)"
170+ { borderRadius: str "var(--input-border-radius) 0 0 var(--input-border-radius)"
165− , ".ry-icon":
171+ , ".ry-icon":
167− { "--stroke-colour": str colour.text
173+ { "--stroke-colour": str colour.text
171inputContainer ∷ ∀ r. { | Props OptionalProp r } -> Style
177inputContainer ∷ ∀ r. { | Props OptionalProp r } -> Style
172inputContainer props = theCss <>? props.css
178inputContainer props = theCss <>? props.css
@@ -175,9 +181,10 @@ inputContainer props = theCss <>? props.css
176 { "--left-icon-size": var "--s0"
182 { "--left-icon-size": var "--s0"
177 , "--right-icon-size": str "calc(var(--s0) * 1.2)"
183 , "--right-icon-size": str "calc(var(--s0) * 1.2)"
178− , "--input-side-padding": str "calc(var(--s-1) * 1.2)"
184+ , "--input-side-padding": str "calc(var(--s-1) * var(--input-size-factor) * 1.2)"
179− , "--input-top-padding": var "--s-5"
185+ , "--input-top-padding": str "calc(var(--s-5) * var(--input-size-factor))"
180− , "--input-bottom-padding": var "--s-5"
186+ , "--input-bottom-padding": str "calc(var(--s-5) * var(--input-size-factor))"
187+ , "--input-size-factor": str ((props.sizeVariant ?|| SizeMedium) # sizeVariantToFactor)
181 , letterSpacing: em (-0.011)
188 , letterSpacing: em (-0.011)
182 , position: relative
189 , position: relative
183 , cursor: str "text"
190 , cursor: str "text"
@@ -200,41 +207,50 @@ inputContainer props = theCss <>? props.css
200 { "--border-width": str "2px"
207 { "--border-width": str "2px"
201 , borderColor: str colour.highlight
208 , borderColor: str colour.highlight
202 , marginTop: str "-1px"
209 , marginTop: str "-1px"
203− , transition: str "border-color 0s linear 0.1s"
204− , animation: plopAnimation <> str " 260ms ease-in"
206 , alignItems: center
211 , alignItems: center
207 , justifyContent: center
212 , justifyContent: center
208 , border: str $ "var(--border-width) solid " <> colour.inputBorder
213 , border: str $ "var(--border-width) solid " <> colour.inputBorder
209− , paddingLeft: str "calc(var(--input-side-padding) - var(--border-width))"
214+ , paddingLeft: str "calc((var(--input-side-padding) - var(--border-width)) * var(--input-size-factor))"
210− , paddingRight: str "calc(var(--input-side-padding) - var(--border-width))"
215+ , paddingRight: str "calc((var(--input-side-padding) - var(--border-width)) * var(--input-size-factor))"
211− , paddingTop: str "calc(var(--input-top-padding) - var(--border-width))"
216+ , paddingTop: str "calc((var(--input-top-padding) - var(--border-width)) * var(--input-size-factor))"
212− , paddingBottom: str "calc(var(--input-bottom-padding) - var(--border-width))"
217+ , paddingBottom: str "calc((var(--input-bottom-padding)) - var(--border-width))"
213 , gap: str "calc(var(--input-side-padding) / 2)"
218 , gap: str "calc(var(--input-side-padding) / 2)"
214 , borderRadius: var "--input-border-radius"
219 , borderRadius: var "--input-border-radius"
223+ploppedFocusWithin ∷ Style
224+ploppedFocusWithin = css
227+ { animation: str "plop 180ms ease"
228+ , animationName: plopAnimation
217containerBackground ∷ ∀ r. { | Props OptionalProp r } -> Style
232containerBackground ∷ ∀ r. { | Props OptionalProp r } -> Style
218−containerBackground props = css {
233+containerBackground props = css
219− background: str (props.background ?|| colour.inputBackground)
234+ { background: str (props.background ?|| colour.inputBackground)
220− , boxShadow: str """
235+ -- , boxShadow: str
221− 0 1px 1px rgba(200,200,255,0.2),
237+ -- 0 1px 1px rgba(200,200,255,0.2),
222− 0 2px 2px rgba(200,200,255,0.1),
238+ -- 0 2px 2px rgba(200,200,255,0.1),
223− 0 4px 8px rgba(200,200,255,0.03)"""
239+ -- 0 4px 8px rgba(200,200,255,0.03)"""
224 , border: str $ "var(--border-width) solid " <> colour.inputBorder
240 , border: str $ "var(--border-width) solid " <> colour.inputBorder
225 , borderRadius: var "--input-border-radius"
241 , borderRadius: var "--input-border-radius"
229containerContainer ∷ ∀ r. { | Props OptionalProp r } -> Style
245containerContainer ∷ ∀ r. { | Props OptionalProp r } -> Style
230−containerContainer props = css {
246+containerContainer props = css
231− "& > *": nested $ css {
247+ { "& > *": nested $ css
232− gridColumn: int 1,
248+ { gridColumn: int 1
233− gridRow: int 1
249+ , gridRow: int 1
234− }, width: str "calc(var(--s4) * 2)"
250+ }
235− , height: str "calc(var(--s2) - var(--border-width) * 2)"
236 , "--border-width": str "1px"
251 , "--border-width": str "1px"
252+ , "--input-size-factor": str ((props.sizeVariant ?|| SizeMedium) # sizeVariantToFactor)
237− , "--input-border-radius": var "--s-1"
253+ , "--input-border-radius": str "calc(var(--s-1) * var(--input-size-factor))"
238 , borderRadius: var "--input-border-radius"
254 , borderRadius: var "--input-border-radius"
239 , display: grid
255 , display: grid
240 , overflow: visible
256 , overflow: visible
@@ -253,7 +269,8 @@ inputWrapper =
253input ∷ ∀ r. { | Props OptionalProp r } -> Style
269input ∷ ∀ r. { | Props OptionalProp r } -> Style
254input props =
270input props =
272+ { "--input-size-factor": str ((props.sizeVariant ?|| SizeMedium) # sizeVariantToFactor)
256− { "&[type=text],&[type=search],&[type=password],&[type=number],&:not([type])":
273+ , "&[type=text],&[type=search],&[type=password],&[type=number],&:not([type])":
258 { background: str "transparent"
275 { background: str "transparent"
259 , touchAction: manipulation
276 , touchAction: manipulation
@@ -262,14 +279,14 @@ input props =
262 , minWidth: _0
279 , minWidth: _0
263 , margin: _0
280 , margin: _0
264 , overflowY: visible
281 , overflowY: visible
282+ , "--padding-top": str "calc(var(--s-1) * var(--input-size-factor))"
283+ , "--padding-bottom": str "calc(var(--s-1) * var(--input-size-factor))"
265 , paddingTop: var "--padding-top"
284 , paddingTop: var "--padding-top"
266 , paddingBottom: var "--padding-bottom"
285 , paddingBottom: var "--padding-bottom"
267 , paddingLeft: _0
286 , paddingLeft: _0
268 , paddingRight: _0
287 , paddingRight: _0
269− -- , fontSize: str "calc(var(--s0) * 0.85)"
288+ , fontSize: str "calc(var(--input-size-factor) * 16px)"
270− , fontSize: str "calc(var(--s0))"
289+ -- , fontSize: str "calc(var(--s0))"
271− , "--padding-top": var "--s-1"
272− , "--padding-bottom": var "--s-1"
273 , "&::placeholder":
290 , "&::placeholder":
275 { color: str (props.placeholderColour ?|| colour.placeholderText)
292 { color: str (props.placeholderColour ?|| colour.placeholderText)
@@ -297,8 +314,9 @@ input props =
297plopAnimation ∷ StyleProperty
314plopAnimation ∷ StyleProperty
298plopAnimation =
315plopAnimation =
299 keyframes
316 keyframes
300− $ { "from": css { transform: str "scale3d(1.01,1.2,1)" }
318+ { "from": css { transform: str "scale3d(1.03,1.02,1)" }
301− , "67.7%": css { transform: str "scale3d(0.993,0.9,1)" }
319+ , "67.7%": css { transform: str "scale3d(0.997,0.98,1)" }
302− , "86.7%": css { transform: str "scale3d(1.002,1.05,1)" }
320+ , "86.7%": css { transform: str "scale3d(1.004,1.01,1)" }
303 , "to": css { transform: str "scale3d(1,1,1)" }
321 , "to": css { transform: str "scale3d(1,1,1)" }