Skip to content

Commit

Permalink
Always bring internal button to full width
Browse files Browse the repository at this point in the history
  • Loading branch information
lucsoft committed Feb 14, 2024
1 parent 2722daa commit 1066a4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export class ButtonComponent extends ColoredComponent {
});
return this;
}
setAlignContent(type: "center" | "end" | "start" | "stretch") {
setAlignContent(type: "center" | "end" | "start" | "stretch" | "space-around" | "space-between" | "space-evenly") {
this.wrapper.style.alignContent = type;
return this;
}
setJustifyContent(type: "center" | "end" | "start" | "stretch") {
setJustifyContent(type: "center" | "end" | "start" | "stretch" | "space-around" | "space-between" | "space-evenly") {
this.wrapper.style.justifyContent = type;
return this;
}
Expand Down
9 changes: 8 additions & 1 deletion src/components/FormInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export class DropDownInputComponent<Value extends string> extends InputForm<Valu
super();

const text = asRef(label);
this.button = Button(text).addSuffix(icon);
this.button = Button(text)
.setWidth("100%")
.setJustifyContent("space-between")
.addSuffix(icon);

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

this.button.onClick(() => {
if (dropDownPopover.isOpen()) {
dropDownPopover.hidePopover();
return;
}
dropDownPopover.clearAnchors("--wdropdown-default");
this.button.setAnchorName("--wdropdown-default");
dropDownPopover.showPopover();
Expand Down
4 changes: 4 additions & 0 deletions src/components/Popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export const Popover = (content: Component) => new class extends Component {
return this;
};

public isOpen() {
return this.wrapper.matches(':popover-open');
}

public clearAnchors(anchorName: `--${string}`) {
const anchors = document.querySelectorAll(`[anchor="${anchorName}"]`);
anchors.forEach(anchor => anchor.removeAttribute("anchor"));
Expand Down

0 comments on commit 1066a4c

Please sign in to comment.