2022-05-02 11:43:55 +00:00
|
|
|
import * as interfaces from './interfaces/index.js';
|
2021-03-06 17:07:06 +00:00
|
|
|
|
2022-01-31 13:07:15 +00:00
|
|
|
import {
|
|
|
|
DeesElement,
|
|
|
|
TemplateResult,
|
|
|
|
property,
|
|
|
|
customElement,
|
|
|
|
html,
|
|
|
|
css,
|
|
|
|
cssManager,
|
2023-09-06 16:43:33 +00:00
|
|
|
} from '@design.estate/dees-element';
|
2021-03-05 16:01:54 +00:00
|
|
|
|
2023-09-06 16:43:33 +00:00
|
|
|
import * as domtools from '@design.estate/dees-domtools';
|
2021-03-05 16:01:54 +00:00
|
|
|
|
2022-11-18 00:30:36 +00:00
|
|
|
@customElement('lele-appui-maincontent')
|
2021-03-05 16:01:54 +00:00
|
|
|
export class DeapMaincontent extends DeesElement {
|
2022-11-18 00:30:36 +00:00
|
|
|
public static demo = () => html`<lele-appui-maincontent></lele-appui-maincontent>`;
|
2021-03-05 16:01:54 +00:00
|
|
|
|
|
|
|
// INSTANCE
|
|
|
|
@property()
|
2021-03-06 18:59:00 +00:00
|
|
|
public tabs: interfaces.ITab[] = [
|
2022-01-31 13:07:15 +00:00
|
|
|
{ key: 'option 1', action: () => {} },
|
|
|
|
{ key: 'a very long option', action: () => {} },
|
|
|
|
{ key: 'reminder: set your tabs', action: () => {} },
|
|
|
|
{ key: 'option 4', action: () => {} },
|
2021-03-05 16:01:54 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
@property()
|
|
|
|
public selectedTab = null;
|
|
|
|
|
2022-01-31 13:07:15 +00:00
|
|
|
public static styles = [
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
css`
|
|
|
|
:host {
|
|
|
|
color: #fff;
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
position: relative;
|
2023-09-06 16:43:33 +00:00
|
|
|
background: #161616;
|
2022-01-31 13:07:15 +00:00
|
|
|
}
|
|
|
|
.maincontainer {
|
|
|
|
position: absolute;
|
|
|
|
height: 100%;
|
|
|
|
right: 0px;
|
|
|
|
top: 0px;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar {
|
|
|
|
position: absolute;
|
|
|
|
width: 100%;
|
2023-09-06 16:43:33 +00:00
|
|
|
height: 80px;
|
|
|
|
background: #000000;
|
2022-01-31 13:07:15 +00:00
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar .heading {
|
2023-09-06 16:43:33 +00:00
|
|
|
padding: 8px 24px 8px 24px;
|
|
|
|
font-family: 'Hubot Sans', sans-serif;
|
|
|
|
font-weight: 600;
|
|
|
|
line-height: 24px;
|
|
|
|
font-size: 16px;
|
|
|
|
height: 40px;
|
2022-01-31 13:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.topbar .tabsContainer {
|
|
|
|
display: grid;
|
2023-09-06 16:43:33 +00:00
|
|
|
margin-left: 24px;
|
2022-01-31 13:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.topbar .tabsContainer .tab {
|
|
|
|
color: #a0a0a0;
|
|
|
|
white-space: nowrap;
|
2022-06-10 14:26:12 +00:00
|
|
|
margin-right: 16px;
|
2023-09-06 16:43:33 +00:00
|
|
|
margin-top: 8px;
|
2022-01-31 13:07:15 +00:00
|
|
|
cursor: pointer;
|
|
|
|
transition: color 0.1s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar .tabsContainer .tab:hover {
|
|
|
|
color: #ffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar .tabsContainer .tab.selectedTab {
|
|
|
|
color: #e0e0e0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar .tabIndicator {
|
|
|
|
position: absolute;
|
2022-06-10 14:26:12 +00:00
|
|
|
left: 40px;
|
2022-01-31 13:07:15 +00:00
|
|
|
bottom: 0px;
|
|
|
|
height: 4px;
|
2022-06-10 14:26:12 +00:00
|
|
|
width: 40px;
|
2023-09-06 16:43:33 +00:00
|
|
|
background: #161616;
|
2022-01-31 13:07:15 +00:00
|
|
|
transition: all 0.1s;
|
2023-09-06 16:43:33 +00:00
|
|
|
border-top-left-radius: 8px;
|
|
|
|
border-top-right-radius: 8px;
|
|
|
|
border-top: 1px solid #e4002b;
|
2022-01-31 13:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.mainicon {
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
];
|
|
|
|
|
2021-03-05 16:01:54 +00:00
|
|
|
public render(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<style>
|
|
|
|
.topbar .tabsContainer {
|
2022-01-31 13:07:15 +00:00
|
|
|
grid-template-columns: repeat(${this.tabs.length}, min-content);
|
2021-03-05 16:01:54 +00:00
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<div class="maincontainer">
|
|
|
|
<div class="topbar">
|
|
|
|
<div class="heading">lossless.com</div>
|
|
|
|
<div class="tabsContainer">
|
2022-01-31 13:07:15 +00:00
|
|
|
${this.tabs.map((tabArg) => {
|
2021-03-05 16:01:54 +00:00
|
|
|
return html`
|
2022-01-31 13:07:15 +00:00
|
|
|
<div
|
|
|
|
class="tab ${tabArg === this.selectedTab ? 'selectedTab' : null}"
|
|
|
|
@click="${() => {
|
|
|
|
this.selectedTab = tabArg;
|
|
|
|
this.updateTabIndicator();
|
|
|
|
tabArg.action();
|
|
|
|
}}"
|
|
|
|
>
|
|
|
|
${tabArg.key}
|
|
|
|
</div>
|
2021-03-05 16:01:54 +00:00
|
|
|
`;
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
<div class="tabIndicator"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* updates the indicator
|
|
|
|
*/
|
2021-03-06 18:59:00 +00:00
|
|
|
private updateTabIndicator() {
|
2021-03-05 16:01:54 +00:00
|
|
|
let selectedTab = this.selectedTab;
|
|
|
|
const tabIndex = this.tabs.indexOf(selectedTab);
|
2022-01-31 13:07:15 +00:00
|
|
|
const selectedTabElement: HTMLElement = this.shadowRoot.querySelector(
|
|
|
|
`.tabsContainer .tab:nth-child(${tabIndex + 1})`
|
|
|
|
);
|
2021-03-05 16:01:54 +00:00
|
|
|
const tabIndicator: HTMLElement = this.shadowRoot.querySelector('.tabIndicator');
|
|
|
|
tabIndicator.style.width = selectedTabElement.clientWidth + 'px';
|
|
|
|
tabIndicator.style.left = selectedTabElement.offsetLeft + 'px';
|
|
|
|
}
|
2021-03-06 18:59:00 +00:00
|
|
|
|
|
|
|
private updateTab(tabArg: interfaces.ITab) {
|
|
|
|
this.selectedTab = tabArg;
|
|
|
|
this.updateTabIndicator();
|
|
|
|
this.selectedTab.action();
|
|
|
|
}
|
|
|
|
|
|
|
|
firstUpdated() {
|
|
|
|
this.updateTab(this.tabs[0]);
|
|
|
|
}
|
2022-01-31 13:07:15 +00:00
|
|
|
}
|