dees-appui-catalog/ts_web/elements/lele-appui-mainselector.ts

146 lines
3.4 KiB
TypeScript
Raw Normal View History

2022-05-02 11:43:55 +00:00
import * as interfaces from './interfaces/index.js';
2021-03-06 18:59:00 +00:00
import {
DeesElement,
TemplateResult,
property,
customElement,
html,
2022-01-31 13:07:15 +00:00
css,
cssManager,
2021-03-06 18:59:00 +00:00
} from '@designestate/dees-element';
2021-03-05 16:01:54 +00:00
2022-11-18 00:30:36 +00:00
@customElement('lele-appui-mainselector')
2021-03-05 16:01:54 +00:00
export class DeapMainselector extends DeesElement {
2022-11-18 00:30:36 +00:00
public static demo = () => html`<lele-appui-mainselector></lele-appui-mainselector>`;
2021-03-05 16:01:54 +00:00
// INSTANCE
@property()
2021-03-06 18:59:00 +00:00
public selectionOptions: interfaces.ISelectionOption[] = [
{
key: 'option 1',
action: () => {},
},
{ key: 'option 2', action: () => {} },
{ key: 'option 3', action: () => {} },
{ key: 'option 4', action: () => {} },
2021-03-05 16:01:54 +00:00
];
2021-03-06 18:59:00 +00:00
@property()
public selectedOption: interfaces.ISelectionOption = null;
2022-01-31 13:07:15 +00:00
public static styles = [
cssManager.defaultStyles,
css`
:host {
2021-03-05 16:01:54 +00:00
color: #fff;
position: relative;
display: block;
width: 100%;
max-width: 300px;
height: 100%;
background: #3c3c3c;
}
.maincontainer {
position: absolute;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
}
.topbar {
position: absolute;
height: 80px;
width: 100%;
2021-03-06 18:59:00 +00:00
2021-03-05 16:01:54 +00:00
background: #333333;
}
.topbar .heading {
padding-left: 20px;
line-height: 80px;
font-family: Roboto Mono;
font-size: 16px;
}
.selectionOptions {
position: absolute;
top: 80px;
left: 0px;
width: 100%;
font-family: Roboto Mono;
font-size: 16px;
}
.selectionOptions .selectionOption {
2022-06-10 14:26:12 +00:00
margin-left: 16px;
margin-right: 16px;
padding-top: 8px;
padding-bottom: 8px;
2021-03-05 16:01:54 +00:00
border-top: 1px solid #707070;
2021-03-06 18:59:00 +00:00
border-left: 0px solid rgba(0,0,0,0);
2021-03-05 16:01:54 +00:00
cursor: pointer;
2021-03-06 18:59:00 +00:00
transition: all 0.1s;
}
.selectionOptions .selectionOption:hover {
2022-06-10 14:26:12 +00:00
border-left: 2px solid #26A69A50;
2021-03-06 18:59:00 +00:00
padding-left: 8px;
}
.selectionOptions .selectionOption.selectedOption {
2022-06-10 14:26:12 +00:00
border-left: 4px solid #26A69A;
2021-03-06 18:59:00 +00:00
padding-left: 10px;
2021-03-05 16:01:54 +00:00
}
.selectionOptions .selectionOption:first-child {
2022-06-10 14:26:12 +00:00
margin-top: 16px;
2021-03-05 16:01:54 +00:00
}
.selectionOptions .selectionOption:last-child {
2022-06-10 14:26:12 +00:00
margin-bottom: 16px;
2021-03-05 16:01:54 +00:00
border-bottom: 1px solid #707070;
}
2022-01-31 13:07:15 +00:00
`
];
public render(): TemplateResult {
return html`
<style>
2021-03-05 16:01:54 +00:00
</style>
<div class="maincontainer">
<div class="topbar">
<div class="heading">Properties</div>
</div>
<div class="selectionOptions">
2021-03-06 18:59:00 +00:00
${this.selectionOptions.map((selectionOptionArg) => {
2021-03-05 16:01:54 +00:00
return html`
2021-03-06 18:59:00 +00:00
<div
class="selectionOption ${this.selectedOption === selectionOptionArg
? 'selectedOption'
: null}"
@click="${() => {
this.selectOption(selectionOptionArg);
}}"
>
2021-03-05 16:01:54 +00:00
${selectionOptionArg.key}
</div>
`;
})}
</div>
</div>
`;
}
2021-03-06 18:59:00 +00:00
private selectOption(optionArg: interfaces.ISelectionOption) {
this.selectedOption = optionArg;
this.selectedOption.action();
}
2021-03-08 01:01:56 +00:00
firstUpdated() {
this.selectOption(this.selectionOptions[0]);
}
2021-03-06 18:59:00 +00:00
}