-
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 Lit based version of vaadin-tabsheet
- Loading branch information
1 parent
03900c1
commit 5f42230
Showing
8 changed files
with
157 additions
and
20 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,21 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2022 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { defineCustomElement } from '@vaadin/component-base/src/define.js'; | ||
import { Scroller } from '@vaadin/scroller/src/vaadin-lit-scroller.js'; | ||
|
||
/** | ||
* An element used internally by `<vaadin-tabsheet>`. Not intended to be used separately. | ||
* | ||
* @extends Scroller | ||
* @private | ||
*/ | ||
class TabsheetScroller extends Scroller { | ||
static get is() { | ||
return 'vaadin-tabsheet-scroller'; | ||
} | ||
} | ||
|
||
defineCustomElement(TabsheetScroller); |
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 @@ | ||
export * from './vaadin-tabsheet.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,78 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2022 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import './vaadin-lit-tabsheet-scroller.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 { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
import { TabSheetMixin } from './vaadin-tabsheet-mixin.js'; | ||
|
||
/** | ||
* LitElement based version of `<vaadin-tabsheet>` 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. | ||
*/ | ||
class TabSheet extends TabSheetMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))) { | ||
static get is() { | ||
return 'vaadin-tabsheet'; | ||
} | ||
|
||
static get styles() { | ||
return css` | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
:host([hidden]) { | ||
display: none !important; | ||
} | ||
[part='tabs-container'] { | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
} | ||
::slotted([slot='tabs']) { | ||
flex: 1; | ||
align-self: stretch; | ||
min-width: 8em; | ||
} | ||
[part='content'] { | ||
position: relative; | ||
flex: 1; | ||
box-sizing: border-box; | ||
} | ||
`; | ||
} | ||
|
||
/** @protected */ | ||
render() { | ||
return html` | ||
<div part="tabs-container"> | ||
<slot name="prefix"></slot> | ||
<slot name="tabs"></slot> | ||
<slot name="suffix"></slot> | ||
</div> | ||
<vaadin-tabsheet-scroller part="content"> | ||
<div part="loader"></div> | ||
<slot id="panel-slot"></slot> | ||
</vaadin-tabsheet-scroller> | ||
`; | ||
} | ||
} | ||
|
||
defineCustomElement(TabSheet); | ||
|
||
export { TabSheet }; |
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 '@vaadin/tabs/src/vaadin-lit-tabs.js'; | ||
import '../src/vaadin-lit-tabsheet.js'; | ||
import './tabsheet.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 '@vaadin/tabs/src/vaadin-tabs.js'; | ||
import '../src/vaadin-tabsheet.js'; | ||
import './tabsheet.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