Skip to content

Commit

Permalink
experiment: add LitElement based version of vaadin-board (#8489)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Jan 10, 2025
1 parent 7570f83 commit 2286fee
Show file tree
Hide file tree
Showing 31 changed files with 186 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/board/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"@open-wc/dedupe-mixin": "^1.3.0",
"@polymer/polymer": "^3.0.0",
"@vaadin/a11y-base": "24.7.0-alpha4",
"@vaadin/component-base": "24.7.0-alpha4"
"@vaadin/component-base": "24.7.0-alpha4",
"lit": "^3.0.0"
},
"devDependencies": {
"@vaadin/chai-plugins": "24.7.0-alpha4",
Expand Down
11 changes: 11 additions & 0 deletions packages/board/src/vaadin-lit-board-row.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @license
* Copyright (c) 2000 - 2025 Vaadin Ltd.
*
* This program is available under Vaadin Commercial License and Service Terms.
*
*
* See https://vaadin.com/commercial-license-and-service-terms for the full
* license.
*/
export * from './vaadin-board-row.js';
60 changes: 60 additions & 0 deletions packages/board/src/vaadin-lit-board-row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @license
* Copyright (c) 2000 - 2025 Vaadin Ltd.
*
* This program is available under Vaadin Commercial License and Service Terms.
*
*
* See https://vaadin.com/commercial-license-and-service-terms for the full
* license.
*/
import { css, html, LitElement } from 'lit';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
import { BoardRowMixin } from './vaadin-board-row-mixin.js';

/**
* LitElement based version of `<vaadin-board-row>` web component.
*
* ## Disclaimer
*
* This component is an experiment and not yet a part of Vaadin platform.
* There is no ETA regarding specific Vaadin version where it'll land.
*/
class BoardRow extends BoardRowMixin(ElementMixin(PolylitMixin(LitElement))) {
static get is() {
return 'vaadin-board-row';
}

static get styles() {
return css`
:host {
display: flex;
flex-flow: row wrap;
align-items: stretch;
--small-size: var(--vaadin-board-width-small, 600px);
--medium-size: var(--vaadin-board-width-medium, 960px);
}
:host([hidden]) {
display: none !important;
}
:host ::slotted(*) {
box-sizing: border-box;
flex-grow: 1;
overflow: hidden;
}
`;
}

/** @protected */
render() {
return html`<slot id="insertionPoint"></slot>`;
}
}

defineCustomElement(BoardRow);

export { BoardRow };
11 changes: 11 additions & 0 deletions packages/board/src/vaadin-lit-board.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @license
* Copyright (c) 2000 - 2025 Vaadin Ltd.
*
* This program is available under Vaadin Commercial License and Service Terms.
*
*
* See https://vaadin.com/commercial-license-and-service-terms for the full
* license.
*/
export * from './vaadin-board.js';
66 changes: 66 additions & 0 deletions packages/board/src/vaadin-lit-board.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* @license
* Copyright (c) 2000 - 2025 Vaadin Ltd.
*
* This program is available under Vaadin Commercial License and Service Terms.
*
*
* See https://vaadin.com/commercial-license-and-service-terms for the full
* license.
*/
import './vaadin-lit-board-row.js';
import { css, html, LitElement } from 'lit';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
import { BoardRow } from './vaadin-lit-board-row.js';

/**
* LitElement based version of `<vaadin-board>` web component.
*
* ## Disclaimer
*
* This component is an experiment and not yet a part of Vaadin platform.
* There is no ETA regarding specific Vaadin version where it'll land.
*/
class Board extends ElementMixin(PolylitMixin(LitElement)) {
static get is() {
return 'vaadin-board';
}

static get cvdlName() {
return 'vaadin-board';
}

static get styles() {
return css`
:host {
display: block;
}
:host([hidden]) {
display: none !important;
}
`;
}

/** @protected */
render() {
return html`<slot></slot>`;
}

/**
* Redraws the board and all rows inside it, if necessary.
*
* In most cases, board will redraw itself if your reconfigure it. If you dynamically change
* breakpoints `--vaadin-board-width-small` or `--vaadin-board-width-medium`,
* then you need to call this method.
*/
redraw() {
[...this.querySelectorAll('*')].filter((node) => node instanceof BoardRow).forEach((row) => row.redraw());
}
}

defineCustomElement(Board);

export { Board };
2 changes: 2 additions & 0 deletions packages/board/test/basic-lit.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-lit-board.js';
import './basic.common.js';
2 changes: 2 additions & 0 deletions packages/board/test/basic-polymer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-board.js';
import './basic.common.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { fixtureSync } from '@vaadin/testing-helpers';
import '../vaadin-board.js';

describe('vaadin-board', () => {
let board, tagName;
Expand Down
2 changes: 2 additions & 0 deletions packages/board/test/board-cols-lit.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-lit-board-row.js';
import './board-cols.common.js';
2 changes: 2 additions & 0 deletions packages/board/test/board-cols-polymer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-board-row.js';
import './board-cols.common.js';
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from '@vaadin/chai-plugins';
import { aTimeout, fixtureSync } from '@vaadin/testing-helpers';
import sinon from 'sinon';
import '../vaadin-board-row.js';

describe('board-cols', () => {
let row;
Expand Down
2 changes: 2 additions & 0 deletions packages/board/test/board-row-lit.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-lit-board-row.js';
import './board-row.common.js';
2 changes: 2 additions & 0 deletions packages/board/test/board-row-polymer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-board-row.js';
import './board-row.common.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { fixtureSync } from '@vaadin/testing-helpers';
import '../vaadin-board.js';

describe('vaadin-board-row', () => {
let row;
Expand Down
2 changes: 2 additions & 0 deletions packages/board/test/light-dom-lit.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-lit-board-row.js';
import './light-dom.common.js';
2 changes: 2 additions & 0 deletions packages/board/test/light-dom-polymer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-board-row.js';
import './light-dom.common.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { fixtureSync, nextFrame } from '@vaadin/testing-helpers';
import '../vaadin-board-row.js';

describe('light DOM children', () => {
let row;
Expand Down
2 changes: 2 additions & 0 deletions packages/board/test/redraw-lit.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-lit-board.js';
import './redraw.common.js';
2 changes: 2 additions & 0 deletions packages/board/test/redraw-polymer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-board.js';
import './redraw.common.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { aTimeout, fixtureSync, nextResize } from '@vaadin/testing-helpers';
import '../vaadin-board.js';
import { allResized } from './helpers.js';

describe('redraw', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/board/test/size-lit.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-lit-board.js';
import './size.common.js';
2 changes: 2 additions & 0 deletions packages/board/test/size-polymer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '../vaadin-board.js';
import './size.common.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect } from '@vaadin/chai-plugins';
import { fixtureSync } from '@vaadin/testing-helpers';
import '../vaadin-board.js';
import { allResized } from './helpers.js';

describe('size', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/board/theme/lumo/vaadin-lit-board-row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../../src/vaadin-lit-board-row.js';
2 changes: 2 additions & 0 deletions packages/board/theme/lumo/vaadin-lit-board.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './vaadin-lit-board-row.js';
import '../../src/vaadin-lit-board.js';
1 change: 1 addition & 0 deletions packages/board/theme/material/vaadin-lit-board-row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../../src/vaadin-lit-board-row.js';
2 changes: 2 additions & 0 deletions packages/board/theme/material/vaadin-lit-board.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './vaadin-lit-board-row.js';
import '../../src/vaadin-lit-board.js';
1 change: 1 addition & 0 deletions packages/board/vaadin-lit-board-row.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/vaadin-board-row.js';
2 changes: 2 additions & 0 deletions packages/board/vaadin-lit-board-row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './theme/lumo/vaadin-lit-board-row.js';
export * from './src/vaadin-lit-board-row.js';
1 change: 1 addition & 0 deletions packages/board/vaadin-lit-board.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/vaadin-board.js';
2 changes: 2 additions & 0 deletions packages/board/vaadin-lit-board.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './theme/lumo/vaadin-lit-board.js';
export * from './src/vaadin-lit-board.js';

0 comments on commit 2286fee

Please sign in to comment.