Skip to content

Commit a613243

Browse files
Felipe Langpaodb
authored andcommitted
fix: add day buttons spacing
Buttons spacing may be customized using --fc-days-of-week-selector-button-space css variable Close #15
1 parent d2c32bb commit a613243

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/main/resources/META-INF/frontend/styles/fc-days-of-week-selector-styles.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,6 @@ vaadin-horizontal-layout.fc-days-of-week-selector-buttons-layout {
5757

5858
vaadin-context-menu-overlay vaadin-context-menu-list-box::part(items) {
5959
padding: 0 var(--lumo-space-xs);
60+
display: inline-flex;
61+
gap: var(--fc-days-of-week-selector-button-space, var(--lumo-space-m));
6062
}

src/main/resources/META-INF/resources/frontend/src/fc-days-of-week-selector.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class DaysOfWeekSelector extends ResizeMixin(ThemableMixin(LitElement)) {
6464
flex-wrap: nowrap;
6565
overflow: hidden;
6666
align-items: center;
67+
gap: var(--fc-days-of-week-selector-button-space, var(--lumo-space-m));
6768
}
6869
6970
[part="overflow-badge"] {
@@ -94,10 +95,14 @@ export class DaysOfWeekSelector extends ResizeMixin(ThemableMixin(LitElement)) {
9495
box-sizing: border-box;
9596
}
9697
98+
[part="container"] vaadin-context-menu {
99+
margin-left: calc(var(--lumo-space-s) * -1);
100+
}
101+
97102
::slotted([slot="overflowIcon"]) {
98103
--lumo-icon-size-m: var(--fc-days-of-week-selector-overflow-icon-size, 1em);
99104
}
100-
105+
101106
/* Style the fallback <vaadin-icon> inside the slot */
102107
vaadin-icon.overflow-icon {
103108
--lumo-icon-size-m: var(--fc-days-of-week-selector-overflow-icon-size, 0.75em);
@@ -157,15 +162,17 @@ export class DaysOfWeekSelector extends ResizeMixin(ThemableMixin(LitElement)) {
157162
}
158163

159164
private _updateOnOverflow() {
160-
const containerWidth = this.getBoundingClientRect().width;
165+
const containerWidth = this._container.getBoundingClientRect().width;
166+
const containerGap = parseFloat(getComputedStyle(this._container).gap) || 0;
167+
161168
let usedWidth = 0;
162169
const overflowButtons: Node[] = [];
163170
const overflowButtonWidth = this._getOverflowButtonWidth();
164171

165172
for (const button of this._daysOfWeek) {
166173
button.style.display = '';
167-
const width = button.getBoundingClientRect().width;
168-
174+
// Add gap only for buttons after the first.
175+
const width = button.getBoundingClientRect().width + (usedWidth > 0 ? containerGap : 0);
169176
if (usedWidth + width > containerWidth - overflowButtonWidth) {
170177
const clonedButton = this._cloneButton(button);
171178
overflowButtons.push(clonedButton);

0 commit comments

Comments
 (0)