Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: layout improvements #8508

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/horizontal-layout/src/vaadin-horizontal-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class HorizontalLayout extends ElementMixin(ThemableMixin(PolymerElement)) {
:host([theme~='spacing']) {
gap: 1em;
}

::slotted(*) {
--_vaadin-layout-item-horizontal-flex: 0 1 auto;
min-width: calc(var(--vaadin-layout-improvements) * 0px);
flex: calc(var(--vaadin-layout-improvements) * var(--_vaadin-layout-item-horizontal-flex));
}
</style>

<slot></slot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class HorizontalLayout extends ThemableMixin(ElementMixin(PolylitMixin(LitElemen
:host([theme~='spacing']) {
gap: 1em;
}

::slotted(*) {
--_vaadin-layout-item-horizontal-flex: 0 1 auto;
min-width: calc(var(--vaadin-layout-improvements) * 0px);
flex: calc(var(--vaadin-layout-improvements) * var(--_vaadin-layout-item-horizontal-flex));
}
`;
}

Expand Down
47 changes: 47 additions & 0 deletions packages/horizontal-layout/test/horizontal-layout.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,51 @@ describe('vaadin-horizontal-layout', () => {
expect(wrapper.scrollWidth).to.equal(200);
});
});

describe('layout improvements', () => {
let layout, child;

beforeEach(() => {
layout = fixtureSync(`
<vaadin-horizontal-layout>
<div>child</div>
</vaadin-horizontal-layout>
`);
child = layout.querySelector('div');
});

describe('disabled', () => {
it('should apply min-width auto to children', () => {
expect(getComputedStyle(child).minWidth).to.equal('auto');
});

it('should apply default flex to children', () => {
expect(getComputedStyle(child).flex).to.equal('0 1 auto');
});

it('should not apply custom flex property to children', () => {
child.style.setProperty('--_vaadin-layout-item-horizontal-flex', '1');
expect(getComputedStyle(child).flex).to.equal('0 1 auto');
});
});

describe('enabled', () => {
beforeEach(() => {
layout.style.setProperty('--vaadin-layout-improvements', '1');
});

it('should apply min-width 0px to children', () => {
expect(getComputedStyle(child).minWidth).to.equal('0px');
});

it('should apply default flex to children', () => {
expect(getComputedStyle(child).flex).to.equal('0 1 auto');
});

it('should apply custom flex property to children ', () => {
child.style.setProperty('--_vaadin-layout-item-horizontal-flex', '1');
expect(getComputedStyle(child).flex).to.equal('1 1 0%');
});
});
});
});
6 changes: 6 additions & 0 deletions packages/vertical-layout/src/vaadin-lit-vertical-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class VerticalLayout extends ThemableMixin(ElementMixin(PolylitMixin(LitElement)
:host([theme~='spacing']) {
gap: 1em;
}

::slotted(*) {
--_vaadin-layout-item-vertical-flex: 0 1 auto;
min-height: calc(var(--vaadin-layout-improvements) * 0px);
flex: calc(var(--vaadin-layout-improvements) * var(--_vaadin-layout-item-vertical-flex));
}
`;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/vertical-layout/src/vaadin-vertical-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class VerticalLayout extends ElementMixin(ThemableMixin(PolymerElement)) {
:host([theme~='spacing']) {
gap: 1em;
}

::slotted(*) {
--_vaadin-layout-item-vertical-flex: 0 1 auto;
min-height: calc(var(--vaadin-layout-improvements) * 0px);
flex: calc(var(--vaadin-layout-improvements) * var(--_vaadin-layout-item-vertical-flex));
}
</style>

<slot></slot>
Expand Down
47 changes: 47 additions & 0 deletions packages/vertical-layout/test/vertical-layout.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,51 @@ describe('vaadin-vertical-layout', () => {
expect(wrapper.scrollHeight).to.equal(200);
});
});

describe('layout improvements', () => {
let layout, child;

beforeEach(() => {
layout = fixtureSync(`
<vaadin-vertical-layout>
<div>child</div>
</vaadin-vertical-layout>
`);
child = layout.querySelector('div');
});

describe('disabled', () => {
it('should apply min-height auto to children', () => {
expect(getComputedStyle(child).minHeight).to.equal('auto');
});

it('should apply default flex to children', () => {
expect(getComputedStyle(child).flex).to.equal('0 1 auto');
});

it('should not apply custom flex property to children', () => {
child.style.setProperty('--_vaadin-layout-item-vertical-flex', '1');
expect(getComputedStyle(child).flex).to.equal('0 1 auto');
});
});

describe('enabled', () => {
beforeEach(() => {
layout.style.setProperty('--vaadin-layout-improvements', '1');
});

it('should apply min-height 0px to children', () => {
expect(getComputedStyle(child).minHeight).to.equal('0px');
});

it('should apply default flex to children', () => {
expect(getComputedStyle(child).flex).to.equal('0 1 auto');
});

it('should apply custom flex property to children ', () => {
child.style.setProperty('--_vaadin-layout-item-vertical-flex', '1');
expect(getComputedStyle(child).flex).to.equal('1 1 0%');
});
});
});
});