Skip to content

Commit 1066a4c

Browse files
committed
Always bring internal button to full width
1 parent 2722daa commit 1066a4c

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/components/Button.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ export class ButtonComponent extends ColoredComponent {
5151
});
5252
return this;
5353
}
54-
setAlignContent(type: "center" | "end" | "start" | "stretch") {
54+
setAlignContent(type: "center" | "end" | "start" | "stretch" | "space-around" | "space-between" | "space-evenly") {
5555
this.wrapper.style.alignContent = type;
5656
return this;
5757
}
58-
setJustifyContent(type: "center" | "end" | "start" | "stretch") {
58+
setJustifyContent(type: "center" | "end" | "start" | "stretch" | "space-around" | "space-between" | "space-evenly") {
5959
this.wrapper.style.justifyContent = type;
6060
return this;
6161
}

src/components/FormInputs.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ export class DropDownInputComponent<Value extends string> extends InputForm<Valu
7777
super();
7878

7979
const text = asRef(label);
80-
this.button = Button(text).addSuffix(icon);
80+
this.button = Button(text)
81+
.setWidth("100%")
82+
.setJustifyContent("space-between")
83+
.addSuffix(icon);
8184

8285
this.wrapper.innerHTML = "";
8386
this.color.setValue(Color.Disabled);
@@ -91,6 +94,10 @@ export class DropDownInputComponent<Value extends string> extends InputForm<Valu
9194
});
9295

9396
this.button.onClick(() => {
97+
if (dropDownPopover.isOpen()) {
98+
dropDownPopover.hidePopover();
99+
return;
100+
}
94101
dropDownPopover.clearAnchors("--wdropdown-default");
95102
this.button.setAnchorName("--wdropdown-default");
96103
dropDownPopover.showPopover();

src/components/Popover.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export const Popover = (content: Component) => new class extends Component {
3434
return this;
3535
};
3636

37+
public isOpen() {
38+
return this.wrapper.matches(':popover-open');
39+
}
40+
3741
public clearAnchors(anchorName: `--${string}`) {
3842
const anchors = document.querySelectorAll(`[anchor="${anchorName}"]`);
3943
anchors.forEach(anchor => anchor.removeAttribute("anchor"));

0 commit comments

Comments
 (0)