Skip to content

Commit af0e4c5

Browse files
authored
Dropdown button updates (#125)
* secondary button should always be white (not transparent) * dropdown-menu-content min-width * set minWidth * set width/height
1 parent f8da18f commit af0e4c5

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Lumi/Components/Button.purs

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ styles = jss
221221
}
222222
, "&[data-color=\"secondary\"]":
223223
{ extend: buttonSecondary
224-
, backgroundColor: cssStringHSLA colors.transparent
224+
, backgroundColor: cssStringHSLA colors.white
225225
, "&:hover":
226226
{ color: cssStringHSLA colors.primary
227227
, borderColor: cssStringHSLA colors.primary
@@ -296,7 +296,7 @@ styles = jss
296296
}
297297

298298
buttonSecondary =
299-
{ backgroundColor: cssStringHSLA colors.transparent
299+
{ backgroundColor: cssStringHSLA colors.white
300300
, color: cssStringHSLA colors.black
301301
, border: [ "1px", "solid", cssStringHSLA colors.black3 ]
302302
}

src/Lumi/Components/DropdownButton.purs

+12-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ dropdownButton =
6767
initialState =
6868
{ isOpen: false
6969
, root: Nothing
70+
, width: 0.0
7071
, position:
7172
{ bottom: 0.0
7273
, left: 0.0
@@ -110,9 +111,10 @@ dropdownButton =
110111
then close self
111112
else do
112113
p <- getAbsolutePosition el
114+
d <- getDimensions el
113115
when state.isOpen $
114116
void $ requestAnimationFrame (capturePosition self ref (Just p0')) =<< HTML.window
115-
self.setState _{ position = p }
117+
self.setState _{ position = p, width = d.width }
116118

117119
toggleOpen self refM = do
118120
self.setStateThen
@@ -149,6 +151,7 @@ dropdownButton =
149151
{ style: R.mergeStyles
150152
[ R.css
151153
{ top: show (state.position.bottom + 4.0) <> "px"
154+
, minWidth: show state.width <> "px"
152155
}
153156
, if maybe false (_ == "right") (toMaybe props.alignment) then
154157
R.css { left: "auto", right: show (state.position.right - 1.0) <> "px" }
@@ -269,6 +272,14 @@ dropdownIcon props =
269272

270273
foreign import checkIsEventTargetInTree :: EffectFn2 Node Event Boolean
271274

275+
getDimensions :: HTML.HTMLElement -> Effect { width :: Number, height :: Number }
276+
getDimensions el = do
277+
{ width, height } <- HTML.getBoundingClientRect el
278+
pure
279+
{ width: width
280+
, height: height
281+
}
282+
272283
getAbsolutePosition :: HTML.HTMLElement -> Effect { bottom :: Number, left :: Number, right :: Number }
273284
getAbsolutePosition el = do
274285
window <- HTML.window

0 commit comments

Comments
 (0)