-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experiment: add LitElement based version of tabs (#7379)
- Loading branch information
1 parent
b494a51
commit 939d0e3
Showing
19 changed files
with
170 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
export * from './vaadin-tab.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { 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 { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js'; | ||
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
import { TabMixin } from './vaadin-tab-mixin.js'; | ||
import { tabStyles } from './vaadin-tab-styles.js'; | ||
|
||
/** | ||
* LitElement based version of `<vaadin-tab>` 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. | ||
* Feel free to try this code in your apps as per Apache 2.0 license. | ||
* | ||
* @extends HTMLElement | ||
* @mixes ElementMixin | ||
* @mixes TabMixin | ||
* @mixes ThemableMixin | ||
*/ | ||
class Tab extends TabMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))) { | ||
static get is() { | ||
return 'vaadin-tab'; | ||
} | ||
|
||
static get styles() { | ||
return [tabStyles]; | ||
} | ||
|
||
/** @protected */ | ||
render() { | ||
return html` | ||
<slot></slot> | ||
<slot name="tooltip"></slot> | ||
`; | ||
} | ||
|
||
/** @protected */ | ||
ready() { | ||
super.ready(); | ||
|
||
this._tooltipController = new TooltipController(this); | ||
this.addController(this._tooltipController); | ||
} | ||
} | ||
|
||
defineCustomElement(Tab); | ||
|
||
export { Tab }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
export * from './vaadin-tabs.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import './vaadin-lit-tab.js'; | ||
import { 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 { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
import { TabsMixin } from './vaadin-tabs-mixin.js'; | ||
import { tabsStyles } from './vaadin-tabs-styles.js'; | ||
|
||
/** | ||
* LitElement based version of `<vaadin-tabs>` 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. | ||
* Feel free to try this code in your apps as per Apache 2.0 license. | ||
* | ||
* @extends HTMLElement | ||
* @mixes ElementMixin | ||
* @mixes TabsMixin | ||
* @mixes ThemableMixin | ||
*/ | ||
class Tabs extends TabsMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) { | ||
static get is() { | ||
return 'vaadin-tabs'; | ||
} | ||
|
||
static get styles() { | ||
return [tabsStyles]; | ||
} | ||
|
||
/** @protected */ | ||
render() { | ||
return html` | ||
<div @click="${this._scrollBack}" part="back-button" aria-hidden="true"></div> | ||
<div id="scroll" part="tabs"> | ||
<slot></slot> | ||
</div> | ||
<div @click="${this._scrollForward}" part="forward-button" aria-hidden="true"></div> | ||
`; | ||
} | ||
} | ||
|
||
defineCustomElement(Tabs); | ||
|
||
export { Tabs }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './not-animated-styles.js'; | ||
import '../theme/lumo/vaadin-lit-tabs.js'; | ||
import './scroll.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './not-animated-styles.js'; | ||
import '../vaadin-tabs.js'; | ||
import './scroll.common.js'; |
2 changes: 0 additions & 2 deletions
2
packages/tabs/test/scroll.test.js → packages/tabs/test/scroll.common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../src/vaadin-lit-tab.js'; | ||
import './tab.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../src/vaadin-tab.js'; | ||
import './tab.common.js'; |
6 changes: 3 additions & 3 deletions
6
packages/tabs/test/tab.test.js → packages/tabs/test/tab.common.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../theme/lumo/vaadin-lit-tabs.js'; | ||
import './tabs.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../vaadin-tabs.js'; | ||
import './tabs.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-tab-styles.js'; | ||
import '../../src/vaadin-lit-tab.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './vaadin-lit-tab.js'; | ||
import './vaadin-tabs-styles.js'; | ||
import '../../src/vaadin-lit-tabs.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import './vaadin-tab-styles.js'; | ||
import '../../src/vaadin-lit-tab.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './vaadin-lit-tab.js'; | ||
import './vaadin-tabs-styles.js'; | ||
import '../../src/vaadin-lit-tabs.js'; |